Merge lp:~pwlars/lava-test/help into lp:lava-test/0.0

Proposed by Paul Larson
Status: Merged
Merged at revision: 11
Proposed branch: lp:~pwlars/lava-test/help
Merge into: lp:lava-test/0.0
Diff against target: 109 lines (+51/-10)
2 files modified
abrek/builtins.py (+48/-10)
abrek/command.py (+3/-0)
To merge this branch: bzr merge lp:~pwlars/lava-test/help
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+29121@code.launchpad.net

Description of the change

Simple help command and help provided for the existing commands

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

36 + print getdoc(cmd)

should you use the help() function you put on cmd?

39 + except IndexError:

I would not use try/except, and just check len(argv), as the intent
is clearer, and it won't mask other issues.

I would also be happy to see some tests of at least the
infrastructure, if not the commands themselves.

Thanks,

James

review: Approve
lp:~pwlars/lava-test/help updated
12. By Paul Larson

use AbrekCmd.help()

13. By Paul Larson

return instead of print help

Revision history for this message
Paul Larson (pwlars) wrote :

> 36 + print getdoc(cmd)
>
> should you use the help() function you put on cmd?
Ah yes, fixed that

> 39 + except IndexError:
>
> I would not use try/except, and just check len(argv), as the intent
> is clearer, and it won't mask other issues.
also fixed

> I would also be happy to see some tests of at least the
> infrastructure, if not the commands themselves.
I'll add some new tests shortly

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'abrek/builtins.py'
--- abrek/builtins.py 2010-06-29 22:33:29 +0000
+++ abrek/builtins.py 2010-07-02 22:19:21 +0000
@@ -1,43 +1,81 @@
1import sys1import sys
22
3from abrek.command import AbrekCmd3import abrek
4from abrek.testdef import testloader4
55class cmd_version(abrek.command.AbrekCmd):
6class cmd_version(AbrekCmd):6 """ Show the version of abrek
7
8 Usage: abrek version
9 """
7 def run(self, argv):10 def run(self, argv):
8 import abrek11 import abrek
9 print abrek.__version__12 print abrek.__version__
1013
11class cmd_install(AbrekCmd):14class cmd_help(abrek.command.AbrekCmd):
15 """ Get help on abrek commands
16
17 Usage: abrek help [command]
18
19 If the command name is ommited, calling the help command will return a
20 list of valid commands.
21 """
22 def run(self, argv):
23 if len(argv) != 1:
24 print "Available commands:"
25 for cmd in abrek.command.get_all_cmds():
26 print " %s" % cmd
27 print
28 print "To access extended help on a command use 'abrek help " \
29 "[command]'"
30 else:
31 cmd = abrek.command.get_command(argv[0])
32 if cmd:
33 print cmd.help()
34 else:
35 print "No command found for '%s'" % argv[0]
36
37class cmd_install(abrek.command.AbrekCmd):
38 """ Install a test
39
40 Usage: abrek install TEST_NAME
41 """
12 def run(self, argv):42 def run(self, argv):
13 if len(argv) != 1:43 if len(argv) != 1:
14 print "please specify the name of the test to install"44 print "please specify the name of the test to install"
15 sys.exit(1)45 sys.exit(1)
16 test = testloader(argv[0])46 test = abrek.testdef.testloader(argv[0])
17 try:47 try:
18 test.install()48 test.install()
19 except RuntimeError as strerror:49 except RuntimeError as strerror:
20 print "Test installation error: %s" % strerror50 print "Test installation error: %s" % strerror
21 sys.exit(1)51 sys.exit(1)
2252
23class cmd_run(AbrekCmd):53class cmd_run(abrek.command.AbrekCmd):
54 """ Run tests
55
56 Usage: abrek run TEST_NAME
57 """
24 def run(self, argv):58 def run(self, argv):
25 if len(argv) != 1:59 if len(argv) != 1:
26 print "please specify the name of the test to run"60 print "please specify the name of the test to run"
27 sys.exit(1)61 sys.exit(1)
28 test = testloader(argv[0])62 test = abrek.testdef.testloader(argv[0])
29 try:63 try:
30 test.run()64 test.run()
31 except Exception as strerror:65 except Exception as strerror:
32 print "Test execution error: %s" % strerror66 print "Test execution error: %s" % strerror
33 sys.exit(1)67 sys.exit(1)
3468
35class cmd_uninstall(AbrekCmd):69class cmd_uninstall(abrek.command.AbrekCmd):
70 """ Uninstall a test
71
72 Usage: abrek uninstall TEST_NAME
73 """
36 def run(self, argv):74 def run(self, argv):
37 if len(argv) != 1:75 if len(argv) != 1:
38 print "please specify the name of the test to uninstall"76 print "please specify the name of the test to uninstall"
39 sys.exit(1)77 sys.exit(1)
40 test = testloader(argv[0])78 test = abrek.testdef.testloader(argv[0])
41 try:79 try:
42 test.uninstall()80 test.uninstall()
43 except Exception as strerror:81 except Exception as strerror:
4482
=== modified file 'abrek/command.py'
--- abrek/command.py 2010-06-21 17:23:54 +0000
+++ abrek/command.py 2010-07-02 22:19:21 +0000
@@ -9,6 +9,9 @@
9 def run(self, argv):9 def run(self, argv):
10 raise NotImplementedError("%s: command defined but not implemented!" %10 raise NotImplementedError("%s: command defined but not implemented!" %
11 self.name())11 self.name())
12 def help(self):
13 from inspect import getdoc
14 return getdoc(self)
1215
13def _convert_command_name(cmd):16def _convert_command_name(cmd):
14 return cmd[4:].replace('_','-')17 return cmd[4:].replace('_','-')

Subscribers

People subscribed via source and target branches