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
1=== modified file 'apport/__init__.py'
2--- apport/__init__.py 2015-08-10 08:01:38 +0000
3+++ apport/__init__.py 2020-08-20 16:32:50 +0000
4@@ -64,9 +64,9 @@
5
6 memstat = {}
7 with open('/proc/self/status') as f:
8- for l in f:
9- if l.startswith('Vm'):
10- (field, size, unit) = l.split()
11+ for line in f:
12+ if line.startswith('Vm'):
13+ (field, size, unit) = line.split()
14 memstat[field[:-1]] = int(size) / 1024.
15
16 sys.stderr.write('Size: %.1f MB, RSS: %.1f MB, Stk: %.1f MB @ %s\n' %
17
18=== modified file 'apport/crashdb_impl/launchpad.py'
19--- apport/crashdb_impl/launchpad.py 2019-04-01 21:59:51 +0000
20+++ apport/crashdb_impl/launchpad.py 2020-08-20 16:32:50 +0000
21@@ -968,7 +968,7 @@
22 hdr['Subscribers'] = 'apport'
23 hdr['Tags'] += ' need-duplicate-check'
24 if 'DuplicateSignature' in report and 'need-duplicate-check' not in hdr['Tags']:
25- hdr['Tags'] += ' need-duplicate-check'
26+ hdr['Tags'] += ' need-duplicate-check'
27
28 # if we have checkbox submission key, link it to the bug; keep text
29 # reference until the link is shown in Launchpad's UI
30
31=== modified file 'apport/fileutils.py'
32--- apport/fileutils.py 2018-07-02 08:46:13 +0000
33+++ apport/fileutils.py 2020-08-20 16:32:50 +0000
34@@ -314,9 +314,9 @@
35 return []
36
37 mismatches = []
38- for l in out.splitlines():
39- if l.endswith('FAILED'):
40- mismatches.append(l.rsplit(':', 1)[0])
41+ for line in out.splitlines():
42+ if line.endswith('FAILED'):
43+ mismatches.append(line.rsplit(':', 1)[0])
44
45 return mismatches
46
47
48=== modified file 'apport/hookutils.py'
49--- apport/hookutils.py 2019-05-16 18:48:29 +0000
50+++ apport/hookutils.py 2020-08-20 16:32:50 +0000
51@@ -608,9 +608,9 @@
52 env['XDG_CONFIG_HOME'] = '/nonexisting'
53 gsettings = subprocess.Popen(['gsettings', 'list-recursively', schema],
54 env=env, stdout=subprocess.PIPE)
55- for l in gsettings.stdout:
56+ for line in gsettings.stdout:
57 try:
58- (schema_name, key, value) = l.split(None, 2)
59+ (schema_name, key, value) = line.split(None, 2)
60 value = value.rstrip()
61 except ValueError:
62 continue # invalid line
63@@ -618,9 +618,9 @@
64
65 gsettings = subprocess.Popen(['gsettings', 'list-recursively', schema],
66 stdout=subprocess.PIPE)
67- for l in gsettings.stdout:
68+ for line in gsettings.stdout:
69 try:
70- (schema_name, key, value) = l.split(None, 2)
71+ (schema_name, key, value) = line.split(None, 2)
72 value = value.rstrip()
73 except ValueError:
74 continue # invalid line
75@@ -801,8 +801,8 @@
76 return 'invalid'
77 except OSError:
78 return None
79- for l in out.splitlines():
80- fields = l.split(':', 1)
81+ for line in out.splitlines():
82+ fields = line.split(':', 1)
83 if len(fields) < 2:
84 continue
85 if fields[0] == 'license':
86@@ -816,7 +816,7 @@
87
88 try:
89 with open(module_list) as f:
90- mods = [l.split()[0] for l in f]
91+ mods = [line.split()[0] for line in f]
92 except IOError:
93 return []
94
95@@ -912,9 +912,9 @@
96
97 if os.path.exists(path):
98 with open(path, 'r') as f:
99- filtered = [l if not l.startswith('password')
100+ filtered = [line if not line.startswith('password')
101 else '### PASSWORD LINE REMOVED ###'
102- for l in f.readlines()]
103+ for line in f.readlines()]
104 report[key] = ''.join(filtered)
105
106
107
108=== modified file 'apport/packaging.py'
109--- apport/packaging.py 2017-06-12 23:42:53 +0000
110+++ apport/packaging.py 2020-08-20 16:32:50 +0000
111@@ -283,16 +283,16 @@
112 name = None
113 version = None
114 with open('/etc/os-release') as f:
115- for l in f:
116- if l.startswith('NAME='):
117- name = l.split('=', 1)[1]
118+ for line in f:
119+ if line.startswith('NAME='):
120+ name = line.split('=', 1)[1]
121 if name.startswith('"'):
122 name = name[1:-2].strip()
123 # work around inconsistent "Debian GNU/Linux" in os-release
124 if name.endswith('GNU/Linux'):
125 name = name.split()[0:-1]
126- elif l.startswith('VERSION_ID='):
127- version = l.split('=', 1)[1]
128+ elif line.startswith('VERSION_ID='):
129+ version = line.split('=', 1)[1]
130 if version.startswith('"'):
131 version = version[1:-2].strip()
132 if name and version:
133
134=== modified file 'apport/report.py'
135--- apport/report.py 2020-06-09 21:41:57 +0000
136+++ apport/report.py 2020-08-20 16:32:50 +0000
137@@ -505,7 +505,7 @@
138 pathlist = [path]
139
140 if not module and desc[2] == imp.PKG_DIRECTORY:
141- module = ['__init__']
142+ module = ['__init__']
143
144 if path and path.endswith('.pyc'):
145 path = path[:-1]
146
147=== modified file 'apport/sandboxutils.py'
148--- apport/sandboxutils.py 2020-04-13 21:19:56 +0000
149+++ apport/sandboxutils.py 2020-08-20 16:32:50 +0000
150@@ -23,13 +23,13 @@
151 pkgs = {}
152
153 # first, grab the versions that we captured at crash time
154- for l in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():
155- if not l.strip():
156+ for line in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():
157+ if not line.strip():
158 continue
159 try:
160- (pkg, version) = l.split()[:2]
161+ (pkg, version) = line.split()[:2]
162 except ValueError:
163- apport.warning('invalid Package/Dependencies line: %s', l)
164+ apport.warning('invalid Package/Dependencies line: %s', line)
165 # invalid line, ignore
166 continue
167 pkgs[pkg] = version
168@@ -41,13 +41,13 @@
169 '''Return package -> version dictionary from report'''
170
171 pkg_vers = {}
172- for l in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():
173- if not l.strip():
174+ for line in (report.get('Package', '') + '\n' + report.get('Dependencies', '')).splitlines():
175+ if not line.strip():
176 continue
177 try:
178- (pkg, version) = l.split()[:2]
179+ (pkg, version) = line.split()[:2]
180 except ValueError:
181- apport.warning('invalid Package/Dependencies line: %s', l)
182+ apport.warning('invalid Package/Dependencies line: %s', line)
183 # invalid line, ignore
184 continue
185 pkg_vers[pkg] = version
186@@ -74,10 +74,10 @@
187 pkgs = set()
188 libs = set()
189 if 'ProcMaps' in report:
190- for l in report['ProcMaps'].splitlines():
191- if not l.strip():
192+ for line in report['ProcMaps'].splitlines():
193+ if not line.strip():
194 continue
195- cols = l.split()
196+ cols = line.split()
197 if len(cols) in (6, 7) and 'x' in cols[1] and '.so' in cols[5]:
198 lib = os.path.realpath(cols[5])
199 libs.add(lib)
200@@ -88,16 +88,18 @@
201 os.makedirs(pkgmap_cache_dir)
202
203 # grab as much as we can
204- for l in libs:
205- pkg = apport.packaging.get_file_package(l, True, pkgmap_cache_dir,
206+ for line in libs:
207+ pkg = apport.packaging.get_file_package(line, True, pkgmap_cache_dir,
208 release=report['DistroRelease'],
209 arch=report.get('Architecture'))
210 if pkg:
211 if verbose:
212- apport.log('dynamically loaded %s needs package %s, queueing' % (l, pkg))
213+ apport.log('dynamically loaded %s needs package %s, queueing'
214+ % (line, pkg))
215 pkgs.add(pkg)
216 else:
217- apport.warning('%s is needed, but cannot be mapped to a package', l)
218+ apport.warning('%s is needed, but cannot be mapped to a package',
219+ line)
220
221 return [(p, pkg_versions.get(p)) for p in pkgs]
222
223@@ -235,8 +237,12 @@
224 report['ExecutablePath'] = '/bin/systemctl'
225 pkg = 'systemd'
226 if pkg:
227- apport.log('Installing extra package %s to get %s' % (pkg, path), log_timestamps)
228- pkgs.append((pkg, pkg_versions.get(pkg)))
229+ version = pkg_versions.get(pkg)
230+ pkg_version = "{}={}".format(pkg, version) if version else pkg
231+ apport.log(
232+ "Installing extra package %s to get %s" % (pkg_version, path), log_timestamps
233+ )
234+ pkgs.append((pkg, version))
235 else:
236 apport.fatal('Cannot find package which ships %s %s', path, report[path])
237
238
239=== modified file 'apport/ui.py'
240--- apport/ui.py 2019-07-22 19:11:45 +0000
241+++ apport/ui.py 2020-08-20 16:32:50 +0000
242@@ -711,23 +711,23 @@
243 self.ui_error_message(_('Invalid problem report'), excstr(e))
244 return True
245 elif self.options.window:
246- self.ui_info_message('', _('After closing this message '
247- 'please click on an application window to report a problem about it.'))
248- xprop = subprocess.Popen(['xprop', '_NET_WM_PID'],
249- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
250- (out, err) = xprop.communicate()
251- if xprop.returncode == 0:
252- try:
253- self.options.pid = int(out.split()[-1])
254- except ValueError:
255- self.ui_error_message(_('Cannot create report'),
256- _('xprop failed to determine process ID of the window'))
257- return True
258- return self.run_report_bug()
259- else:
260+ self.ui_info_message('', _('After closing this message '
261+ 'please click on an application window to report a problem about it.'))
262+ xprop = subprocess.Popen(['xprop', '_NET_WM_PID'],
263+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
264+ (out, err) = xprop.communicate()
265+ if xprop.returncode == 0:
266+ try:
267+ self.options.pid = int(out.split()[-1])
268+ except ValueError:
269 self.ui_error_message(_('Cannot create report'),
270- _('xprop failed to determine process ID of the window') + '\n\n' + err)
271+ _('xprop failed to determine process ID of the window'))
272 return True
273+ return self.run_report_bug()
274+ else:
275+ self.ui_error_message(_('Cannot create report'),
276+ _('xprop failed to determine process ID of the window') + '\n\n' + err)
277+ return True
278 else:
279 return self.run_crashes()
280
281
282=== modified file 'backends/packaging-apt-dpkg.py'
283--- backends/packaging-apt-dpkg.py 2020-04-16 00:25:44 +0000
284+++ backends/packaging-apt-dpkg.py 2020-08-20 16:32:50 +0000
285@@ -1213,9 +1213,9 @@
286 return []
287
288 mismatches = []
289- for l in out.splitlines():
290- if l.endswith('FAILED'):
291- mismatches.append(l.rsplit(':', 1)[0])
292+ for line in out.splitlines():
293+ if line.endswith('FAILED'):
294+ mismatches.append(line.rsplit(':', 1)[0])
295
296 return mismatches
297
298@@ -1224,8 +1224,8 @@
299 '''Heuristically determine primary mirror from an apt sources.list'''
300
301 with open(apt_sources) as f:
302- for l in f:
303- fields = l.split()
304+ for line in f:
305+ fields = line.split()
306 if len(fields) >= 3 and fields[0] == 'deb':
307 if fields[1].startswith('['):
308 # options given, mirror is in third field
309
310=== modified file 'data/package_hook'
311--- data/package_hook 2016-12-10 11:28:27 +0000
312+++ data/package_hook 2020-08-20 16:32:50 +0000
313@@ -52,12 +52,12 @@
314 tags = options.tags.replace(',', '')
315 pr['Tags'] = tags
316
317-for l in (options.logs or []):
318- if os.path.isfile(l):
319- pr[mkattrname(l)] = (l,)
320- elif os.path.isdir(l):
321- for f in os.listdir(l):
322- path = os.path.join(l, f)
323+for line in (options.logs or []):
324+ if os.path.isfile(line):
325+ pr[mkattrname(line)] = (line,)
326+ elif os.path.isdir(line):
327+ for f in os.listdir(line):
328+ path = os.path.join(line, f)
329 if os.path.isfile(path):
330 pr[mkattrname(path)] = (path,)
331
332
333=== modified file 'setup.py'
334--- setup.py 2019-03-29 20:55:44 +0000
335+++ setup.py 2020-08-20 16:32:50 +0000
336@@ -75,8 +75,8 @@
337 distutils.log.info('Updating hashbang of %s', f)
338 lines[0] = new_hashbang
339 with open(f, 'w') as fd:
340- for l in lines:
341- fd.write(l)
342+ for line in lines:
343+ fd.write(line)
344
345
346 #
347
348=== modified file 'test/test_apport_valgrind.py'
349--- test/test_apport_valgrind.py 2019-05-16 18:48:29 +0000
350+++ test/test_apport_valgrind.py 2020-08-20 16:32:50 +0000
351@@ -94,7 +94,7 @@
352 }'''
353
354 with open('memleak.c', 'w') as fd:
355- fd.write(code)
356+ fd.write(code)
357 cmd = ['gcc', '-Wall', '-Werror', '-g', 'memleak.c', '-o', 'memleak']
358 self.assertEqual(
359 subprocess.call(cmd), 0, 'compiling memleak.c failed.')
360
361=== modified file 'test/test_fileutils.py'
362--- test/test_fileutils.py 2016-12-10 11:28:27 +0000
363+++ test/test_fileutils.py 2020-08-20 16:32:50 +0000
364@@ -377,9 +377,9 @@
365 self.assertTrue('libc.so.6' in libs, libs)
366 self.assertTrue('libc.so.6' in libs['libc.so.6'], libs['libc.so.6'])
367 self.assertTrue(os.path.exists(libs['libc.so.6']))
368- for l in libs:
369- self.assertFalse('vdso' in l, libs)
370- self.assertTrue(os.path.exists(libs[l]))
371+ for line in libs:
372+ self.assertFalse('vdso' in line, libs)
373+ self.assertTrue(os.path.exists(libs[line]))
374
375 self.assertEqual(apport.fileutils.shared_libraries('/non/existing'), {})
376 self.assertEqual(apport.fileutils.shared_libraries('/etc'), {})
377
378=== modified file 'test/test_signal_crashes.py'
379--- test/test_signal_crashes.py 2018-03-23 20:23:02 +0000
380+++ test/test_signal_crashes.py 2020-08-20 16:32:50 +0000
381@@ -138,8 +138,8 @@
382 'LC_TELEPHONE', 'LC_MEASUREMENT', 'LC_IDENTIFICATION',
383 'LOCPATH', 'TERM', 'XDG_RUNTIME_DIR', 'LD_PRELOAD']
384
385- for l in pr['ProcEnviron'].splitlines():
386- (k, v) = l.split('=', 1)
387+ for line in pr['ProcEnviron'].splitlines():
388+ (k, v) = line.split('=', 1)
389 self.assertTrue(k in allowed_vars,
390 'report contains sensitive environment variable %s' % k)
391
392
393=== modified file 'test/test_ui.py'
394--- test/test_ui.py 2019-05-16 18:48:29 +0000
395+++ test/test_ui.py 2020-08-20 16:32:50 +0000
396@@ -1770,7 +1770,7 @@
397 def _run_hook(self, code):
398 f = open(os.path.join(self.hookdir, 'coreutils.py'), 'w')
399 f.write('def add_info(report, ui):\n%s\n' %
400- '\n'.join([' ' + l for l in code.splitlines()]))
401+ '\n'.join([' ' + line for line in code.splitlines()]))
402 f.close()
403 self.ui.options.package = 'coreutils'
404 self.ui.run_report_bug()

Subscribers

People subscribed via source and target branches