Merge lp:~bdrung/apport/cleanup into lp:~apport-hackers/apport/trunk

Proposed by Benjamin Drung
Status: Needs review
Proposed branch: lp:~bdrung/apport/cleanup
Merge into: lp:~apport-hackers/apport/trunk
Diff against target: 404 lines (+80/-74)
15 files modified
apport/__init__.py (+3/-3)
apport/crashdb_impl/launchpad.py (+1/-1)
apport/fileutils.py (+3/-3)
apport/hookutils.py (+9/-9)
apport/packaging.py (+5/-5)
apport/report.py (+1/-1)
apport/sandboxutils.py (+23/-17)
apport/ui.py (+15/-15)
backends/packaging-apt-dpkg.py (+5/-5)
data/package_hook (+6/-6)
setup.py (+2/-2)
test/test_apport_valgrind.py (+1/-1)
test/test_fileutils.py (+3/-3)
test/test_signal_crashes.py (+2/-2)
test/test_ui.py (+1/-1)
To merge this branch: bzr merge lp:~bdrung/apport/cleanup
Reviewer Review Type Date Requested Status
Apport upstream developers Pending
Review via email: mp+389618@code.launchpad.net

Description of the change

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.

To post a comment you must log in.

Unmerged revisions

3284. By Benjamin Drung

Log package versions installed in sandbox

3283. By Benjamin Drung

Fix pep8 errors regarding ambiguous variables

Import changes from apport 2.20.11-0ubuntu42 (from Brian Murray).

3282. By Benjamin Drung

Resolve pycodestyle issues

