-
Notifications
You must be signed in to change notification settings - Fork 4
/
oshelper.py
60 lines (43 loc) · 1.28 KB
/
oshelper.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
import os
import os.path
# Directory related tools
class DirectoryHelper:
def default(self):
raise NotImplementedError
def exists(self, directory):
raise NotImplementedError
def toplevel(self, directory):
return os.path.basename(directory)
def base(self, directory):
return os.path.dirname(directory)
def current(self):
return os.getcwd()
def create(self, directory):
raise NotImplementedError
def change(self, directory):
os.chdir(directory)
def at_home(self, path):
raise NotImplementedError
def delete(self, directory):
raise NotImplementedError
# File related tools
class FileHelper:
def exists(self, filename):
return os.path.isfile(filename)
def delete(self, filename):
raise NotImplementedError
# General OS tools
class OsHelper:
def config_user(self, directory):
raise NotImplementedError
def set_environment(self, directory):
# Or return False
raise NotImplementedError
def run(command):
raise NotImplementedError
# nowait not needed, for now
def run_nowait(command):
self.run(command)
if __name__ == '__main__':
print 'Nothing to test at this level...'