You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2014/08/17 12:56:57 UTC

git commit: config: read config file before writing

Repository: cloudstack-cloudmonkey
Updated Branches:
  refs/heads/master f01d4f111 -> 1b226b0e9


config: read config file before writing

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/commit/1b226b0e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/1b226b0e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/1b226b0e

Branch: refs/heads/master
Commit: 1b226b0e92fc4c58bb5d686db80225e0073b66db
Parents: f01d4f1
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Sun Aug 17 12:56:36 2014 +0200
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Sun Aug 17 12:56:36 2014 +0200

----------------------------------------------------------------------
 cloudmonkey/config.py | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/1b226b0e/cloudmonkey/config.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/config.py b/cloudmonkey/config.py
index 601941d..71a1525 100644
--- a/cloudmonkey/config.py
+++ b/cloudmonkey/config.py
@@ -69,6 +69,13 @@ config_fields['server']['secretkey'] = ''
 def write_config(get_attr, config_file, first_time=False):
     global config_fields
     config = ConfigParser()
+    if os.path.exists(config_file) and not first_time:
+        config = ConfigParser()
+        try:
+            with open(config_file, 'r') as cfg:
+                config.readfp(cfg)
+        except IOError, e:
+            print "Error: config_file not found", e
     for section in config_fields.keys():
         config.add_section(section)
         for key in config_fields[section].keys():