summaryrefslogtreecommitdiff
path: root/validation/test/av_home/av_home_caller.py
blob: b63a67e2350ddba9347de2b90867ff396ce09b80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-

"""Module allowing to call av_home, with the adequate configuration"""

import sys
import os

import av_home

class av_home_caller:

    """AV HOME caller"""

    def __init__(self):
        from optparse import OptionParser
        usage = """
        %prog master [conf_file]
            Run the master script for AV HOME test
        %prog slave [conf_file]
            Run the slave script for AV HOME test
        %prog report
            Generate the AV HOME report"""

        self._commands = dict((n[4:], getattr(self, n))
                              for n in dir(self) if n.startswith('run_'))
        self._parser = OptionParser(usage = usage)
        self._parser.add_option ("-m", "--plug-mac-addr", action="store",
            type="string", dest="plug_mac", help="MAC address of the plug")
        self._parser.add_option ("-p", "--peer-mac-addr", action="store",
            type="string", dest="peer_mac", help="MAC address of the peer plug")
        self._parser.add_option ("-s", "--source-mac-addr", action="store",
            type="string", dest="source_mac", help="MAC address of PC")
        self._parser.add_option ("-i", "--iface", action="store",
            type="string", dest="iface", help="Name of the network interface (e.g eth0)")
        self._parser.add_option ("-a", "--ip-addr", action="store",
            type="string", dest="addr", help="IP address of the peer PC")
        self._parser.add_option ("-d", "--output-directory", action="store",
            type="string", dest="output_dir", help="Output directory suffix")
        self._parser.add_option ("-l", "--scammer-path", action="store",
            type="string", dest="scammer_path", help="Path to Lib Scammer directory")

    def run(self, args):
        (options, args) = self._parser.parse_args()
        if args[1]: av_home.parse_config (args[1])
        av_home.set_opts(options)
        av_home.check_params ()
        if args[0] in self._commands:
            getattr(self, 'run_' + args[0])()
        else:
            print (args[0] + ' is not a supported command')
            self._parser.print_help()
            sys.exit(1)
    def run_master(self):
        av_home.master_script();
    def run_slave(self):
        av_home.slave_script();

if __name__ == "__main__":
    av_home_caller().run(sys.argv[1:])