summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2014-11-21 09:08:10 -0500
committerSiddharth Ravikumar <sravik@bgsu.edu>2014-11-21 09:08:10 -0500
commit9f7d577742602018a975c9f2957d13c2858703d9 (patch)
treeee65d5a85cf9e80255d9ee08792753367e5729b1
parentb0eb2f6008ca27711722cfb334ccc373c8aad8b0 (diff)
modified: config.py -- configuration thingy is now a function + the passhrase is sha224 summed.
-rw-r--r--combox/config.py53
1 files changed, 29 insertions, 24 deletions
diff --git a/combox/config.py b/combox/config.py
index ef83f6d..4bf334c 100644
--- a/combox/config.py
+++ b/combox/config.py
@@ -43,34 +43,39 @@
import os
import yaml
import getpass
-import md5
+import hashlib
import sys
import stat
-# First whether combox is already configured.
-config_dir = os.path.join(os.getenv('HOME'),'.combox/')
-if not os.path.exists(config_dir):
- # Create combox dir and configure.
- os.mkdir(config_dir, 0700)
- config_file_path = os.path.join(config_dir, 'config.yaml')
- config_info = {}
- config_info['combox_dir'] = raw_input('path to combox directory: ')
- config_info['topsecret'] = md5.new(getpass.getpass('passphrase: ')).hexdigest()
+def config_cb():
+ """
+ Configure combox, if not already configured.
+ """
+ # First whether combox is already configured.
+ config_dir = os.path.join(os.getenv('HOME'),'.combox/')
+ if not os.path.exists(config_dir):
+ # Create combox dir and configure.
+ os.mkdir(config_dir, 0700)
+ config_file_path = os.path.join(config_dir, 'config.yaml')
+ config_info = {}
- no_nodes = int(raw_input('number of nodes: '))
+ config_info['combox_dir'] = raw_input('path to combox directory: ')
+ config_info['topsecret'] = hashlib.sha224(getpass.getpass('passphrase: ')).hexdigest()
- nodes = {}
- for i in range(no_nodes):
- node_name = raw_input('node %d name: ' % i)
- nodes[node_name] = {}
- nodes[node_name]['path'] = raw_input('node %d path: ' % i)
- nodes[node_name]['size'] = raw_input('node %d size (in mega bytes): ' % i)
- nodes[node_name]['available'] = nodes[node_name]['size']
+ no_nodes = int(raw_input('number of nodes: '))
- 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)
-else:
- print "You've already configured combox!"
+ nodes = {}
+ for i in range(no_nodes):
+ node_name = raw_input('node %d name: ' % i)
+ nodes[node_name] = {}
+ nodes[node_name]['path'] = raw_input('node %d path: ' % i)
+ nodes[node_name]['size'] = raw_input('node %d size (in mega bytes): ' % i)
+ nodes[node_name]['available'] = nodes[node_name]['size']
+
+ 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)
+ else:
+ print "You've already configured combox!"