apport-hackers team mailing list archive
-
apport-hackers team
-
Mailing list archive
-
Message #00317
[Merge] lp:~bdrung/apport/cleanup into lp:apport
Benjamin Drung has proposed merging lp:~bdrung/apport/cleanup into lp:apport.
Requested reviews:
Apport upstream developers (apport-hackers)
For more details, see:
https://code.launchpad.net/~bdrung/apport/cleanup/+merge/389618
This merge request pulls the commits from the Ubuntu package that fixes pep8 and pycodestyle issues. It also logs the package versions installed in the sandbox.
--
Your team Apport upstream developers is requested to review the proposed merge of lp:~bdrung/apport/cleanup into lp:apport.
=== modified file 'apport/__init__.py'
--- apport/__init__.py 2015-08-10 08:01:38 +0000
+++ apport/__init__.py 2020-08-20 16:32:50 +0000
@@ -64,9 +64,9 @@
memstat = {}
with open('/proc/self/status') as f:
- for l in f:
- if l.startswith('Vm'):
- (field, size, unit) = l.split()
+ for line in f:
+ if line.startswith('Vm'):
+ (field, size, unit) = line.split()
memstat[field[:-1]] = int(size) / 1024.
sys.stderr.write('Size: %.1f MB, RSS: %.1f MB, Stk: %.1f MB @ %s\n' %
=== modified file 'apport/crashdb_impl/launchpad.py'
--- apport/crashdb_impl/launchpad.py 2019-04-01 21:59:51 +0000
+++ apport/crashdb_impl/launchpad.py 2020-08-20 16:32:50 +0000
@@ -968,7 +968,7 @@
hdr['Subscribers'] = 'apport'
hdr['Tags'] += ' need-duplicate-check'
if 'DuplicateSignature' in report and 'need-duplicate-check' not in hdr['Tags']:
- hdr['Tags'] += ' need-duplicate-check'
+ hdr['Tags'] += ' need-duplicate-check'
# if we have checkbox submission key, link it to the bug; keep text
# reference until the link is shown in Launchpad's UI
=== modified file 'apport/fileutils.py'
--- apport/fileutils.py 2018-07-02 08:46:13 +0000
+++ apport/fileutils.py 2020-08-20 16:32:50 +0000
@@ -314,9 +314,9 @@
return []
mismatches = []
- for l in out.splitlines():
- if l.endswith('FAILED'):
- mismatches.append(l.rsplit(':', 1)[0])
+ for line in out.splitlines():
+ if line.endswith('FAILED'):
+ mismatches.append(line.rsplit(':', 1)[0])
return mismatches
=== modified file 'apport/hookutils.py'
--- apport/hookutils.py 2019-05-16 18:48:29 +0000
+++ apport/hookutils.py 2020-08-20 16:32:50 +0000
@@ -608,9 +608,9 @@
env['XDG_CONFIG_HOME'] = '/nonexisting'
gsettings = subprocess.Popen(['gsettings', 'list-recursively', schema],
env=env, stdout=subprocess.PIPE)
- for l in gsettings.stdout:
+ for line in gsettings.stdout:
try:
- (schema_name, key, value) = l.split(None, 2)
+ (schema_name, key, value) = line.split(None, 2)
value = value.rstrip()
except ValueError:
continue # invalid line
@@ -618,9 +618,9 @@
gsettings = subprocess.Popen(['gsettings', 'list-recursively', schema],
stdout=subprocess.PIPE)
- for l in gsettings.stdout:
+ for line in gsettings.stdout:
try:
- (schema_name, key, value) = l.split(None, 2)
+ (schema_name, key, value) = line.split(None, 2)
value = value.rstrip()
except ValueError:
continue # invalid line
@@ -801,8 +801,8 @@
return 'invalid'
except OSError:
return None
- for l in out.splitlines():
- fields = l.split(':', 1)
+ for line in out.splitlines():
+ fields = line.split(':', 1)
if len(fields) < 2:
continue
if fields[0] == 'license':
@@ -816,7 +816,7 @@
try:
with open(module_list) as f:
- mods = [l.split()[0] for l in f]
+ mods = [line.split()[0] for line in f]
except IOError:
return []
@@ -912,9 +912,9 @@
if os.path.exists(path):
with open(path, 'r') as f:
- filtered = [l if not l.startswith('password')
+ filtered = [line if not line.startswith('password')
else '### PASSWORD LINE REMOVED ###'
- for l in f.readlines()]
+ for line in f.readlines()]
report[key] = ''.join(filtered)
=== modified file 'apport/packaging.py'
--- apport/packaging.py 2017-06-12 23:42:53 +0000
+++ apport/packaging.py 2020-08-20 16:32:50 +0000
@@ -283,16 +283,16 @@
name = None
version = None
with open('/etc/os-release') as f:
- for l in f:
- if l.startswith('NAME='):
- name = l.split('=', 1)[1]
+ for line in f:
+ if line.startswith('NAME='):
+ name = line.split('=', 1)[1]
if name.startswith('"'):
name = name[1:-2].strip()
# work around inconsistent "Debian GNU/Linux" in os-release
if name.endswith('GNU/Linux'):
name = name.split()[0:-1]
- elif l.startswith('VERSION_ID='):
- version = l.split('=', 1)[1]
+ elif line.startswith('VERSION_ID='):
+ version = line.split('=', 1)[1]
if version.startswith('"'):
version = version[1:-2].strip()
if name and version:
=== modified file 'apport/report.py'
--- apport/report.py 2020-06-09 21:41:57 +0000
+++ apport/report.py 2020-08-20 16:32:50 +0000
@@ -505,7 +505,7 @@
pathlist = [path]
if not module and desc[2] == imp.PKG_DIRECTORY:
- module = ['__init__']
+ module = ['__init__']
if path and path.endswith('.pyc'):
path = path[:-1]
=== modified file 'apport/sandboxutils.py'
--- apport/sandboxutils.py 2020-04-13 21:19:56 +0000
+++ apport/sandboxutils.py 2020-08-20 16:32:50 +0000
@@ -23,13 +23,13 @@
pkgs = {}
# first, grab the versions that we captured at crash time
- for l in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():
- if not l.strip():
+ for line in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():
+ if not line.strip():
continue
try:
- (pkg, version) = l.split()[:2]
+ (pkg, version) = line.split()[:2]
except ValueError:
- apport.warning('invalid Package/Dependencies line: %s', l)
+ apport.warning('invalid Package/Dependencies line: %s', line)
# invalid line, ignore
continue
pkgs[pkg] = version
@@ -41,13 +41,13 @@
'''Return package -> version dictionary from report'''
pkg_vers = {}
- for l in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():
- if not l.strip():
+ for line in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():
+ if not line.strip():
continue
try:
- (pkg, version) = l.split()[:2]
+ (pkg, version) = line.split()[:2]
except ValueError:
- apport.warning('invalid Package/Dependencies line: %s', l)
+ apport.warning('invalid Package/Dependencies line: %s', line)
# invalid line, ignore
continue
pkg_vers[pkg] = version
@@ -74,10 +74,10 @@
pkgs = set()
libs = set()
if 'ProcMaps' in report:
- for l in report['ProcMaps'].splitlines():
- if not l.strip():
+ for line in report['ProcMaps'].splitlines():
+ if not line.strip():
continue
- cols = l.split()
+ cols = line.split()
if len(cols) in (6, 7) and 'x' in cols[1] and '.so' in cols[5]:
lib = os.path.realpath(cols[5])
libs.add(lib)
@@ -88,16 +88,18 @@
os.makedirs(pkgmap_cache_dir)
# grab as much as we can
- for l in libs:
- pkg = apport.packaging.get_file_package(l, True, pkgmap_cache_dir,
+ for line in libs:
+ pkg = apport.packaging.get_file_package(line, True, pkgmap_cache_dir,
release=report['DistroRelease'],
arch=report.get('Architecture'))
if pkg:
if verbose:
- apport.log('dynamically loaded %s needs package %s, queueing' % (l, pkg))
+ apport.log('dynamically loaded %s needs package %s, queueing'
+ % (line, pkg))
pkgs.add(pkg)
else:
- apport.warning('%s is needed, but cannot be mapped to a package', l)
+ apport.warning('%s is needed, but cannot be mapped to a package',
+ line)
return [(p, pkg_versions.get(p)) for p in pkgs]
@@ -235,8 +237,12 @@
report['ExecutablePath'] = '/bin/systemctl'
pkg = 'systemd'
if pkg:
- apport.log('Installing extra package %s to get %s' % (pkg, path), log_timestamps)
- pkgs.append((pkg, pkg_versions.get(pkg)))
+ version = pkg_versions.get(pkg)
+ pkg_version = "{}={}".format(pkg, version) if version else pkg
+ apport.log(
+ "Installing extra package %s to get %s" % (pkg_version, path), log_timestamps
+ )
+ pkgs.append((pkg, version))
else:
apport.fatal('Cannot find package which ships %s %s', path, report[path])
=== modified file 'apport/ui.py'
--- apport/ui.py 2019-07-22 19:11:45 +0000
+++ apport/ui.py 2020-08-20 16:32:50 +0000
@@ -711,23 +711,23 @@
self.ui_error_message(_('Invalid problem report'), excstr(e))
return True
elif self.options.window:
- self.ui_info_message('', _('After closing this message '
- 'please click on an application window to report a problem about it.'))
- xprop = subprocess.Popen(['xprop', '_NET_WM_PID'],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (out, err) = xprop.communicate()
- if xprop.returncode == 0:
- try:
- self.options.pid = int(out.split()[-1])
- except ValueError:
- self.ui_error_message(_('Cannot create report'),
- _('xprop failed to determine process ID of the window'))
- return True
- return self.run_report_bug()
- else:
+ self.ui_info_message('', _('After closing this message '
+ 'please click on an application window to report a problem about it.'))
+ xprop = subprocess.Popen(['xprop', '_NET_WM_PID'],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (out, err) = xprop.communicate()
+ if xprop.returncode == 0:
+ try:
+ self.options.pid = int(out.split()[-1])
+ except ValueError:
self.ui_error_message(_('Cannot create report'),
- _('xprop failed to determine process ID of the window') + '\n\n' + err)
+ _('xprop failed to determine process ID of the window'))
return True
+ return self.run_report_bug()
+ else:
+ self.ui_error_message(_('Cannot create report'),
+ _('xprop failed to determine process ID of the window') + '\n\n' + err)
+ return True
else:
return self.run_crashes()
=== modified file 'backends/packaging-apt-dpkg.py'
--- backends/packaging-apt-dpkg.py 2020-04-16 00:25:44 +0000
+++ backends/packaging-apt-dpkg.py 2020-08-20 16:32:50 +0000
@@ -1213,9 +1213,9 @@
return []
mismatches = []
- for l in out.splitlines():
- if l.endswith('FAILED'):
- mismatches.append(l.rsplit(':', 1)[0])
+ for line in out.splitlines():
+ if line.endswith('FAILED'):
+ mismatches.append(line.rsplit(':', 1)[0])
return mismatches
@@ -1224,8 +1224,8 @@
'''Heuristically determine primary mirror from an apt sources.list'''
with open(apt_sources) as f:
- for l in f:
- fields = l.split()
+ for line in f:
+ fields = line.split()
if len(fields) >= 3 and fields[0] == 'deb':
if fields[1].startswith('['):
# options given, mirror is in third field
=== modified file 'data/package_hook'
--- data/package_hook 2016-12-10 11:28:27 +0000
+++ data/package_hook 2020-08-20 16:32:50 +0000
@@ -52,12 +52,12 @@
tags = options.tags.replace(',', '')
pr['Tags'] = tags
-for l in (options.logs or []):
- if os.path.isfile(l):
- pr[mkattrname(l)] = (l,)
- elif os.path.isdir(l):
- for f in os.listdir(l):
- path = os.path.join(l, f)
+for line in (options.logs or []):
+ if os.path.isfile(line):
+ pr[mkattrname(line)] = (line,)
+ elif os.path.isdir(line):
+ for f in os.listdir(line):
+ path = os.path.join(line, f)
if os.path.isfile(path):
pr[mkattrname(path)] = (path,)
=== modified file 'setup.py'
--- setup.py 2019-03-29 20:55:44 +0000
+++ setup.py 2020-08-20 16:32:50 +0000
@@ -75,8 +75,8 @@
distutils.log.info('Updating hashbang of %s', f)
lines[0] = new_hashbang
with open(f, 'w') as fd:
- for l in lines:
- fd.write(l)
+ for line in lines:
+ fd.write(line)
#
=== modified file 'test/test_apport_valgrind.py'
--- test/test_apport_valgrind.py 2019-05-16 18:48:29 +0000
+++ test/test_apport_valgrind.py 2020-08-20 16:32:50 +0000
@@ -94,7 +94,7 @@
}'''
with open('memleak.c', 'w') as fd:
- fd.write(code)
+ fd.write(code)
cmd = ['gcc', '-Wall', '-Werror', '-g', 'memleak.c', '-o', 'memleak']
self.assertEqual(
subprocess.call(cmd), 0, 'compiling memleak.c failed.')
=== modified file 'test/test_fileutils.py'
--- test/test_fileutils.py 2016-12-10 11:28:27 +0000
+++ test/test_fileutils.py 2020-08-20 16:32:50 +0000
@@ -377,9 +377,9 @@
self.assertTrue('libc.so.6' in libs, libs)
self.assertTrue('libc.so.6' in libs['libc.so.6'], libs['libc.so.6'])
self.assertTrue(os.path.exists(libs['libc.so.6']))
- for l in libs:
- self.assertFalse('vdso' in l, libs)
- self.assertTrue(os.path.exists(libs[l]))
+ for line in libs:
+ self.assertFalse('vdso' in line, libs)
+ self.assertTrue(os.path.exists(libs[line]))
self.assertEqual(apport.fileutils.shared_libraries('/non/existing'), {})
self.assertEqual(apport.fileutils.shared_libraries('/etc'), {})
=== modified file 'test/test_signal_crashes.py'
--- test/test_signal_crashes.py 2018-03-23 20:23:02 +0000
+++ test/test_signal_crashes.py 2020-08-20 16:32:50 +0000
@@ -138,8 +138,8 @@
'LC_TELEPHONE', 'LC_MEASUREMENT', 'LC_IDENTIFICATION',
'LOCPATH', 'TERM', 'XDG_RUNTIME_DIR', 'LD_PRELOAD']
- for l in pr['ProcEnviron'].splitlines():
- (k, v) = l.split('=', 1)
+ for line in pr['ProcEnviron'].splitlines():
+ (k, v) = line.split('=', 1)
self.assertTrue(k in allowed_vars,
'report contains sensitive environment variable %s' % k)
=== modified file 'test/test_ui.py'
--- test/test_ui.py 2019-05-16 18:48:29 +0000
+++ test/test_ui.py 2020-08-20 16:32:50 +0000
@@ -1770,7 +1770,7 @@
def _run_hook(self, code):
f = open(os.path.join(self.hookdir, 'coreutils.py'), 'w')
f.write('def add_info(report, ui):\n%s\n' %
- '\n'.join([' ' + l for l in code.splitlines()]))
+ '\n'.join([' ' + line for line in code.splitlines()]))
f.close()
self.ui.options.package = 'coreutils'
self.ui.run_report_bug()