Merge lp:~chris.macnaughton/mojo/py3001 into lp:~ost-maintainers/mojo/py3
- py3001
- Merge into 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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ryan Beisner | Approve | ||
Review via email: mp+336288@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 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 | 44 | """ | 44 | """ |
6 | 45 | try: | 45 | try: |
7 | 46 | subprocess.check_output(['juju', 'switch']) | 46 | subprocess.check_output(['juju', 'switch']) |
9 | 47 | except subprocess.CalledProcessError, OSError: | 47 | except subprocess.CalledProcessError as OSError: |
10 | 48 | print('Error checking active Juju controller') | 48 | print('Error checking active Juju controller') |
11 | 49 | sys.exit(1) | 49 | sys.exit(1) |
12 | 50 | 50 | ||
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 | 1 | # Copyright 2014, 2015 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2014, 2015 Canonical Ltd. This software is licensed under the |
18 | 2 | # GNU General Public License version 3 (see the file LICENSE). | 2 | # GNU General Public License version 3 (see the file LICENSE). |
20 | 3 | from __future__ import print_function | 3 | |
21 | 4 | import argparse | 4 | import argparse |
22 | 5 | import errno | 5 | import errno |
23 | 6 | import logging | 6 | import logging |
24 | @@ -256,7 +256,7 @@ | |||
25 | 256 | 256 | ||
26 | 257 | 257 | ||
27 | 258 | def list_projects(args): | 258 | def list_projects(args): |
29 | 259 | map(print, mojo.project.Project.list(args.mojo_root, only_names=args.names)) | 259 | list(map(print, mojo.project.Project.list(args.mojo_root, only_names=args.names))) |
30 | 260 | 260 | ||
31 | 261 | 261 | ||
32 | 262 | @warn_if_root | 262 | @warn_if_root |
33 | @@ -312,7 +312,7 @@ | |||
34 | 312 | 312 | ||
35 | 313 | def list_workspaces(args): | 313 | def list_workspaces(args): |
36 | 314 | project = mojo.project.Project(get_project_name(args), args.series, args.mojo_root) | 314 | project = mojo.project.Project(get_project_name(args), args.series, args.mojo_root) |
38 | 315 | map(print, project.workspace_list()) | 315 | list(map(print, project.workspace_list())) |
39 | 316 | 316 | ||
40 | 317 | 317 | ||
41 | 318 | def new_spec(args): | 318 | def new_spec(args): |
42 | 319 | 319 | ||
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 | 173 | self.timeout = 60 | 173 | self.timeout = 60 |
48 | 174 | 174 | ||
49 | 175 | def _check_mount(self): | 175 | def _check_mount(self): |
51 | 176 | if self.device_name in self.container.devices.keys(): | 176 | if self.device_name in list(self.container.devices.keys()): |
52 | 177 | return True | 177 | return True |
53 | 178 | return False | 178 | return False |
54 | 179 | 179 | ||
55 | 180 | 180 | ||
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 | 1 | # Copyright 2014 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2014 Canonical Ltd. This software is licensed under the |
61 | 2 | # GNU General Public License version 3 (see the file LICENSE). | 2 | # GNU General Public License version 3 (see the file LICENSE). |
63 | 3 | from __future__ import print_function | 3 | |
64 | 4 | from mojo.cli import MojoArgumentParser | 4 | from mojo.cli import MojoArgumentParser |
65 | 5 | from mojo.juju.status import Status | 5 | from mojo.juju.status import Status |
66 | 6 | import argparse | 6 | import argparse |
67 | @@ -59,7 +59,7 @@ | |||
68 | 59 | prop)) | 59 | prop)) |
69 | 60 | else: | 60 | else: |
70 | 61 | if isinstance(values, list): | 61 | if isinstance(values, list): |
72 | 62 | map(print, values) | 62 | list(map(print, values)) |
73 | 63 | else: | 63 | else: |
74 | 64 | print(values) | 64 | print(values) |
75 | 65 | sys.exit(0) | 65 | sys.exit(0) |
76 | 66 | 66 | ||
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 | 1 | import subprocess | 1 | import subprocess |
82 | 2 | 2 | ||
86 | 3 | from debuglogs import DebugLogs | 3 | from .debuglogs import DebugLogs |
87 | 4 | from status import JujuStatusError, version, major_version | 4 | from .status import JujuStatusError, version, major_version |
88 | 5 | from wait import JujuWaitException | 5 | from .wait import JujuWaitException |
89 | 6 | 6 | ||
90 | 7 | if major_version == 1: | 7 | if major_version == 1: |
92 | 8 | from status import Juju1Status as Status | 8 | from .status import Juju1Status as Status |
93 | 9 | elif major_version == 2: | 9 | elif major_version == 2: |
95 | 10 | from status import Juju2Status as Status | 10 | from .status import Juju2Status as Status |
96 | 11 | 11 | ||
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 | 6 | import inspect | 6 | import inspect |
102 | 7 | import sys | 7 | import sys |
103 | 8 | 8 | ||
106 | 9 | import checks | 9 | from . import checks |
107 | 10 | from status import Juju2Status, JujuStatusError | 10 | from .status import Juju2Status, JujuStatusError |
108 | 11 | 11 | ||
109 | 12 | 12 | ||
110 | 13 | def main(): | 13 | def main(): |
111 | @@ -25,7 +25,7 @@ | |||
112 | 25 | if issubclass(clsmember, checks.JujuCheck): | 25 | if issubclass(clsmember, checks.JujuCheck): |
113 | 26 | available_checks[clsmember.cmd_name] = clsmember | 26 | available_checks[clsmember.cmd_name] = clsmember |
114 | 27 | 27 | ||
116 | 28 | for check in available_checks.values(): | 28 | for check in list(available_checks.values()): |
117 | 29 | sub = sp.add_parser(check.cmd_name, description=check.help) | 29 | sub = sp.add_parser(check.cmd_name, description=check.help) |
118 | 30 | check.setup_argparse(sub) | 30 | check.setup_argparse(sub) |
119 | 31 | 31 | ||
120 | 32 | 32 | ||
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 | 4 | import argparse | 4 | import argparse |
126 | 5 | import sys | 5 | import sys |
127 | 6 | 6 | ||
129 | 7 | from status import Juju2Status | 7 | from .status import Juju2Status |
130 | 8 | 8 | ||
131 | 9 | 9 | ||
132 | 10 | class StatusInfo: | 10 | class StatusInfo: |
133 | @@ -39,11 +39,11 @@ | |||
134 | 39 | def run(self, args): | 39 | def run(self, args): |
135 | 40 | ips = [] | 40 | ips = [] |
136 | 41 | if 'all' in args.applications: | 41 | if 'all' in args.applications: |
138 | 42 | for machine in self.status.yaml_status()['machines'].values(): | 42 | for machine in list(self.status.yaml_status()['machines'].values()): |
139 | 43 | if 'dns-name' in machine: | 43 | if 'dns-name' in machine: |
140 | 44 | ips.append(machine['dns-name']) | 44 | ips.append(machine['dns-name']) |
141 | 45 | if 'containers' in machine: | 45 | if 'containers' in machine: |
143 | 46 | for container in machine['containers'].values(): | 46 | for container in list(machine['containers'].values()): |
144 | 47 | if 'dns-name' in container: | 47 | if 'dns-name' in container: |
145 | 48 | ips.append(container['dns-name']) | 48 | ips.append(container['dns-name']) |
146 | 49 | else: | 49 | else: |
147 | @@ -71,7 +71,7 @@ | |||
148 | 71 | 71 | ||
149 | 72 | # Setup all available StatusInfo classes as subparsers | 72 | # Setup all available StatusInfo classes as subparsers |
150 | 73 | available_info = {'get_ips': GetIPs} | 73 | available_info = {'get_ips': GetIPs} |
152 | 74 | for cmd in available_info.values(): | 74 | for cmd in list(available_info.values()): |
153 | 75 | sub = sp.add_parser(cmd.name, description=cmd.help) | 75 | sub = sp.add_parser(cmd.name, description=cmd.help) |
154 | 76 | cmd.setup_argparse(sub) | 76 | cmd.setup_argparse(sub) |
155 | 77 | 77 | ||
156 | 78 | 78 | ||
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 | 7 | 7 | ||
162 | 8 | from collections import Counter | 8 | from collections import Counter |
163 | 9 | 9 | ||
165 | 10 | from wait import wait | 10 | from .wait import wait |
166 | 11 | 11 | ||
167 | 12 | try: | 12 | try: |
168 | 13 | with open(os.devnull, 'w') as devnull: | 13 | with open(os.devnull, 'w') as devnull: |
169 | @@ -208,7 +208,7 @@ | |||
170 | 208 | ['juju', 'status', '--format=tabular'])) | 208 | ['juju', 'status', '--format=tabular'])) |
171 | 209 | raise JujuStatusError("Timed out checking Juju status for stable state") | 209 | raise JujuStatusError("Timed out checking Juju status for stable state") |
172 | 210 | stable_state = [] | 210 | stable_state = [] |
174 | 211 | for juju_objtype, check_info in checks.iteritems(): | 211 | for juju_objtype, check_info in checks.items(): |
175 | 212 | for check in check_info: | 212 | for check in check_info: |
176 | 213 | check_function = check['check_func'] | 213 | check_function = check['check_func'] |
177 | 214 | states = check_function() | 214 | states = check_function() |
178 | @@ -229,7 +229,7 @@ | |||
179 | 229 | break | 229 | break |
180 | 230 | time.sleep(5) | 230 | time.sleep(5) |
181 | 231 | self._get_status(force_update=True) | 231 | self._get_status(force_update=True) |
183 | 232 | for juju_objtype, check_info in checks.iteritems(): | 232 | for juju_objtype, check_info in checks.items(): |
184 | 233 | for check in check_info: | 233 | for check in check_info: |
185 | 234 | check_function = check['check_func'] | 234 | check_function = check['check_func'] |
186 | 235 | states = check_function() | 235 | states = check_function() |
187 | @@ -266,7 +266,7 @@ | |||
188 | 266 | def _service_info(self, svc): | 266 | def _service_info(self, svc): |
189 | 267 | if svc == "ALL": | 267 | if svc == "ALL": |
190 | 268 | units = {} | 268 | units = {} |
192 | 269 | for service in self.yaml_status()['services'].values(): | 269 | for service in list(self.yaml_status()['services'].values()): |
193 | 270 | for unit, data in service.get('units', {}).items(): | 270 | for unit, data in service.get('units', {}).items(): |
194 | 271 | units[unit] = data | 271 | units[unit] = data |
195 | 272 | elif svc not in self.yaml_status()['services']: | 272 | elif svc not in self.yaml_status()['services']: |
196 | @@ -304,20 +304,20 @@ | |||
197 | 304 | def service_ips(self, service): | 304 | def service_ips(self, service): |
198 | 305 | units = self._service_info(service) | 305 | units = self._service_info(service) |
199 | 306 | if units: | 306 | if units: |
201 | 307 | return [u.get('public-address') for u in units.values() | 307 | return [u.get('public-address') for u in list(units.values()) |
202 | 308 | if u.get('public-address')] | 308 | if u.get('public-address')] |
203 | 309 | return units | 309 | return units |
204 | 310 | 310 | ||
205 | 311 | def service_units(self, service): | 311 | def service_units(self, service): |
206 | 312 | units = self._service_info(service) | 312 | units = self._service_info(service) |
207 | 313 | if units: | 313 | if units: |
209 | 314 | return units.keys() | 314 | return list(units.keys()) |
210 | 315 | return units | 315 | return units |
211 | 316 | 316 | ||
212 | 317 | def service_machine_numbers(self, service): | 317 | def service_machine_numbers(self, service): |
213 | 318 | units = self._service_info(service) | 318 | units = self._service_info(service) |
214 | 319 | if units: | 319 | if units: |
216 | 320 | return [u.get('machine') for u in units.values() | 320 | return [u.get('machine') for u in list(units.values()) |
217 | 321 | if u.get('machine')] | 321 | if u.get('machine')] |
218 | 322 | return units | 322 | return units |
219 | 323 | 323 | ||
220 | @@ -408,18 +408,18 @@ | |||
221 | 408 | if units is None: | 408 | if units is None: |
222 | 409 | return [] | 409 | return [] |
223 | 410 | 410 | ||
225 | 411 | return [u.get('public-address') for u in units.values() if u.get('public-address')] | 411 | return [u.get('public-address') for u in list(units.values()) if u.get('public-address')] |
226 | 412 | 412 | ||
227 | 413 | def application_machine_numbers(self, application): | 413 | def application_machine_numbers(self, application): |
228 | 414 | units = self._get_units(application) | 414 | units = self._get_units(application) |
229 | 415 | if units is None: | 415 | if units is None: |
230 | 416 | return None | 416 | return None |
231 | 417 | 417 | ||
233 | 418 | return [u.get('machine') for u in units.values() if u.get('machine')] | 418 | return [u.get('machine') for u in list(units.values()) if u.get('machine')] |
234 | 419 | 419 | ||
235 | 420 | def applications_list(self, exclude_subordinates=True): | 420 | def applications_list(self, exclude_subordinates=True): |
236 | 421 | applications = [] | 421 | applications = [] |
238 | 422 | for app in self.yaml_status()['applications'].keys(): | 422 | for app in list(self.yaml_status()['applications'].keys()): |
239 | 423 | if exclude_subordinates and 'subordinate-to' in self.yaml_status()['applications'][app]: | 423 | if exclude_subordinates and 'subordinate-to' in self.yaml_status()['applications'][app]: |
240 | 424 | continue | 424 | continue |
241 | 425 | applications.append(app) | 425 | applications.append(app) |
242 | @@ -431,7 +431,7 @@ | |||
243 | 431 | if units is None: | 431 | if units is None: |
244 | 432 | return None | 432 | return None |
245 | 433 | 433 | ||
247 | 434 | return units.keys() | 434 | return list(units.keys()) |
248 | 435 | 435 | ||
249 | 436 | def applications_ready(self): | 436 | def applications_ready(self): |
250 | 437 | """ Check status of all applications, raise JujuStatusError for an error state. | 437 | """ Check status of all applications, raise JujuStatusError for an error state. |
251 | 438 | 438 | ||
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 | 1 | # Copyright 2014 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2014 Canonical Ltd. This software is licensed under the |
257 | 2 | # GNU General Public License version 3 (see the file LICENSE). | 2 | # GNU General Public License version 3 (see the file LICENSE). |
259 | 3 | import commands | 3 | import subprocess |
260 | 4 | import os | 4 | import os |
261 | 5 | import logging | 5 | import logging |
262 | 6 | import subprocess | 6 | import subprocess |
264 | 7 | import charm_repo | 7 | from . import charm_repo |
265 | 8 | import re | 8 | import re |
266 | 9 | import shutil | 9 | import shutil |
267 | 10 | import tempfile | 10 | import tempfile |
268 | @@ -476,7 +476,7 @@ | |||
269 | 476 | if not modified: | 476 | if not modified: |
270 | 477 | return | 477 | return |
271 | 478 | 478 | ||
273 | 479 | for service, changes in modified.iteritems(): | 479 | for service, changes in modified.items(): |
274 | 480 | deployer_config_items = changes.get('cfg-config') | 480 | deployer_config_items = changes.get('cfg-config') |
275 | 481 | if not deployer_config_items: | 481 | if not deployer_config_items: |
276 | 482 | # Something differs, e.g. constraints, but not the config. | 482 | # Something differs, e.g. constraints, but not the config. |
277 | @@ -485,7 +485,7 @@ | |||
278 | 485 | juju_set_command = ['juju', mojo.juju.utils.get_juju_command('set'), service] | 485 | juju_set_command = ['juju', mojo.juju.utils.get_juju_command('set'), service] |
279 | 486 | config_changes = [] | 486 | config_changes = [] |
280 | 487 | 487 | ||
282 | 488 | for config_item, config_value in deployer_config_items.iteritems(): | 488 | for config_item, config_value in deployer_config_items.items(): |
283 | 489 | # At some point, "juju set" started trimming newlines, | 489 | # At some point, "juju set" started trimming newlines, |
284 | 490 | # which I endorse; but we may get a false positive here. | 490 | # which I endorse; but we may get a false positive here. |
285 | 491 | if identical_but_wrapped_in_newlines( | 491 | if identical_but_wrapped_in_newlines( |
286 | @@ -616,7 +616,7 @@ | |||
287 | 616 | # Take in MOJO_* variables from the environment | 616 | # Take in MOJO_* variables from the environment |
288 | 617 | tmpl_vars = {} | 617 | tmpl_vars = {} |
289 | 618 | env = os.environ.copy() | 618 | env = os.environ.copy() |
291 | 619 | for key in env.iterkeys(): | 619 | for key in env.keys(): |
292 | 620 | if 'MOJO_' in key: | 620 | if 'MOJO_' in key: |
293 | 621 | tmpl_vars[key] = env[key] | 621 | tmpl_vars[key] = env[key] |
294 | 622 | # Process the deployment configs as a Jinja2 template | 622 | # Process the deployment configs as a Jinja2 template |
295 | @@ -948,7 +948,7 @@ | |||
296 | 948 | 948 | ||
297 | 949 | _run = super(VerifyPhase, self).run | 949 | _run = super(VerifyPhase, self).run |
298 | 950 | 950 | ||
300 | 951 | for i in xrange(1, retry + 1): | 951 | for i in range(1, retry + 1): |
301 | 952 | if i > 1: | 952 | if i > 1: |
302 | 953 | logging.info( | 953 | logging.info( |
303 | 954 | "Retrying (attempt {} of {})".format( | 954 | "Retrying (attempt {} of {})".format( |
304 | @@ -1057,7 +1057,7 @@ | |||
305 | 1057 | '[ -f ${CHARMDIR}/codetree-collect-info.yaml ] && ' | 1057 | '[ -f ${CHARMDIR}/codetree-collect-info.yaml ] && ' |
306 | 1058 | 'cat ${CHARMDIR}/codetree-collect-info.yaml| sed -e "s/^/ /" || true; done') | 1058 | 'cat ${CHARMDIR}/codetree-collect-info.yaml| sed -e "s/^/ /" || true; done') |
307 | 1059 | cmd = ['juju', 'ssh', machine_id, "'{}'".format(audit_cmd), "2>/dev/null"] | 1059 | cmd = ['juju', 'ssh', machine_id, "'{}'".format(audit_cmd), "2>/dev/null"] |
309 | 1060 | status, output = commands.getstatusoutput(" ".join(cmd)) | 1060 | status, output = subprocess.getstatusoutput(" ".join(cmd)) |
310 | 1061 | if status != 0: | 1061 | if status != 0: |
311 | 1062 | raise CharmAuditPhaseException("Unknown error trying to run {}: {}".format(" ".join(cmd), output)) | 1062 | raise CharmAuditPhaseException("Unknown error trying to run {}: {}".format(" ".join(cmd), output)) |
312 | 1063 | return output | 1063 | return output |
313 | @@ -1065,7 +1065,7 @@ | |||
314 | 1065 | def parse_charm_audit_output(self, audit_output): | 1065 | def parse_charm_audit_output(self, audit_output): |
315 | 1066 | audit_info = yaml.safe_load(audit_output) | 1066 | audit_info = yaml.safe_load(audit_output) |
316 | 1067 | parsed_audit_output = {} | 1067 | parsed_audit_output = {} |
318 | 1068 | for unit in audit_info.keys(): | 1068 | for unit in list(audit_info.keys()): |
319 | 1069 | try: | 1069 | try: |
320 | 1070 | collect_url = audit_info[unit]['collect_url'] | 1070 | collect_url = audit_info[unit]['collect_url'] |
321 | 1071 | except KeyError: | 1071 | except KeyError: |
322 | @@ -1074,7 +1074,7 @@ | |||
323 | 1074 | application = audit_info[unit]['application'] | 1074 | application = audit_info[unit]['application'] |
324 | 1075 | 1075 | ||
325 | 1076 | try: | 1076 | try: |
327 | 1077 | collect_urls = parsed_audit_output[application].keys() | 1077 | collect_urls = list(parsed_audit_output[application].keys()) |
328 | 1078 | except KeyError: | 1078 | except KeyError: |
329 | 1079 | collect_urls = [] | 1079 | collect_urls = [] |
330 | 1080 | finally: | 1080 | finally: |
331 | @@ -1119,7 +1119,7 @@ | |||
332 | 1119 | "sed 's/.*/(set -x; & \&\& echo MOJO_NAGIOS_OK) || echo MOJO_NAGIOS_FAIL /'" \ | 1119 | "sed 's/.*/(set -x; & \&\& echo MOJO_NAGIOS_OK) || echo MOJO_NAGIOS_FAIL /'" \ |
333 | 1120 | "|sudo -u nagios -s bash".format(skip_check_command) | 1120 | "|sudo -u nagios -s bash".format(skip_check_command) |
334 | 1121 | cmd = ['juju', 'ssh', unit, '"{}"'.format(check_cmd), "2>/dev/null"] | 1121 | cmd = ['juju', 'ssh', unit, '"{}"'.format(check_cmd), "2>/dev/null"] |
336 | 1122 | status, output = commands.getstatusoutput(" ".join(cmd)) | 1122 | status, output = subprocess.getstatusoutput(" ".join(cmd)) |
337 | 1123 | error_output, ok_output = "", "" | 1123 | error_output, ok_output = "", "" |
338 | 1124 | if status != 0: | 1124 | if status != 0: |
339 | 1125 | if 'No such file or directory' in output or 'sudo: unknown user: nagios' in output: | 1125 | if 'No such file or directory' in output or 'sudo: unknown user: nagios' in output: |
340 | 1126 | 1126 | ||
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 | 206 | "project".format(self.name, self.root)) | 206 | "project".format(self.name, self.root)) |
346 | 207 | else: | 207 | else: |
347 | 208 | try: | 208 | try: |
349 | 209 | mkdirs(self.root, self.owner, mode=0700) | 209 | mkdirs(self.root, self.owner, mode=0o700) |
350 | 210 | except OSError as e: | 210 | except OSError as e: |
351 | 211 | raise ProjectCreationError( | 211 | raise ProjectCreationError( |
352 | 212 | "Could not create project root: {}".format(e.strerror)) | 212 | "Could not create project root: {}".format(e.strerror)) |
353 | @@ -216,7 +216,7 @@ | |||
354 | 216 | "using it.".format(self.name, self.project_series)) | 216 | "using it.".format(self.name, self.project_series)) |
355 | 217 | else: | 217 | else: |
356 | 218 | try: | 218 | try: |
358 | 219 | mkdirs(self.project_series, self.owner, mode=0700) | 219 | mkdirs(self.project_series, self.owner, mode=0o700) |
359 | 220 | except OSError as e: | 220 | except OSError as e: |
360 | 221 | raise ProjectCreationError( | 221 | raise ProjectCreationError( |
361 | 222 | "Could not create project project_series: " | 222 | "Could not create project project_series: " |
362 | @@ -246,7 +246,7 @@ | |||
363 | 246 | logging.info("Checking {} project dir {} ..." | 246 | logging.info("Checking {} project dir {} ..." |
364 | 247 | "".format(self.name, self.container_project_series)) | 247 | "".format(self.name, self.container_project_series)) |
365 | 248 | if not os.path.exists(self.container_project_series): | 248 | if not os.path.exists(self.container_project_series): |
367 | 249 | mkdirs(self.container_project_series, self.owner, mode=0700) | 249 | mkdirs(self.container_project_series, self.owner, mode=0o700) |
368 | 250 | 250 | ||
369 | 251 | sudoers_file = os.path.join(self.project_container_root, "etc", "sudoers.d", | 251 | sudoers_file = os.path.join(self.project_container_root, "etc", "sudoers.d", |
370 | 252 | "ubuntu-all") | 252 | "ubuntu-all") |
371 | @@ -254,7 +254,7 @@ | |||
372 | 254 | self.name, sudoers_file)) | 254 | self.name, sudoers_file)) |
373 | 255 | with open(sudoers_file, "w") as f: | 255 | with open(sudoers_file, "w") as f: |
374 | 256 | f.write("ubuntu ALL=(ALL) NOPASSWD: ALL\n") | 256 | f.write("ubuntu ALL=(ALL) NOPASSWD: ALL\n") |
376 | 257 | os.chmod(sudoers_file, 0400) | 257 | os.chmod(sudoers_file, 0o400) |
377 | 258 | 258 | ||
378 | 259 | if not os.path.exists(os.path.join(self.project_series, '.project')): | 259 | if not os.path.exists(os.path.join(self.project_series, '.project')): |
379 | 260 | self.write_project_info() | 260 | self.write_project_info() |
380 | @@ -294,19 +294,19 @@ | |||
381 | 294 | 294 | ||
382 | 295 | # Validate the project exists | 295 | # Validate the project exists |
383 | 296 | if self.name not in self.list(self.mojo_root, True): | 296 | if self.name not in self.list(self.mojo_root, True): |
388 | 297 | print "Project, '{}', does not appear to exist.".format(self.name) | 297 | print("Project, '{}', does not appear to exist.".format(self.name)) |
389 | 298 | print "Please run 'mojo project-new --series {} {}' to " \ | 298 | print("Please run 'mojo project-new --series {} {}' to " \ |
390 | 299 | "create the project.".format(self.series, self.name) | 299 | "create the project.".format(self.series, self.name)) |
391 | 300 | print "Or check the file permissions on {}".format(self.root) | 300 | print("Or check the file permissions on {}".format(self.root)) |
392 | 301 | sys.exit(1) | 301 | sys.exit(1) |
393 | 302 | if not self.container.exists() or not self.container.is_setup(): | 302 | if not self.container.exists() or not self.container.is_setup(): |
401 | 303 | print "The container project and series path for {} does not appear " \ | 303 | print("The container project and series path for {} does not appear " \ |
402 | 304 | "to exist at {}.".format(self.name, self.container_project_series) | 304 | "to exist at {}.".format(self.name, self.container_project_series)) |
403 | 305 | print "Check to make sure the project and series exist and " \ | 305 | print("Check to make sure the project and series exist and " \ |
404 | 306 | "permissions are set properly." | 306 | "permissions are set properly.") |
405 | 307 | print "Please run 'mojo project-new --series {} {}' to " \ | 307 | print("Please run 'mojo project-new --series {} {}' to " \ |
406 | 308 | "create the project if needed.".format(self.series, self.name) | 308 | "create the project if needed.".format(self.series, self.name)) |
407 | 309 | print "Or check the file permissions on {}".format(self.container_project_series) | 309 | print("Or check the file permissions on {}".format(self.container_project_series)) |
408 | 310 | sys.exit(1) | 310 | sys.exit(1) |
409 | 311 | 311 | ||
410 | 312 | # If we're using nested directories for specs, make sure our workspace | 312 | # If we're using nested directories for specs, make sure our workspace |
411 | 313 | 313 | ||
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 | 1 | # Copyright 2015 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2015 Canonical Ltd. This software is licensed under the |
417 | 2 | # GNU General Public License version 3 (see the file LICENSE). | 2 | # GNU General Public License version 3 (see the file LICENSE). |
418 | 3 | import os | 3 | import os |
420 | 4 | import cli | 4 | from . import cli |
421 | 5 | from .utils import setup_logging | 5 | from .utils import setup_logging |
422 | 6 | 6 | ||
423 | 7 | 7 | ||
424 | 8 | 8 | ||
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 | 1 | # Copyright 2015 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2015 Canonical Ltd. This software is licensed under the |
430 | 2 | # GNU General Public License version 3 (see the file LICENSE). | 2 | # GNU General Public License version 3 (see the file LICENSE). |
431 | 3 | import os | 3 | import os |
433 | 4 | import cli | 4 | from . import cli |
434 | 5 | from .utils import setup_logging | 5 | from .utils import setup_logging |
435 | 6 | 6 | ||
436 | 7 | 7 | ||
437 | 8 | 8 | ||
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 | 19 | @mock.patch('subprocess.check_output') | 19 | @mock.patch('subprocess.check_output') |
443 | 20 | def test__resolve_remote_paths(self, _check_output): | 20 | def test__resolve_remote_paths(self, _check_output): |
444 | 21 | """Test _resolve_remote_paths""" | 21 | """Test _resolve_remote_paths""" |
446 | 22 | _check_output.return_value = u"['/etc/init.d/apache2']" | 22 | _check_output.return_value = "['/etc/init.d/apache2']" |
447 | 23 | ws = None | 23 | ws = None |
448 | 24 | debug_logs = DebugLogs(ws, "production", None, None) | 24 | debug_logs = DebugLogs(ws, "production", None, None) |
449 | 25 | self.assertEqual(debug_logs._resolve_remote_paths('apache2/0', '/etc/init.d/apache2'), | 25 | self.assertEqual(debug_logs._resolve_remote_paths('apache2/0', '/etc/init.d/apache2'), |
450 | 26 | 26 | ||
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 | 2 | # GNU General Public License version 3 (see the file LICENSE). | 2 | # GNU General Public License version 3 (see the file LICENSE). |
456 | 3 | import mock | 3 | import mock |
457 | 4 | import os | 4 | import os |
459 | 5 | from StringIO import StringIO | 5 | from io import StringIO |
460 | 6 | import sys | 6 | import sys |
461 | 7 | from unittest import TestCase | 7 | from unittest import TestCase |
462 | 8 | 8 | ||
463 | 9 | 9 | ||
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 | 5 | from tempfile import mkdtemp | 5 | from tempfile import mkdtemp |
469 | 6 | from shutil import rmtree | 6 | from shutil import rmtree |
470 | 7 | import subprocess | 7 | import subprocess |
472 | 8 | import commands | 8 | import subprocess |
473 | 9 | import os | 9 | import os |
474 | 10 | import sys | 10 | import sys |
475 | 11 | import time | 11 | import time |
476 | @@ -260,7 +260,7 @@ | |||
477 | 260 | ] | 260 | ] |
478 | 261 | for cmd in cmds: | 261 | for cmd in cmds: |
479 | 262 | bc_status, bc_output = mojo.utils.bicommand(cmd) | 262 | bc_status, bc_output = mojo.utils.bicommand(cmd) |
481 | 263 | c_status, c_output = commands.getstatusoutput(cmd) | 263 | c_status, c_output = subprocess.getstatusoutput(cmd) |
482 | 264 | 264 | ||
483 | 265 | # We don't care about return codes, we just want to confirm they're | 265 | # We don't care about return codes, we just want to confirm they're |
484 | 266 | # both returning zero or non-zero | 266 | # both returning zero or non-zero |
485 | 267 | 267 | ||
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 | 43 | with open(os.path.join(directory, manifest_path), 'w+') as fp: | 43 | with open(os.path.join(directory, manifest_path), 'w+') as fp: |
491 | 44 | fp.write(content) | 44 | fp.write(content) |
492 | 45 | 45 | ||
494 | 46 | filenames = list(filenames) + manifests.keys() | 46 | filenames = list(filenames) + list(manifests.keys()) |
495 | 47 | 47 | ||
496 | 48 | with mojo.utils.chdir(directory): | 48 | with mojo.utils.chdir(directory): |
497 | 49 | for filename in filenames: | 49 | for filename in filenames: |
498 | 50 | 50 | ||
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 | 1 | # Copyright 2014 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2014 Canonical Ltd. This software is licensed under the |
504 | 2 | # GNU General Public License version 3 (see the file LICENSE). | 2 | # GNU General Public License version 3 (see the file LICENSE). |
505 | 3 | """A helper for attaching volumes to Juju instances""" | 3 | """A helper for attaching volumes to Juju instances""" |
507 | 4 | from __future__ import print_function | 4 | |
508 | 5 | from subprocess import check_call | 5 | from subprocess import check_call |
509 | 6 | import os | 6 | import os |
510 | 7 | import sys | 7 | import sys |
511 | @@ -132,7 +132,7 @@ | |||
512 | 132 | for volume_id in [v for (v, u) in unit_map.items() if u is None]: | 132 | for volume_id in [v for (v, u) in unit_map.items() if u is None]: |
513 | 133 | if status.service_units(service): | 133 | if status.service_units(service): |
514 | 134 | units = [u for u in status.service_units(service) | 134 | units = [u for u in status.service_units(service) |
516 | 135 | if u not in unit_map.values()] | 135 | if u not in list(unit_map.values())] |
517 | 136 | else: | 136 | else: |
518 | 137 | raise VolumeConfigError("No service {} found".format(service)) | 137 | raise VolumeConfigError("No service {} found".format(service)) |
519 | 138 | if units: | 138 | if units: |
520 | 139 | 139 | ||
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 | 61 | 61 | ||
526 | 62 | def clean(self): | 62 | def clean(self): |
527 | 63 | "Reset the workspace" | 63 | "Reset the workspace" |
529 | 64 | map(shutil.rmtree, (d for d in self.all_dirs if os.path.exists(d))) | 64 | list(map(shutil.rmtree, (d for d in self.all_dirs if os.path.exists(d)))) |
530 | 65 | return self.prepare() | 65 | return self.prepare() |
531 | 66 | 66 | ||
532 | 67 | def delete(self): | 67 | def delete(self): |
533 | 68 | 68 | ||
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 | 13 | [testenv:mojo_exec] | 13 | [testenv:mojo_exec] |
539 | 14 | basepython = python3 | 14 | basepython = python3 |
540 | 15 | deps = -r{toxinidir}/requirements.txt | 15 | deps = -r{toxinidir}/requirements.txt |
542 | 16 | commands = pip install . | 16 | commands = pip install --upgrade . |
543 | 17 | mojo --version | 17 | mojo --version |
There are a number of print(( changes which I think can just be print(. Happy to be proven incorrect, however.