1
2 __docformat__ = "restructuredtext"
3 import sys
4
5
7 """Run the spawned command
8 :param args: arguments excluding the executable path"""
9 if len(args) < 1:
10 raise Exception("Invalid Arguments, call command as follows:\nspcmd package.module.ServerClassName [additional options for execute method]")
11
12
13 try:
14 tokens = args[0].split('.')
15 args = args[1:]
16 module, classname = ".".join(tokens[:-1]), tokens[-1]
17 module = __import__(module, globals(), locals(), [module])
18 cmdtype = getattr(module, classname)
19
20 cmdinstance = cmdtype(_spawned=True)
21
22
23 found = False
24 try:
25 func = getattr(cmdinstance, '_execute')
26 found = True
27 func(*args)
28 except AttributeError,e:
29 raise
30 except Exception, e:
31 import logging
32
33 logging.critical("Unhandled Exception", exc_info=True)
34 raise
35
36
37
38 if __name__ == '__main__':
39 main(sys.argv[1:])
40