Fix config
This commit is contained in:
parent
0866367887
commit
bfda2be38b
10
config.py
10
config.py
@ -25,12 +25,12 @@ import tools
|
|||||||
def make_sure_path_exists(path):
|
def make_sure_path_exists(path):
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
return True
|
return False
|
||||||
except OSError as exception:
|
except OSError as exception:
|
||||||
if exception.errno != errno.EEXIST:
|
if exception.errno != errno.EEXIST:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
return False
|
return True
|
||||||
|
|
||||||
|
|
||||||
class Config():
|
class Config():
|
||||||
@ -40,7 +40,7 @@ class Config():
|
|||||||
self.load()
|
self.load()
|
||||||
|
|
||||||
def get(self, param):
|
def get(self, param):
|
||||||
return self.config[param]
|
return self.config.get(param, False)
|
||||||
|
|
||||||
def set(self, param, value):
|
def set(self, param, value):
|
||||||
self.config[param] = value
|
self.config[param] = value
|
||||||
@ -57,11 +57,11 @@ class Config():
|
|||||||
def load(self):
|
def load(self):
|
||||||
try:
|
try:
|
||||||
folder_exists = make_sure_path_exists(self.config_path)
|
folder_exists = make_sure_path_exists(self.config_path)
|
||||||
if folder_exists and os.path.isfile(self.config.path + "bmc.json"):
|
if folder_exists and os.path.isfile(self.config_path + "bmc.json"):
|
||||||
initialized = True
|
initialized = True
|
||||||
else:
|
else:
|
||||||
initialized = False
|
initialized = False
|
||||||
except:
|
except OSError:
|
||||||
tools.warning("Unable to create ~/.config folder.")
|
tools.warning("Unable to create ~/.config folder.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if not initialized:
|
if not initialized:
|
||||||
|
Loading…
Reference in New Issue
Block a user