-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathburton_class.py
79 lines (48 loc) · 1.71 KB
/
burton_class.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import configparser
import os
settings_file = None
class Burton(object):
def __init__(self):
self.settings_file = self.get_settings_file()
self.load_default_configuration_profile()
#config = configparser.ConfigParser()
def get_settings_file(self):
config_dir = os.path.realpath(os.path.expanduser('~/.burton'))
if not os.path.isdir(config_dir):
print("Creating settings directory: %s ... " % (config_dir,), end='')
os.mkdir(config_dir)
if not os.path.isdir(config_dir):
raise Exception("Cannot create settings direcroty!")
print("Done!")
config_file = os.path.join(config_dir, 'burtonrc')
if os.path.isfile(config_file):
fh = open(config_file, 'w')
else:
print("Creating settings file: %s ... " % (config_file,), end='')
fh = open(config_file, 'w')
open(config_file, 'w')
fh.write('')
fh.flush()
if not os.path.isfile(config_file):
raise Exception("Cannot create settings file!")
print("Done!")
return fh
def load_server_configuration(self, env):
# Load from config file, set properties as in load_default_configuration_profile()
print("Not yet implemented!")
return True
def load_default_configuration_profile(self):
self.profile_name = 'default'
self.prompt = '>> '
self.host = 'localhost'
self.username = None
self.password = None
example_file_dir = os.path.join(os.getcwd(), 'example-files')
if not os.path.isdir(example_file_dir):
print("Creating example files directory: %s ... " % (example_file_dir,), end='')
os.mkdir(example_file_dir)
if not os.path.isdir(example_file_dir):
raise Exception("Cannot create example files direcroty!")
print("Done!")
self.example_file_dir = example_file_dir
return True