Read ~/.sfi/sfi_config
Andy Bavier [Wed, 23 Jun 2010 15:40:15 +0000 (11:40 -0400)]
Configure.py
SfaData.py
SfaGUI.py

index ef7fd76..2d5db33 100644 (file)
@@ -66,9 +66,9 @@ class Configure(Sink):
         panel.setWidth("100%")
         panel.setWidth("100%")
 
-        self.userBox = LabeledTextBox("User HRN:", SfaData.user)
+        self.userBox = LabeledTextBox("User HRN:", self.data.getUser())
         panel.add(self.userBox.getWidget())
-        self.sliceBox = LabeledTextBox("Slice HRN:", SfaData.slice)
+        self.sliceBox = LabeledTextBox("Slice HRN:", self.data.getSlice())
         panel.add(self.sliceBox.getWidget())
 
         hp = HorizontalPanel()
index 88d2b13..117c06d 100644 (file)
@@ -4,32 +4,36 @@ from subprocess import *
 from sfa.util.rspecHelper import RSpec
 
 class SfaData:
-    authority = "plc.princeton"
-    user = "plc.princeton.acb"
-    slice = "plc.princeton.sapan"
-
     def __init__(self):
         self.registry = None
         self.slicemgr = None
+        filename = os.path.expanduser("~/.sfi/sfi_config")
+        execfile(filename, SfaData.__dict__)
+        if not hasattr(SfaData, 'SFI_AUTH'): 
+            SfaData.SFI_AUTH = None
+        if not hasattr(SfaData, 'SFI_USER'): 
+            SfaData.SFI_USER = None
+        if not hasattr(SfaData, 'SFI_SLICE'): 
+            SfaData.SFI_SLICE = None
 
     def getAuthority(self):
-        return SfaData.authority
+        return SfaData.SFI_AUTH
 
     def getUser(self):
-        return SfaData.user
+        return SfaData.SFI_USER
 
     def setUser(self, user):
-        SfaData.user = user
+        SfaData.SFI_USER = user
 
         # Should probably get authority from user record instead...
-        a = SfaData.user.split('.')
-        SfaData.authority = '.'.join(a[:len(a)-1])
+        a = user.split('.')
+        SfaData.SFI_AUTH = '.'.join(a[:len(a)-1])
 
     def getSlice(self):
-        return SfaData.slice
+        return SfaData.SFI_SLICE
 
     def setSlice(self, slice):
-        SfaData.slice = slice
+        SfaData.SFI_SLICE = slice
 
     def getRecord(self, hrn):
         text = Popen(["sfi.py", "-u", self.getUser(), "-a", 
index 09f0333..0a3ddda 100644 (file)
--- a/SfaGUI.py
+++ b/SfaGUI.py
@@ -52,6 +52,7 @@ class SfaGUI:
 
         self.description.setStyleName("ks-Info")
 
+        self.panel.add(self.tp, DockPanel.NORTH)
         self.panel.add(self.sink_list, DockPanel.WEST)
         self.panel.add(vp, DockPanel.CENTER)
 
@@ -60,7 +61,6 @@ class SfaGUI:
         self.panel.setCellHeight(vp, "100%")
 
         History.addHistoryListener(self)
-        RootPanel().add(self.tp)
         RootPanel().add(self.panel)
 
         #Show the initial screen.