[projects/pld-builder.new] Fix iterators assumptions that are no longer valid in python3
baggins
baggins at pld-linux.org
Sun Jan 17 19:53:02 CET 2021
commit 8b63d7eb90a010ae55a08a723ecb433d1e643a40
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Sun Jan 17 19:52:41 2021 +0100
Fix iterators assumptions that are no longer valid in python3
PLD_Builder/build.py | 2 +-
PLD_Builder/chroot.py | 2 +-
PLD_Builder/file_sender.py | 4 ++--
PLD_Builder/get_br.py | 3 +--
PLD_Builder/install.py | 10 +++++-----
PLD_Builder/load_balancer.py | 2 +-
PLD_Builder/mailer.py | 4 ++--
PLD_Builder/poldek.py | 3 +--
PLD_Builder/report.py | 4 ++--
PLD_Builder/request_handler.py | 2 +-
PLD_Builder/util.py | 2 +-
11 files changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/PLD_Builder/build.py b/PLD_Builder/build.py
index a7c281b..bf38ff4 100644
--- a/PLD_Builder/build.py
+++ b/PLD_Builder/build.py
@@ -36,7 +36,7 @@ def run_command(batch):
# TODO: the append here by shell hack should be solved in python
c = "(%s) >> %s 2>&1" % (command, batch.logfile)
f = os.popen(c)
- for l in f.xreadlines():
+ for l in f:
pass
r = f.close()
if r == None:
diff --git a/PLD_Builder/chroot.py b/PLD_Builder/chroot.py
index f099d01..a489ac3 100644
--- a/PLD_Builder/chroot.py
+++ b/PLD_Builder/chroot.py
@@ -49,7 +49,7 @@ def run(cmd, user = "builder", logfile = None, logstdout = None):
def cp(file, outfile, user="builder", rm=False):
m = md5()
- m.update(str(random.sample(xrange(100000), 500)))
+ m.update(str(random.sample(range(100000), 500)))
digest = m.hexdigest()
marker_start = "--- FILE BEGIN DIGEST %s ---" % digest
diff --git a/PLD_Builder/file_sender.py b/PLD_Builder/file_sender.py
index 4e90e5a..44fdd8b 100644
--- a/PLD_Builder/file_sender.py
+++ b/PLD_Builder/file_sender.py
@@ -24,7 +24,7 @@ def read_name_val(file):
f = open(file)
r = {'_file': file[:-5], '_desc': file}
rx = re.compile(r"^([^:]+)\s*:(.*)$")
- for l in f.xreadlines():
+ for l in f:
if l == "END\n":
f.close()
return r
@@ -60,7 +60,7 @@ def rsync_file(src, target, host):
p = open(path.rsync_password_file, "r")
password = ""
- for l in p.xreadlines():
+ for l in p:
l = string.split(l)
if len(l) >= 2 and l[0] == host:
password = l[1]
diff --git a/PLD_Builder/get_br.py b/PLD_Builder/get_br.py
index 2465866..933548c 100644
--- a/PLD_Builder/get_br.py
+++ b/PLD_Builder/get_br.py
@@ -4,7 +4,6 @@ from __future__ import print_function
import re
import string
-import xreadlines
from util import *
@@ -63,7 +62,7 @@ def get_build_requires(spec, bconds_with, bconds_without):
build_req = []
f = open(spec)
- for l in xreadlines.xreadlines(f):
+ for l in f:
l = string.strip(l)
if l == "%changelog": break
diff --git a/PLD_Builder/install.py b/PLD_Builder/install.py
index ddb5bea..da3ba05 100644
--- a/PLD_Builder/install.py
+++ b/PLD_Builder/install.py
@@ -34,7 +34,7 @@ def close_killset(killset):
f = chroot.popen("poldek --noask --test --test --erase %s" % p, user = "root")
crucial = 0
e = []
- for l in f.xreadlines():
+ for l in f:
m = rx.search(l)
if m:
pkg = m.group('name')
@@ -55,7 +55,7 @@ def upgrade_from_batch(r, b):
f = chroot.popen("rpm --test -F %s 2>&1" % string.join(b.files), user = "root")
killset = {}
rx = re.compile(r' \(installed\) (?P<name>[^\s]+)-[^-]+-[^-]+$')
- for l in f.xreadlines():
+ for l in f:
m = rx.search(l)
if m: killset[m.group('name')] = 1
f.close()
@@ -115,7 +115,7 @@ def uninstall_self_conflict(b):
# java-sun conflicts with soprano-2.1.67-1.src
rx = re.compile(r"\s+(?P<name>[\w-]+)\s+.*conflicts with [^\s]+-[^-]+-[^-]+\.src($| .*)")
conflicting = {}
- for l in f.xreadlines():
+ for l in f:
m = rx.search(l)
if m:
b.log_line("rpmbuild: %s" % l.rstrip())
@@ -142,7 +142,7 @@ def install_br(r, b):
rx = re.compile(r"^\s*(?P<name>[^\s]+) .*is needed by")
needed = {}
b.log_line("checking BR")
- for l in f.xreadlines():
+ for l in f:
b.log_line("rpm: %s" % l.rstrip())
m = rx.search(l)
if m and not ignore_br.match(l):
@@ -170,7 +170,7 @@ def install_br(r, b):
# jmx is needed by (installed) java-commons-modeler-2.0-1.noarch
rx = re.compile(r".*(conflicts with|is required by|is needed by)( installed| \(installed\)|) (?P<name>[^\s]+)-[^-]+-[^-]+($| .*)")
conflicting = {}
- for l in f.xreadlines():
+ for l in f:
b.log_line("poldek: %s" % l.rstrip())
m = rx.search(l)
if m: conflicting[m.group('name')] = 1
diff --git a/PLD_Builder/load_balancer.py b/PLD_Builder/load_balancer.py
index 2e182c8..a530f81 100644
--- a/PLD_Builder/load_balancer.py
+++ b/PLD_Builder/load_balancer.py
@@ -29,7 +29,7 @@ def builders_order():
f = open(path.got_lock_file, "r+")
line_no = 0
- for l in f.xreadlines():
+ for l in f:
line_no += 1
b = string.strip(l)
if bs.has_key(b):
diff --git a/PLD_Builder/mailer.py b/PLD_Builder/mailer.py
index 7e260b8..4e771dc 100644
--- a/PLD_Builder/mailer.py
+++ b/PLD_Builder/mailer.py
@@ -51,11 +51,11 @@ class Message:
# just head and tail
f = open(log)
line_cnt = 0
- for l in f.xreadlines():
+ for l in f:
line_cnt += 1
f.seek(0)
line = 0
- for l in f.xreadlines():
+ for l in f:
if line < 100 or line > line_cnt - 100:
self.body.write(recode(l))
if line == line_cnt - 100:
diff --git a/PLD_Builder/poldek.py b/PLD_Builder/poldek.py
index 9b23a89..df9df9b 100644
--- a/PLD_Builder/poldek.py
+++ b/PLD_Builder/poldek.py
@@ -3,7 +3,6 @@
import re
import types
import string
-import xreadlines
from chroot import *
from util import *
@@ -55,7 +54,7 @@ def get_poldek_requires():
cur_pkg = None
f = chr_popen("poldek -v -v --verify --unique-pkg-names")
- for l in xreadlines.xreadlines(f):
+ for l in f:
m = name_rx.match(l)
if m:
if cur_pkg:
diff --git a/PLD_Builder/report.py b/PLD_Builder/report.py
index c35af0e..0190f9f 100644
--- a/PLD_Builder/report.py
+++ b/PLD_Builder/report.py
@@ -13,7 +13,7 @@ def unpackaged_files(b):
f = open(b.logfile)
copy_mode = 0
out = []
- for l in f.xreadlines():
+ for l in f:
if l == msg:
copy_mode = 1
out.append(l)
@@ -41,7 +41,7 @@ def info_from_log(b, target):
f = open(b.logfile)
copy_mode = 0
need_header = 1
- for l in f.xreadlines():
+ for l in f:
if l == beg:
if need_header:
need_header = 0
diff --git a/PLD_Builder/request_handler.py b/PLD_Builder/request_handler.py
index d84b4cc..2307607 100644
--- a/PLD_Builder/request_handler.py
+++ b/PLD_Builder/request_handler.py
@@ -30,7 +30,7 @@ def check_double_id(id):
id_nl = id + "\n"
ids = open(path.processed_ids_file)
- for i in ids.xreadlines():
+ for i in ids:
if i == id_nl:
# FIXME: security email here?
log.alert("request %s already processed" % id)
diff --git a/PLD_Builder/util.py b/PLD_Builder/util.py
index 86f6776..b4c8599 100644
--- a/PLD_Builder/util.py
+++ b/PLD_Builder/util.py
@@ -54,7 +54,7 @@ def collect_files(log, basedir = "/home"):
rx = re.compile(r"^Wrote: (%s.*\.rpm)$" % basedir)
proc = re.compile(r"^Processing files:.*$")
files = []
- for l in reversed(list(f.xreadlines())):
+ for l in reversed(list(f)):
if proc.match(l):
break
m = rx.search(l)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/8b63d7eb90a010ae55a08a723ecb433d1e643a40
More information about the pld-cvs-commit
mailing list