fix scrolling issues and display of xml tag
[sface.git] / sface / config.py
index d74d239..885e6b6 100644 (file)
@@ -13,16 +13,16 @@ class Config:
 
     d_registry= "http://www.planet-lab.org:12345"
     d_slicemgr= "http://www.planet-lab.org:12347"
-    d_aggmgr=   "http://www.planet-lab.org:12346"
+#    d_aggmgr=   "http://www.planet-lab.org:12346"
 
     supported = [
         # local code name, config variable name, default
         ('slice',      'SFI_SLICE' ,   None,           '-s','--slice',         "slice HRN"),
         ('user',       'SFI_USER',     None,           '-u','--user',          "user HRN"),
         ('authority',  'SFI_AUTH',     None,           '-t','--auth',          "users's authority HRN"),
-        ('registry',   'SFI_REGISTRY', d_registry,     '-r','--registry',      "registry's URL"),
-        ('slicemgr',   'SFI_SM' ,      d_slicemgr,     '-m','--slicemgr',      "slice manager's URL"),
-        ('aggmgr',     'SFI_AM',       d_aggmgr,       '-a','--aggregate',     "aggregate manager's URL"),
+        ('registry',   'SFI_REGISTRY', d_registry,     '-r','--registry',      "registry API URL"),
+        ('slicemgr',   'SFI_SM' ,      d_slicemgr,     '-m','--slicemgr',      "slice API URL"),
+#        ('aggmgr',    'SFI_AM',       d_aggmgr,       '-a','--aggregate',     "aggregate manager's URL"),
         ('verbose',    'SFACE_VERBOSE',True,          '-v','--verbose',       "UI verbosity"),
         ('debug',      'SFACE_DEBUG',  False,          '-d','--debug',         "UI debug flag"),
         ]
@@ -70,8 +70,11 @@ class Config:
     def __init__(self):
         self.read_config()
 
+    def dirname (self):
+        return os.path.expanduser("~/.sfi/")
+
     def filename (self):
-        return os.path.expanduser("~/.sfi/sfi_config")
+        return self.dirname() + "sfi_config"
 
     def read_config(self):
         tmp={}
@@ -92,14 +95,21 @@ class Config:
                 print "%-20s: %r"%(k, self.get(k))
 
     def save_config(self):
+        configdir = self.dirname()
+        if not os.path.exists(configdir):
+            os.makedirs(configdir)
+
         configfile = self.filename()
+        if not os.path.exists(configfile):
+            open(configfile, "w").close()
+
         tmpfile = configfile + ".tmp"
 
         out = open(tmpfile, "w")
         lineno = 0
         written_fields = []
         fields = self.fields()
-        for line in open(configfile):
+        for line in open(configfile, "r"):
             lineno += 1
             try:
                 sfi, val = line.split('=')