summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2016-01-11 18:28:48 -0500
committerSiddharth Ravikumar <sravik@bgsu.edu>2016-01-11 18:28:48 -0500
commit84a74768c00ade0c7ca44cb72b9b32f103653333 (patch)
tree64b78fe3b26f9d8f0a7b8f1b4da1c64f13cbf092
parent3a0a9857b116cacda9ac658b5410f80857cf29da (diff)
combox/config.py: modified config_cb function.
The combox configuration directory creation is now done after reading all the configuration values; the function also creates the combox directory if it does not already exist.
-rw-r--r--ChangeLog4
-rw-r--r--combox/config.py13
2 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index e0aa0c7..7f06b7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
* combox/cbox.py: Now, combox starts configuration when the
configuration directory does not exist or when the configuration
file does not exist.
+ * combox/config.py (config_cb): The combox configuration directory
+ creation is now done after reading all the configuration values;
+ the function also creates the combox directory if it does not
+ already exist.
2016-01-10 Siddharth Ravikumar <sravik@bgsu.edu>
diff --git a/combox/config.py b/combox/config.py
index d370a44..a6ffc8d 100644
--- a/combox/config.py
+++ b/combox/config.py
@@ -110,10 +110,6 @@ def config_cb(config_dir = path.join(expanduser("~"), '.combox'),
:rtype: dict
"""
-
- if not path.exists(config_dir):
- # Create combox dir.
- os.mkdir(config_dir, 0700)
config_file_path = path.join(config_dir, 'config.yaml')
config_info = {}
@@ -144,6 +140,15 @@ def config_cb(config_dir = path.join(expanduser("~"), '.combox'),
os.makedirs(nodes[node_name]['path'])
config_info['nodes_info'] = nodes
+
+ if not path.exists(config_dir):
+ # Create combox config directory.
+ os.mkdir(config_dir, 0700)
+
+ if not path.exists(config_info['combox_dir']):
+ # Create combox directory.
+ os.makedirs(config_info['combox_dir'])
+
if write:
config_file = open(config_file_path, 'w')
yaml.dump(config_info, config_file, default_flow_style=False)