Merge lp:~chris.macnaughton/mojo/py3001 into lp:~ost-maintainers/mojo/py3

Proposed by Chris MacNaughton
Status: Merged
Merged at revision: 464
Proposed branch: lp:~chris.macnaughton/mojo/py3001
Merge into: lp:~ost-maintainers/mojo/py3
Diff against target: 543 lines (+66/-66)
19 files modified
contrib/test/utils.py (+1/-1)
mojo/cli.py (+3/-3)
mojo/contain.py (+1/-1)
mojo/info.py (+2/-2)
mojo/juju/__init__.py (+5/-5)
mojo/juju/check.py (+3/-3)
mojo/juju/parse_status.py (+4/-4)
mojo/juju/status.py (+11/-11)
mojo/phase.py (+10/-10)
mojo/project.py (+15/-15)
mojo/project_destroy.py (+1/-1)
mojo/project_new.py (+1/-1)
mojo/tests/test_debuglogs.py (+1/-1)
mojo/tests/test_juju2.py (+1/-1)
mojo/tests/test_mojo.py (+2/-2)
mojo/tests/utils.py (+1/-1)
mojo/volattach.py (+2/-2)
mojo/workspace.py (+1/-1)
tox.ini (+1/-1)
To merge this branch: bzr merge lp:~chris.macnaughton/mojo/py3001
Reviewer Review Type Date Requested Status
Ryan Beisner Approve
Review via email: mp+336288@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ryan Beisner (1chb1n) wrote :