Import changes from apport 2.20.11-0ubuntu7 (from Brian Murray).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
6464
65 memstat = {}65 memstat = {}
66 with open('/proc/self/status') as f:66 with open('/proc/self/status') as f:
67 for l in f:67 for line in f:
68 if l.startswith('Vm'):68 if line.startswith('Vm'):
69 (field, size, unit) = l.split()69 (field, size, unit) = line.split()
70 memstat[field[:-1]] = int(size) / 1024.70 memstat[field[:-1]] = int(size) / 1024.
7171
72 sys.stderr.write('Size: %.1f MB, RSS: %.1f MB, Stk: %.1f MB @ %s\n' %72 sys.stderr.write('Size: %.1f MB, RSS: %.1f MB, Stk: %.1f MB @ %s\n' %
7373
=== 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 @@
968 hdr['Subscribers'] = 'apport'968 hdr['Subscribers'] = 'apport'
969 hdr['Tags'] += ' need-duplicate-check'969 hdr['Tags'] += ' need-duplicate-check'
970 if 'DuplicateSignature' in report and 'need-duplicate-check' not in hdr['Tags']:970 if 'DuplicateSignature' in report and 'need-duplicate-check' not in hdr['Tags']:
971 hdr['Tags'] += ' need-duplicate-check'971 hdr['Tags'] += ' need-duplicate-check'
972972
973 # if we have checkbox submission key, link it to the bug; keep text973 # if we have checkbox submission key, link it to the bug; keep text
974 # reference until the link is shown in Launchpad's UI974 # reference until the link is shown in Launchpad's UI
975975
=== 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 @@
314 return []314 return []
315315
316 mismatches = []316 mismatches = []
317 for l in out.splitlines():317 for line in out.splitlines():
318 if l.endswith('FAILED'):318 if line.endswith('FAILED'):
319 mismatches.append(l.rsplit(':', 1)[0])319 mismatches.append(line.rsplit(':', 1)[0])
320320
321 return mismatches321 return mismatches
322322
323323
=== 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 @@
608 env['XDG_CONFIG_HOME'] = '/nonexisting'608 env['XDG_CONFIG_HOME'] = '/nonexisting'
609 gsettings = subprocess.Popen(['gsettings', 'list-recursively', schema],609 gsettings = subprocess.Popen(['gsettings', 'list-recursively', schema],
610 env=env, stdout=subprocess.PIPE)610 env=env, stdout=subprocess.PIPE)
611 for l in gsettings.stdout:611 for line in gsettings.stdout:
612 try:612 try:
613 (schema_name, key, value) = l.split(None, 2)613 (schema_name, key, value) = line.split(None, 2)
614 value = value.rstrip()614 value = value.rstrip()
615 except ValueError:615 except ValueError:
616 continue # invalid line616 continue # invalid line
@@ -618,9 +618,9 @@
618618
619 gsettings = subprocess.Popen(['gsettings', 'list-recursively', schema],619 gsettings = subprocess.Popen(['gsettings', 'list-recursively', schema],
620 stdout=subprocess.PIPE)620 stdout=subprocess.PIPE)
621 for l in gsettings.stdout:621 for line in gsettings.stdout:
622 try:622 try:
623 (schema_name, key, value) = l.split(None, 2)623 (schema_name, key, value) = line.split(None, 2)
624 value = value.rstrip()624 value = value.rstrip()
625 except ValueError:625 except ValueError:
626 continue # invalid line626 continue # invalid line
@@ -801,8 +801,8 @@
801 return 'invalid'801 return 'invalid'
802 except OSError:802 except OSError:
803 return None803 return None
804 for l in out.splitlines():804 for line in out.splitlines():
805 fields = l.split(':', 1)805 fields = line.split(':', 1)
806 if len(fields) < 2:806 if len(fields) < 2:
807 continue807 continue
808 if fields[0] == 'license':808 if fields[0] == 'license':
@@ -816,7 +816,7 @@
816816
817 try:817 try:
818 with open(module_list) as f:818 with open(module_list) as f:
819 mods = [l.split()[0] for l in f]819 mods = [line.split()[0] for line in f]
820 except IOError:820 except IOError:
821 return []821 return []
822822
@@ -912,9 +912,9 @@
912912
913 if os.path.exists(path):913 if os.path.exists(path):
914 with open(path, 'r') as f:914 with open(path, 'r') as f:
915 filtered = [l if not l.startswith('password')915 filtered = [line if not line.startswith('password')
916 else '### PASSWORD LINE REMOVED ###'916 else '### PASSWORD LINE REMOVED ###'
917 for l in f.readlines()]917 for line in f.readlines()]
918 report[key] = ''.join(filtered)918 report[key] = ''.join(filtered)
919919
920920
921921
=== 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 @@
283 name = None283 name = None
284 version = None284 version = None
285 with open('/etc/os-release') as f:285 with open('/etc/os-release') as f:
286 for l in f:286 for line in f:
287 if l.startswith('NAME='):287 if line.startswith('NAME='):
288 name = l.split('=', 1)[1]288 name = line.split('=', 1)[1]
289 if name.startswith('"'):289 if name.startswith('"'):
290 name = name[1:-2].strip()290 name = name[1:-2].strip()
291 # work around inconsistent "Debian GNU/Linux" in os-release291 # work around inconsistent "Debian GNU/Linux" in os-release
292 if name.endswith('GNU/Linux'):292 if name.endswith('GNU/Linux'):
293 name = name.split()[0:-1]293 name = name.split()[0:-1]
294 elif l.startswith('VERSION_ID='):294 elif line.startswith('VERSION_ID='):
295 version = l.split('=', 1)[1]295 version = line.split('=', 1)[1]
296 if version.startswith('"'):296 if version.startswith('"'):
297 version = version[1:-2].strip()297 version = version[1:-2].strip()
298 if name and version:298 if name and version:
299299
=== 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 @@
505 pathlist = [path]505 pathlist = [path]
506506
507 if not module and desc[2] == imp.PKG_DIRECTORY:507 if not module and desc[2] == imp.PKG_DIRECTORY:
508 module = ['__init__']508 module = ['__init__']
509509
510 if path and path.endswith('.pyc'):510 if path and path.endswith('.pyc'):
511 path = path[:-1]511 path = path[:-1]
512512
=== 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 @@
23 pkgs = {}23 pkgs = {}
2424
25 # first, grab the versions that we captured at crash time25 # first, grab the versions that we captured at crash time
26 for l in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():26 for line in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():
27 if not l.strip():27 if not line.strip():
28 continue28 continue
29 try:29 try:
30 (pkg, version) = l.split()[:2]30 (pkg, version) = line.split()[:2]
31 except ValueError:31 except ValueError:
32 apport.warning('invalid Package/Dependencies line: %s', l)32 apport.warning('invalid Package/Dependencies line: %s', line)
33 # invalid line, ignore33 # invalid line, ignore
34 continue34 continue
35 pkgs[pkg] = version35 pkgs[pkg] = version
@@ -41,13 +41,13 @@
41 '''Return package -> version dictionary from report'''41 '''Return package -> version dictionary from report'''
4242
43 pkg_vers = {}43 pkg_vers = {}
44 for l in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():44 for line in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():
45 if not l.strip():45 if not line.strip():
46 continue46 continue
47 try:47 try:
48 (pkg, version) = l.split()[:2]48 (pkg, version) = line.split()[:2]
49 except ValueError:49 except ValueError:
50 apport.warning('invalid Package/Dependencies line: %s', l)50 apport.warning('invalid Package/Dependencies line: %s', line)
51 # invalid line, ignore51 # invalid line, ignore
52 continue52 continue
53 pkg_vers[pkg] = version53 pkg_vers[pkg] = version
@@ -74,10 +74,10 @@
74 pkgs = set()74 pkgs = set()
75 libs = set()75 libs = set()
76 if 'ProcMaps' in report:76 if 'ProcMaps' in report:
77 for l in report['ProcMaps'].splitlines():77 for line in report['ProcMaps'].splitlines():
78 if not l.strip():78 if not line.strip():
79 continue79 continue
80 cols = l.split()80 cols = line.split()
81 if len(cols) in (6, 7) and 'x' in cols[1] and '.so' in cols[5]:81 if len(cols) in (6, 7) and 'x' in cols[1] and '.so' in cols[5]:
82 lib = os.path.realpath(cols[5])82 lib = os.path.realpath(cols[5])
83 libs.add(lib)83 libs.add(lib)
@@ -88,16 +88,18 @@
88 os.makedirs(pkgmap_cache_dir)88 os.makedirs(pkgmap_cache_dir)
8989
90 # grab as much as we can90 # grab as much as we can
91 for l in libs:91 for line in libs:
92 pkg = apport.packaging.get_file_package(l, True, pkgmap_cache_dir,92 pkg = apport.packaging.get_file_package(line, True, pkgmap_cache_dir,
93 release=report['DistroRelease'],93 release=report['DistroRelease'],
94 arch=report.get('Architecture'))94 arch=report.get('Architecture'))
95 if pkg:95 if pkg:
96 if verbose:96 if verbose:
97 apport.log('dynamically loaded %s needs package %s, queueing' % (l, pkg))97 apport.log('dynamically loaded %s needs package %s, queueing'
98 % (line, pkg))
98 pkgs.add(pkg)99 pkgs.add(pkg)
99 else:100 else:
100 apport.warning('%s is needed, but cannot be mapped to a package', l)101 apport.warning('%s is needed, but cannot be mapped to a package',
102 line)
101103
102 return [(p, pkg_versions.get(p)) for p in pkgs]104 return [(p, pkg_versions.get(p)) for p in pkgs]
103105
@@ -235,8 +237,12 @@
235 report['ExecutablePath'] = '/bin/systemctl'237 report['ExecutablePath'] = '/bin/systemctl'
236 pkg = 'systemd'238 pkg = 'systemd'
237 if pkg:239 if pkg:
238 apport.log('Installing extra package %s to get %s' % (pkg, path), log_timestamps)240 version = pkg_versions.get(pkg)
239 pkgs.append((pkg, pkg_versions.get(pkg)))241 pkg_version = "{}={}".format(pkg, version) if version else pkg
242 apport.log(
243 "Installing extra package %s to get %s" % (pkg_version, path), log_timestamps
244 )
245 pkgs.append((pkg, version))
240 else:246 else:
241 apport.fatal('Cannot find package which ships %s %s', path, report[path])247 apport.fatal('Cannot find package which ships %s %s', path, report[path])
242248
243249
=== 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 @@
711 self.ui_error_message(_('Invalid problem report'), excstr(e))711 self.ui_error_message(_('Invalid problem report'), excstr(e))
712 return True712 return True
713 elif self.options.window:713 elif self.options.window:
714 self.ui_info_message('', _('After closing this message '714 self.ui_info_message('', _('After closing this message '
715 'please click on an application window to report a problem about it.'))715 'please click on an application window to report a problem about it.'))
716 xprop = subprocess.Popen(['xprop', '_NET_WM_PID'],716 xprop = subprocess.Popen(['xprop', '_NET_WM_PID'],
717 stdout=subprocess.PIPE, stderr=subprocess.PIPE)717 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
718 (out, err) = xprop.communicate()718 (out, err) = xprop.communicate()
719 if xprop.returncode == 0:719 if xprop.returncode == 0:
720 try:720 try:
721 self.options.pid = int(out.split()[-1])721 self.options.pid = int(out.split()[-1])
722 except ValueError:722 except ValueError:
723 self.ui_error_message(_('Cannot create report'),
724 _('xprop failed to determine process ID of the window'))
725 return True
726 return self.run_report_bug()
727 else:
728 self.ui_error_message(_('Cannot create report'),723 self.ui_error_message(_('Cannot create report'),
729 _('xprop failed to determine process ID of the window') + '\n\n' + err)724 _('xprop failed to determine process ID of the window'))
730 return True725 return True
726 return self.run_report_bug()
727 else:
728 self.ui_error_message(_('Cannot create report'),
729 _('xprop failed to determine process ID of the window') + '\n\n' + err)
730 return True
731 else:731 else:
732 return self.run_crashes()732 return self.run_crashes()
733733
734734
=== 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 @@
1213 return []1213 return []
12141214
1215 mismatches = []1215 mismatches = []
1216 for l in out.splitlines():1216 for line in out.splitlines():
1217 if l.endswith('FAILED'):1217 if line.endswith('FAILED'):
1218 mismatches.append(l.rsplit(':', 1)[0])1218 mismatches.append(line.rsplit(':', 1)[0])
12191219
1220 return mismatches1220 return mismatches
12211221
@@ -1224,8 +1224,8 @@
1224 '''Heuristically determine primary mirror from an apt sources.list'''1224 '''Heuristically determine primary mirror from an apt sources.list'''
12251225
1226 with open(apt_sources) as f:1226 with open(apt_sources) as f:
1227 for l in f:1227 for line in f:
1228 fields = l.split()1228 fields = line.split()
1229 if len(fields) >= 3 and fields[0] == 'deb':1229 if len(fields) >= 3 and fields[0] == 'deb':
1230 if fields[1].startswith('['):1230 if fields[1].startswith('['):
1231 # options given, mirror is in third field1231 # options given, mirror is in third field
12321232
=== 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 @@
52 tags = options.tags.replace(',', '')52 tags = options.tags.replace(',', '')
53 pr['Tags'] = tags53 pr['Tags'] = tags
5454
55for l in (options.logs or []):55for line in (options.logs or []):
56 if os.path.isfile(l):56 if os.path.isfile(line):
57 pr[mkattrname(l)] = (l,)57 pr[mkattrname(line)] = (line,)
58 elif os.path.isdir(l):58 elif os.path.isdir(line):
59 for f in os.listdir(l):59 for f in os.listdir(line):
60 path = os.path.join(l, f)60 path = os.path.join(line, f)
61 if os.path.isfile(path):61 if os.path.isfile(path):
62 pr[mkattrname(path)] = (path,)62 pr[mkattrname(path)] = (path,)
6363
6464
=== 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 @@
75 distutils.log.info('Updating hashbang of %s', f)75 distutils.log.info('Updating hashbang of %s', f)
76 lines[0] = new_hashbang76 lines[0] = new_hashbang
77 with open(f, 'w') as fd:77 with open(f, 'w') as fd:
78 for l in lines:78 for line in lines:
79 fd.write(l)79 fd.write(line)
8080
8181
82#82#
8383
=== 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 @@
94}'''94}'''
9595
96 with open('memleak.c', 'w') as fd:96 with open('memleak.c', 'w') as fd:
97 fd.write(code)97 fd.write(code)
98 cmd = ['gcc', '-Wall', '-Werror', '-g', 'memleak.c', '-o', 'memleak']98 cmd = ['gcc', '-Wall', '-Werror', '-g', 'memleak.c', '-o', 'memleak']
99 self.assertEqual(99 self.assertEqual(
100 subprocess.call(cmd), 0, 'compiling memleak.c failed.')100 subprocess.call(cmd), 0, 'compiling memleak.c failed.')
101101
=== 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 @@
377 self.assertTrue('libc.so.6' in libs, libs)377 self.assertTrue('libc.so.6' in libs, libs)
378 self.assertTrue('libc.so.6' in libs['libc.so.6'], libs['libc.so.6'])378 self.assertTrue('libc.so.6' in libs['libc.so.6'], libs['libc.so.6'])
379 self.assertTrue(os.path.exists(libs['libc.so.6']))379 self.assertTrue(os.path.exists(libs['libc.so.6']))
380 for l in libs:380 for line in libs:
381 self.assertFalse('vdso' in l, libs)381 self.assertFalse('vdso' in line, libs)
382 self.assertTrue(os.path.exists(libs[l]))382 self.assertTrue(os.path.exists(libs[line]))
383383
384 self.assertEqual(apport.fileutils.shared_libraries('/non/existing'), {})384 self.assertEqual(apport.fileutils.shared_libraries('/non/existing'), {})
385 self.assertEqual(apport.fileutils.shared_libraries('/etc'), {})385 self.assertEqual(apport.fileutils.shared_libraries('/etc'), {})
386386
=== 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 @@
138 'LC_TELEPHONE', 'LC_MEASUREMENT', 'LC_IDENTIFICATION',138 'LC_TELEPHONE', 'LC_MEASUREMENT', 'LC_IDENTIFICATION',
139 'LOCPATH', 'TERM', 'XDG_RUNTIME_DIR', 'LD_PRELOAD']139 'LOCPATH', 'TERM', 'XDG_RUNTIME_DIR', 'LD_PRELOAD']
140140
141 for l in pr['ProcEnviron'].splitlines():141 for line in pr['ProcEnviron'].splitlines():
142 (k, v) = l.split('=', 1)142 (k, v) = line.split('=', 1)
143 self.assertTrue(k in allowed_vars,143 self.assertTrue(k in allowed_vars,
144 'report contains sensitive environment variable %s' % k)144 'report contains sensitive environment variable %s' % k)
145145
146146
=== 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 @@
1770 def _run_hook(self, code):1770 def _run_hook(self, code):
1771 f = open(os.path.join(self.hookdir, 'coreutils.py'), 'w')1771 f = open(os.path.join(self.hookdir, 'coreutils.py'), 'w')
1772 f.write('def add_info(report, ui):\n%s\n' %1772 f.write('def add_info(report, ui):\n%s\n' %
1773 '\n'.join([' ' + l for l in code.splitlines()]))1773 '\n'.join([' ' + line for line in code.splitlines()]))
1774 f.close()1774 f.close()
1775 self.ui.options.package = 'coreutils'1775 self.ui.options.package = 'coreutils'
1776 self.ui.run_report_bug()1776 self.ui.run_report_bug()

Subscribers

People subscribed via source and target branches