From 84a74768c00ade0c7ca44cb72b9b32f103653333 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Mon, 11 Jan 2016 18:28:48 -0500 Subject: 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. --- ChangeLog | 4 ++++ combox/config.py | 13 +++++++++---- 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 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) -- cgit v1.2.3