blob: c8a5222d860a706d0362ee562998e72d4e610267 (
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
|
#!/usr/bin/env python
import sys
import importlib
actions = {
'list': 'gentoostats.list',
'search': 'gentooostats.search'
}
def print_usage(actions):
print 'Usage:', sys.argv[0], '<action>'
print 'Available actions:'
for action in actions.keys():
print action
def main():
argc = len(sys.argv)
if argc == 1:
print_usage(actions)
sys.exit(1)
try:
loaded_module = importlib.import_module(actions[sys.argv[1]])
loaded_module.main(opts=sys.argv[2:])
except KeyError, ImportError:
sys.stderr.writelines('Unknown action')
sys.exit(1)
if __name__ == "__main__":
main()
|