Merge lp:~cjohnston/ubuntu-ci-services-itself/fix-flake8-issues into lp:ubuntu-ci-services-itself
- fix-flake8-issues
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Chris Johnston |
Approved revision: | 235 |
Merged at revision: | 236 |
Proposed branch: | lp:~cjohnston/ubuntu-ci-services-itself/fix-flake8-issues |
Merge into: | lp:ubuntu-ci-services-itself |
Diff against target: |
351 lines (+35/-49) 15 files modified
branch-source-builder/run_worker (+1/-0) branch-source-builder/upload_package.py (+3/-4) branch-source-builder/watch_ppa.py (+1/-1) charms/precise/webui/hooks/hooks.py (+0/-1) ci-utils/ci_utils/nova_client/__init__.py (+14/-22) ci-utils/ci_utils/tests/test_jenkins.py (+0/-2) ci-utils/ci_utils/tests/test_tmpdir.py (+1/-1) juju-deployer/test_update.py (+2/-2) juju-deployer/update.py (+3/-3) lander/bin/lander_archiver.py (+0/-1) ppa-assigner/ppa_assigner/management/commands/integration_test.py (+4/-3) run-tests (+2/-2) test_runner/tstrun/testbed.py (+0/-2) test_runner/tstrun/tests/test_data_store.py (+0/-1) tests/data_store/test.py (+4/-4) |
To merge this branch: | bzr merge lp:~cjohnston/ubuntu-ci-services-itself/fix-flake8-issues |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email:
|
Commit message
Fix misc flake8 issues around the project
Description of the change
We should adhere to pep8
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:235
http://
Executed test runs:
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ursula Junque (ursinha) wrote : | # |
The changes look good (can't disagree with flake8 cleanup :)). I see that all cupstream2distro reused code needs pep8 love, so might be too much for this branch, but I found three worth fixing in this branch:
branch-
ci-utils/
cli/tests/
Other than that that's great.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Vincent Ladeuil (vila) wrote : | # |
> We should adhere to pep8
+1
Yet, it's not good if it's not automatic. It's on my TODO list as part of our test story but not at the top yet (ucitests provides a base class that can be used for that but does not work (yet) on precise).
...
Now that I think about it, I should just skip that on precise, I don't think there are a lot of us developing on precise ... will make a MP later.
...
In fact, I already did almost all that is needed in ucitests-0.0.8, so less work than I think.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Chris Johnston (cjohnston) wrote : | # |
On Thu, Feb 13, 2014 at 11:00 AM, Ursula Junque <email address hidden> wrote:
> The changes look good (can't disagree with flake8 cleanup :)). I see that
> all cupstream2distro reused code needs pep8 love, so might be too much for
> this branch, but I found three worth fixing in this branch:
>
Since cupstream2distro was a direct copy and paste, I disagree with making
changes to it. If we want to fix them, I think they should be fixed
upstream first and then brought to us, otherwise making changes across both
will become more difficult. I also didn't even look at any of the charms
other than webui for that same reason.
>
> branch-
> ci-utils/
> is assigned to but never used
> cli/tests/
>
>
cli was fixed in a previous MP. UPLOAD_LIST and id I was going to talk to
the developers about. UPLOAD_LIST looks like there is part of a story
missing.
> Other than that that's great.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ursula Junque (ursinha) wrote : | # |
> On Thu, Feb 13, 2014 at 11:00 AM, Ursula Junque <email address hidden> wrote:
>
> > The changes look good (can't disagree with flake8 cleanup :)). I see that
> > all cupstream2distro reused code needs pep8 love, so might be too much for
> > this branch, but I found three worth fixing in this branch:
> >
>
> Since cupstream2distro was a direct copy and paste, I disagree with making
> changes to it. If we want to fix them, I think they should be fixed
> upstream first and then brought to us, otherwise making changes across both
> will become more difficult. I also didn't even look at any of the charms
> other than webui for that same reason.
I'm not sure they're only copy&paste, from fginther's MP it seems the code was copied and adapted, so it's unclear we're bringing upstream changes to our code. But that's a separate thing, I think, as it needs further discussion.
>
>
> >
> > branch-
> > ci-utils/
> > is assigned to but never used
> > cli/tests/
> >
> >
> cli was fixed in a previous MP. UPLOAD_LIST and id I was going to talk to
> the developers about. UPLOAD_LIST looks like there is part of a story
> missing.
>
>
> > Other than that that's great.
Preview Diff
1 | === modified file 'branch-source-builder/run_worker' |
2 | --- branch-source-builder/run_worker 2014-02-11 20:57:36 +0000 |
3 | +++ branch-source-builder/run_worker 2014-02-12 21:16:08 +0000 |
4 | @@ -32,6 +32,7 @@ |
5 | from ci_utils import amqp_utils |
6 | TIME_BETWEEN_CHECKS = 60 |
7 | |
8 | + |
9 | def on_message(msg): |
10 | log.info('on_message: {}'.format(msg.body)) |
11 | params = json.loads(msg.body) |
12 | |
13 | === modified file 'branch-source-builder/upload_package.py' |
14 | --- branch-source-builder/upload_package.py 2014-02-07 17:32:37 +0000 |
15 | +++ branch-source-builder/upload_package.py 2014-02-12 21:16:08 +0000 |
16 | @@ -17,7 +17,6 @@ |
17 | import argparse |
18 | import atexit |
19 | from dput.changes import parse_changes_file |
20 | -import json |
21 | import logging |
22 | import os |
23 | import re |
24 | @@ -43,9 +42,9 @@ |
25 | |
26 | |
27 | def cleanup(directory): |
28 | - if os.path.exists(directory) and os.path.isdir(directory): |
29 | - logging.info('Removing temp directory: {}'.format(directory)) |
30 | - shutil.rmtree(directory) |
31 | + if os.path.exists(directory) and os.path.isdir(directory): |
32 | + logging.info('Removing temp directory: {}'.format(directory)) |
33 | + shutil.rmtree(directory) |
34 | |
35 | |
36 | def create_temp_dir(): |
37 | |
38 | === modified file 'branch-source-builder/watch_ppa.py' |
39 | --- branch-source-builder/watch_ppa.py 2014-02-07 17:32:37 +0000 |
40 | +++ branch-source-builder/watch_ppa.py 2014-02-12 21:16:08 +0000 |
41 | @@ -80,7 +80,7 @@ |
42 | # Get archs available and archs to ignore |
43 | (available_archs_in_ppa, |
44 | arch_all_arch) = launchpadmanager.get_available_and_all_archs( |
45 | - lp_series, monitored_ppa) |
46 | + lp_series, monitored_ppa) |
47 | (archs_to_eventually_ignore, |
48 | archs_to_unconditionally_ignore) = launchpadmanager.get_ignored_archs() |
49 | logging.info('Arches available in ppa: {}'.format(available_archs_in_ppa)) |
50 | |
51 | === modified file 'charms/precise/webui/hooks/hooks.py' |
52 | --- charms/precise/webui/hooks/hooks.py 2014-01-27 21:44:48 +0000 |
53 | +++ charms/precise/webui/hooks/hooks.py 2014-02-12 21:16:08 +0000 |
54 | @@ -2,7 +2,6 @@ |
55 | |
56 | import distutils.dir_util |
57 | import grp |
58 | -import json |
59 | import os |
60 | import pwd |
61 | import re |
62 | |
63 | === modified file 'ci-utils/ci_utils/nova_client/__init__.py' |
64 | --- ci-utils/ci_utils/nova_client/__init__.py 2014-01-29 23:01:46 +0000 |
65 | +++ ci-utils/ci_utils/nova_client/__init__.py 2014-02-12 21:16:08 +0000 |
66 | @@ -38,19 +38,18 @@ |
67 | self.nova = novaclient.Client(**creds) |
68 | image = self.nova.images.find(name=imagename) |
69 | inst_flavor = self.nova.flavors.find(name=flavor) |
70 | - SSH_KEYNAME=os.path.expanduser('~/.ssh/id_rsa') |
71 | + SSH_KEYNAME = os.path.expanduser('~/.ssh/id_rsa') |
72 | if not os.path.exists(SSH_KEYNAME): |
73 | subprocess.call( |
74 | - ['ssh-keygen','-t','rsa','-f',SSH_KEYNAME,'-N','']) |
75 | + ['ssh-keygen', '-t', 'rsa', '-f', SSH_KEYNAME, '-N', '']) |
76 | if not self.nova.keypairs.findall(name="sshkey"): |
77 | with open(SSH_KEYNAME+'.pub') as sshkey: |
78 | - self.key=self.nova.keypairs.create( |
79 | + self.key = self.nova.keypairs.create( |
80 | name="sshkey", public_key=sshkey.read()) |
81 | - self.instance=self.nova.servers.create( |
82 | + self.instance = self.nova.servers.create( |
83 | name="test", image=image, flavor=inst_flavor, key_name="sshkey") |
84 | self.ip = self._get_ip() |
85 | |
86 | - |
87 | def _wait_for_instance(self): |
88 | status = self.instance.status |
89 | #Try for up to 5 minutes to create the instance |
90 | @@ -63,19 +62,17 @@ |
91 | if status == 'BUILD': |
92 | raise NovaClientException("Instance creation timed out") |
93 | |
94 | - |
95 | def _refresh_instance(self): |
96 | - id=self.instance.id |
97 | + id = self.instance.id |
98 | try: |
99 | #You have to re-get the instance for it to update |
100 | self.instance = self.nova.servers.get(id) |
101 | except ConnectionError: |
102 | log.warn("Received connection error, retrying") |
103 | |
104 | - |
105 | def _get_ip(self): |
106 | timeout = time.time()+300 |
107 | - id=self.instance.id |
108 | + id = self.instance.id |
109 | ip = None |
110 | while not ip and time.time() < timeout: |
111 | try: |
112 | @@ -83,7 +80,7 @@ |
113 | self._refresh_instance() |
114 | #The value first instance in networks should contain the |
115 | #value we need |
116 | - ip=self.instance.networks.values()[0][0] |
117 | + ip = self.instance.networks.values()[0][0] |
118 | except IndexError: |
119 | log.info("Waiting for IP to become available") |
120 | time.sleep(5) |
121 | @@ -92,36 +89,31 @@ |
122 | log.info("IP is %s" % ip) |
123 | return ip |
124 | |
125 | - |
126 | def runcmd(self, cmd): |
127 | - sshopts = ['-o','UserKnownHostsFile=/dev/null','-o ', |
128 | + sshopts = ['-o', 'UserKnownHostsFile=/dev/null', '-o ', |
129 | 'StrictHostKeyChecking=no'] |
130 | cmd = ['ssh'] + ['ubuntu@'+self.ip] + sshopts + cmd.split(' ') |
131 | return subprocess.check_output(cmd) |
132 | |
133 | - |
134 | def scp(self, src, dest, recurse=False): |
135 | - sshopts = ['-o','UserKnownHostsFile=/dev/null','-o ', |
136 | + sshopts = ['-o', 'UserKnownHostsFile=/dev/null', '-o ', |
137 | 'StrictHostKeyChecking=no'] |
138 | if recurse: |
139 | sshopts.append['-r'] |
140 | - cmd = ['scp'] + ['ubuntu@'+self.ip] + sshopts + [src, dest] |
141 | - |
142 | + ['scp'] + ['ubuntu@'+self.ip] + sshopts + [src, dest] |
143 | |
144 | def delete(self): |
145 | self.instance.delete() |
146 | |
147 | - |
148 | def _get_nova_creds(self, config): |
149 | try: |
150 | creds = {'auth_url': config['auth_url'], |
151 | - 'username': config['auth_user'], |
152 | - 'api_key': config['auth_password'], |
153 | - 'project_id': config['auth_tenant_name'], |
154 | - 'region_name': config['auth_region']} |
155 | + 'username': config['auth_user'], |
156 | + 'api_key': config['auth_password'], |
157 | + 'project_id': config['auth_tenant_name'], |
158 | + 'region_name': config['auth_region']} |
159 | except KeyError: |
160 | raise self.NovaClientException( |
161 | "Missing or invalid authentication info." |
162 | ) |
163 | return creds |
164 | - |
165 | |
166 | === modified file 'ci-utils/ci_utils/tests/test_jenkins.py' |
167 | --- ci-utils/ci_utils/tests/test_jenkins.py 2014-02-07 22:09:36 +0000 |
168 | +++ ci-utils/ci_utils/tests/test_jenkins.py 2014-02-12 21:16:08 +0000 |
169 | @@ -15,8 +15,6 @@ |
170 | |
171 | import json |
172 | import mock |
173 | -import os |
174 | -import sys |
175 | import unittest |
176 | |
177 | from ci_utils import jenkins_utils |
178 | |
179 | === modified file 'ci-utils/ci_utils/tests/test_tmpdir.py' |
180 | --- ci-utils/ci_utils/tests/test_tmpdir.py 2014-01-10 16:47:39 +0000 |
181 | +++ ci-utils/ci_utils/tests/test_tmpdir.py 2014-02-12 21:16:08 +0000 |
182 | @@ -22,6 +22,6 @@ |
183 | class TestTmpDir(unittest.TestCase): |
184 | def test_tmpdir(self): |
185 | with TmpDir() as tmpdir: |
186 | - dir_created=tmpdir |
187 | + dir_created = tmpdir |
188 | self.assertTrue(os.path.exists(dir_created)) |
189 | self.assertFalse(os.path.exists(dir_created)) |
190 | |
191 | === modified file 'juju-deployer/test_update.py' |
192 | --- juju-deployer/test_update.py 2014-02-04 15:58:00 +0000 |
193 | +++ juju-deployer/test_update.py 2014-02-12 21:16:08 +0000 |
194 | @@ -132,7 +132,7 @@ |
195 | def test_get_branches_and_revnos(self): |
196 | branch_url = self.get_branch_url() |
197 | current = self.branch.revno() |
198 | - y = self.get_service_yaml(current -1) |
199 | + y = self.get_service_yaml(current - 1) |
200 | path = os.path.join(self.temp_dir, 'foo.yaml') |
201 | with open(path, 'w') as fp: |
202 | fp.write(yaml.safe_dump(y)) |
203 | @@ -141,7 +141,7 @@ |
204 | actual = update.get_branches_and_revnos( |
205 | [path], True) |
206 | msg = '{} is out of date (currently {}, latest {})' |
207 | - msg = msg.format(branch_url, current -1, current) |
208 | + msg = msg.format(branch_url, current - 1, current) |
209 | warn.assert_called_with(msg) |
210 | self.assertEqual(actual, {branch_url: current}) |
211 | |
212 | |
213 | === modified file 'juju-deployer/update.py' |
214 | --- juju-deployer/update.py 2014-02-04 15:58:00 +0000 |
215 | +++ juju-deployer/update.py 2014-02-12 21:16:08 +0000 |
216 | @@ -43,7 +43,6 @@ |
217 | plugin.load_plugins() |
218 | |
219 | |
220 | - |
221 | class UpdateArgParser(argparse.ArgumentParser): |
222 | """A parser for the uci-run-tests script.""" |
223 | |
224 | @@ -140,7 +139,7 @@ |
225 | |
226 | def set_branches_and_revnos(paths, branches): |
227 | """Update the yaml files with the new revnos. |
228 | - |
229 | + |
230 | We cannot use pyyaml for this, as it doesn't preserve order or preserve |
231 | comments. |
232 | """ |
233 | @@ -163,6 +162,7 @@ |
234 | with open(cfg, 'w') as fp: |
235 | fp.write(new_body) |
236 | |
237 | + |
238 | def main(args=None): |
239 | if args is None: |
240 | args = sys.argv[1:] |
241 | @@ -174,7 +174,7 @@ |
242 | paths = list(get_deployer_configs(deployer_dir)) |
243 | |
244 | if ns.assert_pinned: |
245 | - all_pinned = ensure_all_branches_are_pinned(paths) |
246 | + all_pinned = ensure_all_branches_are_pinned(paths) |
247 | return not bool(all_pinned) |
248 | else: |
249 | branches = get_branches_and_revnos(paths, ns.check) |
250 | |
251 | === modified file 'lander/bin/lander_archiver.py' |
252 | --- lander/bin/lander_archiver.py 2014-02-06 18:50:05 +0000 |
253 | +++ lander/bin/lander_archiver.py 2014-02-12 21:16:08 +0000 |
254 | @@ -18,7 +18,6 @@ |
255 | import logging |
256 | import os |
257 | import sys |
258 | -import urllib2 |
259 | import yaml |
260 | |
261 | sys.path.append(os.path.join(os.path.dirname(__file__), '../../ci-utils')) |
262 | |
263 | === modified file 'ppa-assigner/ppa_assigner/management/commands/integration_test.py' |
264 | --- ppa-assigner/ppa_assigner/management/commands/integration_test.py 2013-12-23 19:46:06 +0000 |
265 | +++ ppa-assigner/ppa_assigner/management/commands/integration_test.py 2014-02-12 21:16:08 +0000 |
266 | @@ -41,9 +41,10 @@ |
267 | default=%(default)s'''), |
268 | make_option('--pocket', dest='pocket', default='Release', |
269 | help='Pocket to copy package in. default=%(default)s'), |
270 | - make_option('--archive', dest='archive', |
271 | - default='https://api.launchpad.net/1.0/ubuntu/+archive/primary', |
272 | - help='Archive for source package. defafult=%(default)s'), |
273 | + make_option( |
274 | + '--archive', dest='archive', |
275 | + default='https://api.launchpad.net/1.0/ubuntu/+archive/primary', |
276 | + help='Archive for source package. defafult=%(default)s'), |
277 | ) |
278 | |
279 | def handle(self, *args, **options): |
280 | |
281 | === modified file 'run-tests' |
282 | --- run-tests 2014-02-04 14:50:46 +0000 |
283 | +++ run-tests 2014-02-12 21:16:08 +0000 |
284 | @@ -87,8 +87,8 @@ |
285 | 'branch-source-builder', |
286 | 'image-builder', |
287 | 'lander', |
288 | -# 'ppa-assigner', |
289 | -# 'ticket_system', |
290 | + # 'ppa-assigner', |
291 | + # 'ticket_system', |
292 | 'test_runner', |
293 | ] |
294 | loader = loaders.Loader() |
295 | |
296 | === modified file 'test_runner/tstrun/testbed.py' |
297 | --- test_runner/tstrun/testbed.py 2014-02-06 11:23:26 +0000 |
298 | +++ test_runner/tstrun/testbed.py 2014-02-12 21:16:08 +0000 |
299 | @@ -294,8 +294,6 @@ |
300 | # 'auth_testbed_sshkey' can be defined there if you don't use ~/.ssh/id_rsa. |
301 | |
302 | def test_print_ip(): |
303 | - precise_image = ('ubuntu-released/ubuntu-precise-12.04' |
304 | - '-amd64-server-20131205-disk1.img') |
305 | saucy_image = ('ubuntu-released/ubuntu-saucy-13.10' |
306 | '-amd64-server-20140129-disk1.img') |
307 | test_bed = TestBed('vila1', 'm1.small', saucy_image, |
308 | |
309 | === modified file 'test_runner/tstrun/tests/test_data_store.py' |
310 | --- test_runner/tstrun/tests/test_data_store.py 2014-02-06 11:23:26 +0000 |
311 | +++ test_runner/tstrun/tests/test_data_store.py 2014-02-12 21:16:08 +0000 |
312 | @@ -14,7 +14,6 @@ |
313 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
314 | |
315 | import errno |
316 | -import os |
317 | import unittest |
318 | |
319 | |
320 | |
321 | === modified file 'tests/data_store/test.py' |
322 | --- tests/data_store/test.py 2014-02-10 19:11:11 +0000 |
323 | +++ tests/data_store/test.py 2014-02-12 21:16:08 +0000 |
324 | @@ -20,7 +20,8 @@ |
325 | import sys |
326 | import yaml |
327 | |
328 | -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'ci-utils')) |
329 | +sys.path.append(os.path.join( |
330 | + os.path.dirname(__file__), '..', '..', 'ci-utils')) |
331 | |
332 | from ci_utils import data_store |
333 | |
334 | @@ -106,15 +107,14 @@ |
335 | |
336 | del self.auth_config['auth_region'] |
337 | with self.assertRaises(data_store.DataStoreException): |
338 | - ds = data_store.DataStore("test2", auth_config=self.auth_config) |
339 | + data_store.DataStore("test2", auth_config=self.auth_config) |
340 | |
341 | def test_bad_region(self): |
342 | """ Test that passing an invalid region fails. """ |
343 | |
344 | self.auth_config['auth_region'] = 'bad_region' |
345 | with self.assertRaises(data_store.DataStoreException): |
346 | - ds = data_store.DataStore("test2", |
347 | - auth_config=self.auth_config) |
348 | + data_store.DataStore("test2", auth_config=self.auth_config) |
349 | |
350 | |
351 | if __name__ == "__main__": |
FAILED: Continuous integration, rev:235 s-jenkins. ubuntu- ci:8080/ job/uci- engine- ci/146/
http://
Executed test runs:
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/uci- engine- ci/146/ rebuild
http://