-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtool.py
45 lines (32 loc) · 887 Bytes
/
tool.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
38
39
40
41
42
43
import sys, platform
class CallRouter:
def __init__(self):
self.platform = "".join(platform.linux_distribution()).replace(' ', '_')
for n in range(len(self.platform)):
p = self.platform[:-n]
op = getattr(self, p, None)
if op:
#print 'Matched {0}'.format(p)
return op()
else: return self.default()
class Router(CallRouter):
def default(self):
print 'Don\'t know what to do, exiting'
sys.exit(100)
def common(self):
print 'This is a nice LSB OS'
def RedHat(self):
self.common()
CentOS = RedHat
def Ubuntu(self):
self.common()
def openSUSE(self):
self.common()
def success():
print 'Item passed'
sys.exit(0)
def fail():
print 'Item Failed'
sys.exit(33)
if __name__ == '__main__':
Router()