Merge lp:~vila/uci-vms/proper-prog into lp:uci-vms

Proposed by Vincent Ladeuil
Status: Merged
Merged at revision: 122
Proposed branch: lp:~vila/uci-vms/proper-prog
Merge into: lp:uci-vms
Diff against target: 57 lines (+12/-6)
3 files modified
NEWS.rst (+2/-0)
ucivms/commands.py (+7/-3)
ucivms/tests/test_commands.py (+3/-3)
To merge this branch: bzr merge lp:~vila/uci-vms/proper-prog
Reviewer Review Type Date Requested Status
Leo Arias (community) Approve
Snappy Tarmac (community) Approve
Review via email: mp+268773@code.launchpad.net

Commit message

Fix the script name in the help output.

Description of the change

Quick fix for a FIXME added while I restored py2 support: the script name is uci-vms2 for python3, the help messages should respect that.

To post a comment you must log in.
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

looks good.

review: Approve
Revision history for this message
Leo Arias (elopio) wrote :

oops, wrong user.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS.rst'
2--- NEWS.rst 2015-08-13 08:31:23 +0000
3+++ NEWS.rst 2015-08-21 15:47:39 +0000
4@@ -7,6 +7,8 @@
5 dev
6 ===
7
8+* Fix the script name in the help output.
9+
10 * Restore python2 support.
11
12 * Since timeouts are used in a 'try/sleep' loop, force the last value to be
13
14=== modified file 'ucivms/commands.py'
15--- ucivms/commands.py 2015-07-21 08:27:55 +0000
16+++ ucivms/commands.py 2015-08-21 15:47:39 +0000
17@@ -44,9 +44,13 @@
18 """A parser for the uci-vms script."""
19
20 def __init__(self, name, description):
21- # FIXME: uci-vms2 if running python2 ? -- vila 2015-07-21
22- super(ArgParser, self).__init__(prog='uci-vms {}'.format(name),
23- description=description)
24+ if sys.version_info < (3,):
25+ script_name = 'uci-vms2'
26+ else:
27+ script_name = 'uci-vms'
28+ super(ArgParser, self).__init__(
29+ prog='{} {}'.format(script_name, name),
30+ description=description)
31
32 def parse_args(self, args=None, out=None, err=None):
33 """Parse arguments, overridding stdout/stderr if provided.
34
35=== modified file 'ucivms/tests/test_commands.py'
36--- ucivms/tests/test_commands.py 2015-07-22 12:02:24 +0000
37+++ ucivms/tests/test_commands.py 2015-08-21 15:47:39 +0000
38@@ -92,7 +92,7 @@
39
40 def test_help_help(self):
41 self.assertHelp('''\
42-usage: uci-vms help [-h] [COMMAND [COMMAND ...]]
43+usage: uci-vms... help [-h] [COMMAND [COMMAND ...]]
44
45 Describe uci-vms commands.
46
47@@ -241,8 +241,8 @@
48 self.parse_args(['foo', 'bar', 'baz'])
49 self.assertEqual(2, cm.exception.code)
50 self.assertError('''\
51-usage: uci-vms config [-h] [--remove] [--all] vm_name [name]
52-uci-vms config: error: unrecognized arguments: baz
53+usage: uci-vms... config [-h] [--remove] [--all] vm_name [name]
54+uci-vms... config: error: unrecognized arguments: baz
55 ''')
56
57 def test_remove_requires_name(self):

Subscribers

People subscribed via source and target branches