Skip to content

Commit

Permalink
PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Jul 9, 2020
1 parent eea2818 commit 5104de9
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ jobs:
;;
checks)
flake8 --ignore=E731,W504
find scripts -name '*.py' -exec flake8 {} +
diff -q reprozip/reprozip/common.py reprounzip/reprounzip/common.py
diff -q reprozip/reprozip/utils.py reprounzip/reprounzip/utils.py
find reprozip reprounzip reprozip-* reprounzip-* .travis -name '*.py' -or -name '*.sh' -or -name '*.h' -or -name '*.c' | (set +x; while read i; do
Expand Down
10 changes: 5 additions & 5 deletions reprounzip/reprounzip/unpackers/common/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def get_packages_info(packages):
pkgs_dict = dict((pkg.name, (pkg, PKG_NOT_INSTALLED))
for pkg in packages)
try:
for l in p.stdout:
fields = l.split()
for line in p.stdout:
fields = line.split()
if len(fields) == 2:
name = fields[0].decode('ascii')
status = fields[1].decode('ascii')
Expand Down Expand Up @@ -124,9 +124,9 @@ def get_packages_info(packages):
pkgs_dict = dict((pkg.name, (pkg, PKG_NOT_INSTALLED))
for pkg in packages)
try:
for l in p.stdout:
if l[0] == b'+':
fields = l[1:].split()
for line in p.stdout:
if line[0] == b'+':
fields = line[1:].split()
if len(fields) == 2:
name = fields[0].decode('ascii')
status = fields[1].decode('ascii')
Expand Down
8 changes: 4 additions & 4 deletions reprounzip/reprounzip/unpackers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ def directory_run(args):
stderr=subprocess.PIPE)
stdout, _ = p.communicate()
try:
for l in stdout.splitlines():
if len(l) < 2 or l[0] in (b' ', b'\t'):
for line in stdout.splitlines():
if len(line) < 2 or line[0] in (b' ', b'\t'):
continue
if l.endswith(b':'):
lib_dirs.append(Path(l[:-1]))
if line.endswith(b':'):
lib_dirs.append(Path(line[:-1]))
finally:
if p.returncode != 0:
raise subprocess.CalledProcessError(p.returncode,
Expand Down
4 changes: 2 additions & 2 deletions reprozip/reprozip/tracer/linux_pkgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def search_for_files(self, files):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = proc.communicate()
for l in out.splitlines():
pkgname, path = l.split(b': ', 1)
for line in out.splitlines():
pkgname, path = line.split(b': ', 1)
path = Path(path.strip())
# 8-bit safe encoding, because this might be a localized error
# message (that we don't care about)
Expand Down
4 changes: 2 additions & 2 deletions scripts/conda/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def build_pkg(python_ver, package_name):
with open(join(temp_dir, package_name, 'meta.yaml')) as fp:
lines = fp.readlines()
# Changes version in recipe
lines = [l.replace('_REPLACE_version_REPLACE_', version)
for l in lines]
lines = [line.replace('_REPLACE_version_REPLACE_', version)
for line in lines]
with open(join(temp_dir, package_name, 'meta.yaml'), 'w') as fp:
for line in lines:
# Changes version
Expand Down
30 changes: 16 additions & 14 deletions tests/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ def functional_tests(raise_warnings, interactive, run_vagrant, run_docker):
#

output = check_output(rpz + ['testrun', '/bin/echo', 'outputhere'])
assert any(b' 1 | /bin/echo outputhere ' in l
for l in output.splitlines())
assert any(b' 1 | /bin/echo outputhere ' in line
for line in output.splitlines())

output = check_output(rpz + ['testrun', '-a', '/fake/path/echo',
'/bin/echo', 'outputhere'])
assert any(b' 1 | (/bin/echo) /fake/path/echo outputhere ' in l
for l in output.splitlines())
assert any(b' 1 | (/bin/echo) /fake/path/echo outputhere ' in line
for line in output.splitlines())

# ########################################
# testrun multiple commands
Expand Down Expand Up @@ -494,8 +494,8 @@ def check_simple(args, stream, infile=1):
build('threads', ['threads.c'], ['-lpthread'])
# Trace
output = check_output(rpz + ['testrun', './threads'], 'err')
assert any(b'successfully exec\'d /bin/./echo' in l
for l in output.splitlines())
assert any(b'successfully exec\'d /bin/./echo' in line
for line in output.splitlines())

# ########################################
# 'threads2' program: testrun
Expand All @@ -505,8 +505,8 @@ def check_simple(args, stream, infile=1):
build('threads2', ['threads2.c'], ['-lpthread'])
# Trace
output = check_output(rpz + ['testrun', './threads2'], 'err')
assert any(b'successfully exec\'d /bin/echo' in l
for l in output.splitlines())
assert any(b'successfully exec\'d /bin/echo' in line
for line in output.splitlines())

# ########################################
# 'segv' program: testrun
Expand Down Expand Up @@ -579,9 +579,10 @@ def check_simple(args, stream, infile=1):
# Trace
err = check_output(rpz + ['testrun', './connect'], 'err')
err = err.split(b'\n')
assert not any(b'program exited with non-zero code' in l for l in err)
assert any(re.search(br'process connected to [0-9.]+:80', l)
for l in err)
assert not any(b'program exited with non-zero code' in line
for line in err)
assert any(re.search(br'process connected to [0-9.]+:80', line)
for line in err)

# ########################################
# 'vfork' program: testrun
Expand All @@ -592,7 +593,8 @@ def check_simple(args, stream, infile=1):
# Trace
err = check_output(rpz + ['testrun', './vfork'], 'err')
err = err.split(b'\n')
assert not any(b'program exited with non-zero code' in l for l in err)
assert not any(b'program exited with non-zero code' in line
for line in err)

# ########################################
# 'rename' program: trace
Expand Down Expand Up @@ -758,7 +760,7 @@ def check_simple(args, stream, infile=1):
'94627ebfafbf81cd77a17d4ed646a80c94bf4202'],
'err')
err = err.split(b'\n')
assert any(b'executing set-uid binary!' in l for l in err)
assert any(b'executing set-uid binary!' in line for line in err)

# ########################################
# Test set-gid warning
Expand All @@ -773,7 +775,7 @@ def check_simple(args, stream, infile=1):
# Pass a wrong username to su to make it exit without reading a password
_, err = call_output(rpz + ['testrun', executable, '-l'], 'err')
err = err.split(b'\n')
assert any(b'executing set-gid binary!' in l for l in err)
assert any(b'executing set-gid binary!' in line for line in err)

# ########################################
# Test old packages
Expand Down
4 changes: 2 additions & 2 deletions tests/test_reprozip.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ def fail(s):
set(fi.path for fi in files))
self.assertEqualPaths([set(["/some/r", "/some/rw"]),
set(["/some/cli", "/some/r"])],
[set(l) for l in inputs])
[set(run) for run in inputs])
self.assertEqualPaths([set(["/some/cli"]), set(["/some/rw"])],
[set(l) for l in outputs])
[set(run) for run in outputs])
finally:
Path.is_file, Path.stat = old

Expand Down

0 comments on commit 5104de9

Please sign in to comment.