Ensure configuration directory exists before copying config file
This commit is contained in:
+8
-2
@@ -6,8 +6,11 @@ import shutil
|
|||||||
class MonitorSetup():
|
class MonitorSetup():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._stg_conf_file = "monitor.conf"
|
self._stg_conf_file = "monitor.conf"
|
||||||
self._conf_file_path = os.path.join(os.path.expanduser('~'),
|
self._conf_file_dir = os.path.join(os.path.expanduser('~'),
|
||||||
".config/hdr-helper",self._stg_conf_file)
|
".config/hdr-helper")
|
||||||
|
self._conf_file_path = os.path.join(self._conf_file_dir,
|
||||||
|
self._stg_conf_file)
|
||||||
|
|
||||||
################################
|
################################
|
||||||
self.default_mode = None
|
self.default_mode = None
|
||||||
self.alt_rate = None
|
self.alt_rate = None
|
||||||
@@ -80,6 +83,9 @@ class MonitorSetup():
|
|||||||
file.write(line)
|
file.write(line)
|
||||||
|
|
||||||
def copy_config_file(self):
|
def copy_config_file(self):
|
||||||
|
if not os.path.exists(self._conf_file_dir):
|
||||||
|
os.makedirs(self._conf_file_dir)
|
||||||
|
|
||||||
# Backup existing config file if it exists
|
# Backup existing config file if it exists
|
||||||
if os.path.isfile(self._conf_file_path):
|
if os.path.isfile(self._conf_file_path):
|
||||||
shutil.move(self._conf_file_path, self._conf_file_path + ".backup" )
|
shutil.move(self._conf_file_path, self._conf_file_path + ".backup" )
|
||||||
|
|||||||
Reference in New Issue
Block a user