There are a number of print(( changes which I think can just be print(. Happy to be proven incorrect, however.

review: Needs Fixing
lp:~chris.macnaughton/mojo/py3001 updated
466. By Chris MacNaughton

Remove print((

Revision history for this message
Ryan Beisner (1chb1n) wrote :

Ignoring existing lint issues at lp:mojo trunk, let's land this and continue to iterate/fix stuff. Thank you.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'contrib/test/utils.py'
2--- contrib/test/utils.py 2017-04-26 04:00:14 +0000
3+++ contrib/test/utils.py 2018-01-18 11:04:49 +0000
4@@ -44,6 +44,6 @@
5 """
6 try:
7 subprocess.check_output(['juju', 'switch'])
8- except subprocess.CalledProcessError, OSError:
9+ except subprocess.CalledProcessError as OSError:
10 print('Error checking active Juju controller')
11 sys.exit(1)
12
13=== modified file 'mojo/cli.py'
14--- mojo/cli.py 2017-11-08 14:58:22 +0000
15+++ mojo/cli.py 2018-01-18 11:04:49 +0000
16@@ -1,6 +1,6 @@
17 # Copyright 2014, 2015 Canonical Ltd. This software is licensed under the
18 # GNU General Public License version 3 (see the file LICENSE).
19-from __future__ import print_function
20+
21 import argparse
22 import errno
23 import logging
24@@ -256,7 +256,7 @@
25
26
27 def list_projects(args):
28- map(print, mojo.project.Project.list(args.mojo_root, only_names=args.names))
29+ list(map(print, mojo.project.Project.list(args.mojo_root, only_names=args.names)))
30
31
32 @warn_if_root
33@@ -312,7 +312,7 @@
34
35 def list_workspaces(args):
36 project = mojo.project.Project(get_project_name(args), args.series, args.mojo_root)
37- map(print, project.workspace_list())
38+ list(map(print, project.workspace_list()))
39
40
41 def new_spec(args):
42
43=== modified file 'mojo/contain.py'
44--- mojo/contain.py 2017-12-14 10:13:12 +0000
45+++ mojo/contain.py 2018-01-18 11:04:49 +0000
46@@ -173,7 +173,7 @@
47 self.timeout = 60
48
49 def _check_mount(self):
50- if self.device_name in self.container.devices.keys():
51+ if self.device_name in list(self.container.devices.keys()):
52 return True
53 return False
54
55
56=== modified file 'mojo/info.py'
57--- mojo/info.py 2016-05-25 11:59:42 +0000
58+++ mojo/info.py 2018-01-18 11:04:49 +0000
59@@ -1,6 +1,6 @@
60 # Copyright 2014 Canonical Ltd. This software is licensed under the
61 # GNU General Public License version 3 (see the file LICENSE).
62-from __future__ import print_function
63+
64 from mojo.cli import MojoArgumentParser
65 from mojo.juju.status import Status
66 import argparse
67@@ -59,7 +59,7 @@
68 prop))
69 else:
70 if isinstance(values, list):
71- map(print, values)
72+ list(map(print, values))
73 else:
74 print(values)
75 sys.exit(0)
76
77=== modified file 'mojo/juju/__init__.py'
78--- mojo/juju/__init__.py 2016-10-05 16:58:34 +0000
79+++ mojo/juju/__init__.py 2018-01-18 11:04:49 +0000
80@@ -1,10 +1,10 @@
81 import subprocess
82
83-from debuglogs import DebugLogs
84-from status import JujuStatusError, version, major_version
85-from wait import JujuWaitException
86+from .debuglogs import DebugLogs
87+from .status import JujuStatusError, version, major_version
88+from .wait import JujuWaitException
89
90 if major_version == 1:
91- from status import Juju1Status as Status
92+ from .status import Juju1Status as Status
93 elif major_version == 2:
94- from status import Juju2Status as Status
95+ from .status import Juju2Status as Status
96
97=== modified file 'mojo/juju/check.py'
98--- mojo/juju/check.py 2016-10-25 06:49:00 +0000
99+++ mojo/juju/check.py 2018-01-18 11:04:49 +0000
100@@ -6,8 +6,8 @@
101 import inspect
102 import sys
103
104-import checks
105-from status import Juju2Status, JujuStatusError
106+from . import checks
107+from .status import Juju2Status, JujuStatusError
108
109
110 def main():
111@@ -25,7 +25,7 @@
112 if issubclass(clsmember, checks.JujuCheck):
113 available_checks[clsmember.cmd_name] = clsmember
114
115- for check in available_checks.values():
116+ for check in list(available_checks.values()):
117 sub = sp.add_parser(check.cmd_name, description=check.help)
118 check.setup_argparse(sub)
119
120
121=== modified file 'mojo/juju/parse_status.py'
122--- mojo/juju/parse_status.py 2017-12-07 15:09:39 +0000
123+++ mojo/juju/parse_status.py 2018-01-18 11:04:49 +0000
124@@ -4,7 +4,7 @@
125 import argparse
126 import sys
127
128-from status import Juju2Status
129+from .status import Juju2Status
130
131
132 class StatusInfo:
133@@ -39,11 +39,11 @@
134 def run(self, args):
135 ips = []
136 if 'all' in args.applications:
137- for machine in self.status.yaml_status()['machines'].values():
138+ for machine in list(self.status.yaml_status()['machines'].values()):
139 if 'dns-name' in machine:
140 ips.append(machine['dns-name'])
141 if 'containers' in machine:
142- for container in machine['containers'].values():
143+ for container in list(machine['containers'].values()):
144 if 'dns-name' in container:
145 ips.append(container['dns-name'])
146 else:
147@@ -71,7 +71,7 @@
148
149 # Setup all available StatusInfo classes as subparsers
150 available_info = {'get_ips': GetIPs}
151- for cmd in available_info.values():
152+ for cmd in list(available_info.values()):
153 sub = sp.add_parser(cmd.name, description=cmd.help)
154 cmd.setup_argparse(sub)
155
156
157=== modified file 'mojo/juju/status.py'
158--- mojo/juju/status.py 2017-11-21 09:59:26 +0000
159+++ mojo/juju/status.py 2018-01-18 11:04:49 +0000
160@@ -7,7 +7,7 @@
161
162 from collections import Counter
163
164-from wait import wait
165+from .wait import wait
166
167 try:
168 with open(os.devnull, 'w') as devnull:
169@@ -208,7 +208,7 @@
170 ['juju', 'status', '--format=tabular']))
171 raise JujuStatusError("Timed out checking Juju status for stable state")
172 stable_state = []
173- for juju_objtype, check_info in checks.iteritems():
174+ for juju_objtype, check_info in checks.items():
175 for check in check_info:
176 check_function = check['check_func']
177 states = check_function()
178@@ -229,7 +229,7 @@
179 break
180 time.sleep(5)
181 self._get_status(force_update=True)
182- for juju_objtype, check_info in checks.iteritems():
183+ for juju_objtype, check_info in checks.items():
184 for check in check_info:
185 check_function = check['check_func']
186 states = check_function()
187@@ -266,7 +266,7 @@
188 def _service_info(self, svc):
189 if svc == "ALL":
190 units = {}
191- for service in self.yaml_status()['services'].values():
192+ for service in list(self.yaml_status()['services'].values()):
193 for unit, data in service.get('units', {}).items():
194 units[unit] = data
195 elif svc not in self.yaml_status()['services']:
196@@ -304,20 +304,20 @@
197 def service_ips(self, service):
198 units = self._service_info(service)
199 if units:
200- return [u.get('public-address') for u in units.values()
201+ return [u.get('public-address') for u in list(units.values())
202 if u.get('public-address')]
203 return units
204
205 def service_units(self, service):
206 units = self._service_info(service)
207 if units:
208- return units.keys()
209+ return list(units.keys())
210 return units
211
212 def service_machine_numbers(self, service):
213 units = self._service_info(service)
214 if units:
215- return [u.get('machine') for u in units.values()
216+ return [u.get('machine') for u in list(units.values())
217 if u.get('machine')]
218 return units
219
220@@ -408,18 +408,18 @@
221 if units is None:
222 return []
223
224- return [u.get('public-address') for u in units.values() if u.get('public-address')]
225+ return [u.get('public-address') for u in list(units.values()) if u.get('public-address')]
226
227 def application_machine_numbers(self, application):
228 units = self._get_units(application)
229 if units is None:
230 return None
231
232- return [u.get('machine') for u in units.values() if u.get('machine')]
233+ return [u.get('machine') for u in list(units.values()) if u.get('machine')]
234
235 def applications_list(self, exclude_subordinates=True):
236 applications = []
237- for app in self.yaml_status()['applications'].keys():
238+ for app in list(self.yaml_status()['applications'].keys()):
239 if exclude_subordinates and 'subordinate-to' in self.yaml_status()['applications'][app]:
240 continue
241 applications.append(app)
242@@ -431,7 +431,7 @@
243 if units is None:
244 return None
245
246- return units.keys()
247+ return list(units.keys())
248
249 def applications_ready(self):
250 """ Check status of all applications, raise JujuStatusError for an error state.
251
252=== modified file 'mojo/phase.py'
253--- mojo/phase.py 2017-12-21 11:27:44 +0000
254+++ mojo/phase.py 2018-01-18 11:04:49 +0000
255@@ -1,10 +1,10 @@
256 # Copyright 2014 Canonical Ltd. This software is licensed under the
257 # GNU General Public License version 3 (see the file LICENSE).
258-import commands
259+import subprocess
260 import os
261 import logging
262 import subprocess
263-import charm_repo
264+from . import charm_repo
265 import re
266 import shutil
267 import tempfile
268@@ -476,7 +476,7 @@
269 if not modified:
270 return
271
272- for service, changes in modified.iteritems():
273+ for service, changes in modified.items():
274 deployer_config_items = changes.get('cfg-config')
275 if not deployer_config_items:
276 # Something differs, e.g. constraints, but not the config.
277@@ -485,7 +485,7 @@
278 juju_set_command = ['juju', mojo.juju.utils.get_juju_command('set'), service]
279 config_changes = []
280
281- for config_item, config_value in deployer_config_items.iteritems():
282+ for config_item, config_value in deployer_config_items.items():
283 # At some point, "juju set" started trimming newlines,
284 # which I endorse; but we may get a false positive here.
285 if identical_but_wrapped_in_newlines(
286@@ -616,7 +616,7 @@
287 # Take in MOJO_* variables from the environment
288 tmpl_vars = {}
289 env = os.environ.copy()
290- for key in env.iterkeys():
291+ for key in env.keys():
292 if 'MOJO_' in key:
293 tmpl_vars[key] = env[key]
294 # Process the deployment configs as a Jinja2 template
295@@ -948,7 +948,7 @@
296
297 _run = super(VerifyPhase, self).run
298
299- for i in xrange(1, retry + 1):
300+ for i in range(1, retry + 1):
301 if i > 1:
302 logging.info(
303 "Retrying (attempt {} of {})".format(
304@@ -1057,7 +1057,7 @@
305 '[ -f ${CHARMDIR}/codetree-collect-info.yaml ] && '
306 'cat ${CHARMDIR}/codetree-collect-info.yaml| sed -e "s/^/ /" || true; done')
307 cmd = ['juju', 'ssh', machine_id, "'{}'".format(audit_cmd), "2>/dev/null"]
308- status, output = commands.getstatusoutput(" ".join(cmd))
309+ status, output = subprocess.getstatusoutput(" ".join(cmd))
310 if status != 0:
311 raise CharmAuditPhaseException("Unknown error trying to run {}: {}".format(" ".join(cmd), output))
312 return output
313@@ -1065,7 +1065,7 @@
314 def parse_charm_audit_output(self, audit_output):
315 audit_info = yaml.safe_load(audit_output)
316 parsed_audit_output = {}
317- for unit in audit_info.keys():
318+ for unit in list(audit_info.keys()):
319 try:
320 collect_url = audit_info[unit]['collect_url']
321 except KeyError:
322@@ -1074,7 +1074,7 @@
323 application = audit_info[unit]['application']
324
325 try:
326- collect_urls = parsed_audit_output[application].keys()
327+ collect_urls = list(parsed_audit_output[application].keys())
328 except KeyError:
329 collect_urls = []
330 finally:
331@@ -1119,7 +1119,7 @@
332 "sed 's/.*/(set -x; & \&\& echo MOJO_NAGIOS_OK) || echo MOJO_NAGIOS_FAIL /'" \
333 "|sudo -u nagios -s bash".format(skip_check_command)
334 cmd = ['juju', 'ssh', unit, '"{}"'.format(check_cmd), "2>/dev/null"]
335- status, output = commands.getstatusoutput(" ".join(cmd))
336+ status, output = subprocess.getstatusoutput(" ".join(cmd))
337 error_output, ok_output = "", ""
338 if status != 0:
339 if 'No such file or directory' in output or 'sudo: unknown user: nagios' in output:
340
341=== modified file 'mojo/project.py'
342--- mojo/project.py 2017-06-18 23:54:07 +0000
343+++ mojo/project.py 2018-01-18 11:04:49 +0000
344@@ -206,7 +206,7 @@
345 "project".format(self.name, self.root))
346 else:
347 try:
348- mkdirs(self.root, self.owner, mode=0700)
349+ mkdirs(self.root, self.owner, mode=0o700)
350 except OSError as e:
351 raise ProjectCreationError(
352 "Could not create project root: {}".format(e.strerror))
353@@ -216,7 +216,7 @@
354 "using it.".format(self.name, self.project_series))
355 else:
356 try:
357- mkdirs(self.project_series, self.owner, mode=0700)
358+ mkdirs(self.project_series, self.owner, mode=0o700)
359 except OSError as e:
360 raise ProjectCreationError(
361 "Could not create project project_series: "
362@@ -246,7 +246,7 @@
363 logging.info("Checking {} project dir {} ..."
364 "".format(self.name, self.container_project_series))
365 if not os.path.exists(self.container_project_series):
366- mkdirs(self.container_project_series, self.owner, mode=0700)
367+ mkdirs(self.container_project_series, self.owner, mode=0o700)
368
369 sudoers_file = os.path.join(self.project_container_root, "etc", "sudoers.d",
370 "ubuntu-all")
371@@ -254,7 +254,7 @@
372 self.name, sudoers_file))
373 with open(sudoers_file, "w") as f:
374 f.write("ubuntu ALL=(ALL) NOPASSWD: ALL\n")
375- os.chmod(sudoers_file, 0400)
376+ os.chmod(sudoers_file, 0o400)
377
378 if not os.path.exists(os.path.join(self.project_series, '.project')):
379 self.write_project_info()
380@@ -294,19 +294,19 @@
381
382 # Validate the project exists
383 if self.name not in self.list(self.mojo_root, True):
384- print "Project, '{}', does not appear to exist.".format(self.name)
385- print "Please run 'mojo project-new --series {} {}' to " \
386- "create the project.".format(self.series, self.name)
387- print "Or check the file permissions on {}".format(self.root)
388+ print("Project, '{}', does not appear to exist.".format(self.name))
389+ print("Please run 'mojo project-new --series {} {}' to " \
390+ "create the project.".format(self.series, self.name))
391+ print("Or check the file permissions on {}".format(self.root))
392 sys.exit(1)
393 if not self.container.exists() or not self.container.is_setup():
394- print "The container project and series path for {} does not appear " \
395- "to exist at {}.".format(self.name, self.container_project_series)
396- print "Check to make sure the project and series exist and " \
397- "permissions are set properly."
398- print "Please run 'mojo project-new --series {} {}' to " \
399- "create the project if needed.".format(self.series, self.name)
400- print "Or check the file permissions on {}".format(self.container_project_series)
401+ print("The container project and series path for {} does not appear " \
402+ "to exist at {}.".format(self.name, self.container_project_series))
403+ print("Check to make sure the project and series exist and " \
404+ "permissions are set properly.")
405+ print("Please run 'mojo project-new --series {} {}' to " \
406+ "create the project if needed.".format(self.series, self.name))
407+ print("Or check the file permissions on {}".format(self.container_project_series))
408 sys.exit(1)
409
410 # If we're using nested directories for specs, make sure our workspace
411
412=== modified file 'mojo/project_destroy.py'
413--- mojo/project_destroy.py 2016-11-21 22:15:55 +0000
414+++ mojo/project_destroy.py 2018-01-18 11:04:49 +0000
415@@ -1,7 +1,7 @@
416 # Copyright 2015 Canonical Ltd. This software is licensed under the
417 # GNU General Public License version 3 (see the file LICENSE).
418 import os
419-import cli
420+from . import cli
421 from .utils import setup_logging
422
423
424
425=== modified file 'mojo/project_new.py'
426--- mojo/project_new.py 2016-11-25 17:27:11 +0000
427+++ mojo/project_new.py 2018-01-18 11:04:49 +0000
428@@ -1,7 +1,7 @@
429 # Copyright 2015 Canonical Ltd. This software is licensed under the
430 # GNU General Public License version 3 (see the file LICENSE).
431 import os
432-import cli
433+from . import cli
434 from .utils import setup_logging
435
436
437
438=== modified file 'mojo/tests/test_debuglogs.py'
439--- mojo/tests/test_debuglogs.py 2017-01-11 14:24:11 +0000
440+++ mojo/tests/test_debuglogs.py 2018-01-18 11:04:49 +0000
441@@ -19,7 +19,7 @@
442 @mock.patch('subprocess.check_output')
443 def test__resolve_remote_paths(self, _check_output):
444 """Test _resolve_remote_paths"""
445- _check_output.return_value = u"['/etc/init.d/apache2']"
446+ _check_output.return_value = "['/etc/init.d/apache2']"
447 ws = None
448 debug_logs = DebugLogs(ws, "production", None, None)
449 self.assertEqual(debug_logs._resolve_remote_paths('apache2/0', '/etc/init.d/apache2'),
450
451=== modified file 'mojo/tests/test_juju2.py'
452--- mojo/tests/test_juju2.py 2017-12-08 10:58:48 +0000
453+++ mojo/tests/test_juju2.py 2018-01-18 11:04:49 +0000
454@@ -2,7 +2,7 @@
455 # GNU General Public License version 3 (see the file LICENSE).
456 import mock
457 import os
458-from StringIO import StringIO
459+from io import StringIO
460 import sys
461 from unittest import TestCase
462
463
464=== modified file 'mojo/tests/test_mojo.py'
465--- mojo/tests/test_mojo.py 2017-05-11 01:27:01 +0000
466+++ mojo/tests/test_mojo.py 2018-01-18 11:04:49 +0000
467@@ -5,7 +5,7 @@
468 from tempfile import mkdtemp
469 from shutil import rmtree
470 import subprocess
471-import commands
472+import subprocess
473 import os
474 import sys
475 import time
476@@ -260,7 +260,7 @@
477 ]
478 for cmd in cmds:
479 bc_status, bc_output = mojo.utils.bicommand(cmd)
480- c_status, c_output = commands.getstatusoutput(cmd)
481+ c_status, c_output = subprocess.getstatusoutput(cmd)
482
483 # We don't care about return codes, we just want to confirm they're
484 # both returning zero or non-zero
485
486=== modified file 'mojo/tests/utils.py'
487--- mojo/tests/utils.py 2017-04-19 02:09:34 +0000
488+++ mojo/tests/utils.py 2018-01-18 11:04:49 +0000
489@@ -43,7 +43,7 @@
490 with open(os.path.join(directory, manifest_path), 'w+') as fp:
491 fp.write(content)
492
493- filenames = list(filenames) + manifests.keys()
494+ filenames = list(filenames) + list(manifests.keys())
495
496 with mojo.utils.chdir(directory):
497 for filename in filenames:
498
499=== modified file 'mojo/volattach.py'
500--- mojo/volattach.py 2016-09-21 17:00:41 +0000
501+++ mojo/volattach.py 2018-01-18 11:04:49 +0000
502@@ -1,7 +1,7 @@
503 # Copyright 2014 Canonical Ltd. This software is licensed under the
504 # GNU General Public License version 3 (see the file LICENSE).
505 """A helper for attaching volumes to Juju instances"""
506-from __future__ import print_function
507+
508 from subprocess import check_call
509 import os
510 import sys
511@@ -132,7 +132,7 @@
512 for volume_id in [v for (v, u) in unit_map.items() if u is None]:
513 if status.service_units(service):
514 units = [u for u in status.service_units(service)
515- if u not in unit_map.values()]
516+ if u not in list(unit_map.values())]
517 else:
518 raise VolumeConfigError("No service {} found".format(service))
519 if units:
520
521=== modified file 'mojo/workspace.py'
522--- mojo/workspace.py 2016-02-05 23:40:05 +0000
523+++ mojo/workspace.py 2018-01-18 11:04:49 +0000
524@@ -61,7 +61,7 @@
525
526 def clean(self):
527 "Reset the workspace"
528- map(shutil.rmtree, (d for d in self.all_dirs if os.path.exists(d)))
529+ list(map(shutil.rmtree, (d for d in self.all_dirs if os.path.exists(d))))
530 return self.prepare()
531
532 def delete(self):
533
534=== modified file 'tox.ini'
535--- tox.ini 2018-01-18 10:03:30 +0000
536+++ tox.ini 2018-01-18 11:04:49 +0000
537@@ -13,5 +13,5 @@
538 [testenv:mojo_exec]
539 basepython = python3
540 deps = -r{toxinidir}/requirements.txt
541-commands = pip install .
542+commands = pip install --upgrade .
543 mojo --version

Subscribers

People subscribed via source and target branches