~pwlars/lava-test/hwprofile

« back to all changes in this revision

Viewing changes to abrek/builtins.py

  • Committer: Paul Larson
  • Date: 2010-07-02 22:20:37 UTC
  • mfrom: (10.1.3 help)
  • Revision ID: paul.larson@canonical.com-20100702222037-k3y4up80ly2w1le9
Provide a simple help command and help on the existing commands

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import sys
2
2
 
3
 
from abrek.command import AbrekCmd
4
 
from abrek.testdef import testloader
5
 
 
6
 
class cmd_version(AbrekCmd):
 
3
import abrek
 
4
 
 
5
class cmd_version(abrek.command.AbrekCmd):
 
6
    """ Show the version of abrek
 
7
 
 
8
    Usage:  abrek version
 
9
    """
7
10
    def run(self, argv):
8
11
        import abrek
9
12
        print abrek.__version__
10
13
 
11
 
class cmd_install(AbrekCmd):
 
14
class 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
 
 
37
class cmd_install(abrek.command.AbrekCmd):
 
38
    """ Install a test
 
39
 
 
40
    Usage: abrek install TEST_NAME
 
41
    """
12
42
    def run(self, argv):
13
43
        if len(argv) != 1:
14
44
            print "please specify the name of the test to install"
15
45
            sys.exit(1)
16
 
        test = testloader(argv[0])
 
46
        test = abrek.testdef.testloader(argv[0])
17
47
        try:
18
48
            test.install()
19
49
        except RuntimeError as strerror:
20
50
            print "Test installation error: %s" % strerror
21
51
            sys.exit(1)
22
52
 
23
 
class cmd_run(AbrekCmd):
 
53
class cmd_run(abrek.command.AbrekCmd):
 
54
    """ Run tests
 
55
 
 
56
    Usage: abrek run TEST_NAME
 
57
    """
24
58
    def run(self, argv):
25
59
        if len(argv) != 1:
26
60
            print "please specify the name of the test to run"
27
61
            sys.exit(1)
28
 
        test = testloader(argv[0])
 
62
        test = abrek.testdef.testloader(argv[0])
29
63
        try:
30
64
            test.run()
31
65
        except Exception as strerror:
32
66
            print "Test execution error: %s" % strerror
33
67
            sys.exit(1)
34
68
 
35
 
class cmd_uninstall(AbrekCmd):
 
69
class cmd_uninstall(abrek.command.AbrekCmd):
 
70
    """ Uninstall a test
 
71
 
 
72
    Usage: abrek uninstall TEST_NAME
 
73
    """
36
74
    def run(self, argv):
37
75
        if len(argv) != 1:
38
76
            print "please specify the name of the test to uninstall"
39
77
            sys.exit(1)
40
 
        test = testloader(argv[0])
 
78
        test = abrek.testdef.testloader(argv[0])
41
79
        try:
42
80
            test.uninstall()
43
81
        except Exception as strerror: