-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
37 lines (30 loc) · 907 Bytes
/
main.py
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
#!/usr/bin/env python
'''
Copyleft 2013
Written by Widnyana Putra. <[email protected]>
Demo of simple python plugin system
'''
import sys
from ploader import PluginLoader
if __name__ == '__main__':
pl = PluginLoader()
lists = pl.load_all()
avail = "Available Commands: "
for key, val in enumerate(lists):
avail+="%s, " % val
# print available command
print avail[:-2]
# executor part
# pass command as string, the code will run it on a 'switch-case' style
cmd = raw_input("Enter Command: ").strip()
args = raw_input("Enter parameter: ").strip()
try:
lists[cmd].run(args)
except Exception, ex:
msg = "%s" % ex
if msg.startswith('run()'):
# parameter is missing or not enough
print "command " + msg[6:]
else:
print "command Not found"
print ex