summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-02-09 10:31:10 -0500
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-02-09 10:31:10 -0500
commit224c0ff2510d41ddeee527b08fbdb3b686379747 (patch)
tree4feb4ed7c83233ba9c32200a7f1353e4057a6080
parent57f5accd78d2819bc7c26d8248419aafb0d13855 (diff)
combox/config.py: added a new arg `write' (boolean) to cb_config function.
`write' is set to 'True' by default. If `write' is 'True' the generated config is written to the disk; otherwise it is returned.
-rw-r--r--combox/config.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/combox/config.py b/combox/config.py
index c4b83c4..ea6acd4 100644
--- a/combox/config.py
+++ b/combox/config.py
@@ -64,7 +64,8 @@ def get_stdin(prompt):
def config_cb(config_dir = path.join(os.getenv('HOME'),'.combox/'),
pass_func = get_secret,
- input_func = get_stdin):
+ input_func = get_stdin,
+ write=True):
"""
Configure combox.
"""
@@ -89,7 +90,6 @@ def config_cb(config_dir = path.join(os.getenv('HOME'),'.combox/'),
config_info['topsecret'] = pass_func()
no_nodes = int(input_func('number of nodes'))
-
nodes = {}
for i in range(no_nodes):
node_name = input_func('node %d name' % i)
@@ -103,9 +103,12 @@ def config_cb(config_dir = path.join(os.getenv('HOME'),'.combox/'),
os.mkdir(nodes[node_name]['path'])
config_info['nodes_info'] = nodes
- config_file = open(config_file_path, 'w')
- yaml.dump(config_info, config_file, default_flow_style=False)
- os.chmod(config_file_path,stat.S_IRUSR|stat.S_IWUSR)
+ if write:
+ config_file = open(config_file_path, 'w')
+ yaml.dump(config_info, config_file, default_flow_style=False)
+ os.chmod(config_file_path,stat.S_IRUSR|stat.S_IWUSR)
+ else:
+ return config_info
def get_nodedirs(config):