Merge lp:~smoser/maas-images/trunk.flake8 into lp:maas-images

Proposed by Scott Moser
Status: Merged
Merged at revision: 401
Proposed branch: lp:~smoser/maas-images/trunk.flake8
Merge into: lp:maas-images
Diff against target: 79 lines (+13/-8)
3 files modified
meph2/commands/dpkg.py (+2/-2)
meph2/commands/meph2_util.py (+1/-1)
meph2/util.py (+10/-5)
To merge this branch: bzr merge lp:~smoser/maas-images/trunk.flake8
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+348489@code.launchpad.net

Commit message

flake8: fix flake8 errors.

current versions of flake8 as seen in 'tox -e flake8' are complaining
about bare except and a line-too-long. This fixes all those
complaints.

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :

LGTM! Thanks for fixing the errors.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'meph2/commands/dpkg.py'
2--- meph2/commands/dpkg.py 2018-05-04 17:10:58 +0000
3+++ meph2/commands/dpkg.py 2018-06-25 19:16:11 +0000
4@@ -125,8 +125,8 @@
5 if package is None or dpkg_a_newer_than_b(
6 packages[pkg_name]['Version'], package['Version']):
7 package = packages[pkg_name]
8- sys.stderr.write(
9- 'Found %s-%s in %s\n' % (pkg_name, package['Version'], dist))
10+ sys.stderr.write('Found %s-%s in %s\n' %
11+ (pkg_name, package['Version'], dist))
12 # Download it if it was found and a dest was set
13 if package is not None and dest is not None:
14 pkg_data = geturl('%s/%s' % (archive, package['Filename']))
15
16=== modified file 'meph2/commands/meph2_util.py'
17--- meph2/commands/meph2_util.py 2017-02-11 01:29:31 +0000
18+++ meph2/commands/meph2_util.py 2018-06-25 19:16:11 +0000
19@@ -390,7 +390,7 @@
20 reaped.add(orphan)
21 try:
22 os.removedirs(os.path.dirname(location))
23- except:
24+ except OSError:
25 pass
26
27 if not args.dry_run:
28
29=== modified file 'meph2/util.py'
30--- meph2/util.py 2016-10-07 02:51:20 +0000
31+++ meph2/util.py 2018-06-25 19:16:11 +0000
32@@ -29,6 +29,11 @@
33 import sys
34 import tempfile
35
36+try:
37+ JSONDecodeError = json.decoder.JSONDecodeError
38+except AttributeError:
39+ JSONDecodeError = ValueError
40+
41 # for callers convenience
42 timestamp = sutil.timestamp
43
44@@ -159,7 +164,7 @@
45 with open(filename) as orphan_file:
46 known_orphans = json.load(orphan_file)
47 return known_orphans
48- except:
49+ except JSONDecodeError:
50 raise Exception(
51 '%s exists but is not a valid orphan file' % filename
52 )
53@@ -181,8 +186,8 @@
54 with open(filename, 'w') as orphan_file:
55 json.dump(orphans, orphan_file, indent=1)
56 orphan_file.write("\n")
57- except:
58- raise Exception('Cannot write orphan file %s' % filename)
59+ except Exception as exc:
60+ raise Exception('Cannot write orphan file %s: %s' % (filename, exc))
61
62
63 def empty_iid_products(content_id):
64@@ -232,14 +237,14 @@
65 if summer.check():
66 try:
67 os.rename(tf.name, path)
68- except:
69+ except OSError:
70 os.unlink(tf.name)
71 raise
72 else:
73 found = summer.hexdigest()
74 try:
75 size = os.path.getsize(tf.name)
76- except:
77+ except OSError:
78 size = "unavailable"
79 os.unlink(tf.name)
80

Subscribers

People subscribed via source and target branches