avoid sending a 'resources' after 'create', use the result of 'create'
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 8 Sep 2011 13:18:58 +0000 (15:18 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 8 Sep 2011 13:18:58 +0000 (15:18 +0200)
instead
cosmetic tweaks in the config screen

sface/screens/configscreen.py
sface/screens/mainscreen.py
sface/sfiprocess.py

index 37db423..3c716ce 100644 (file)
@@ -73,28 +73,29 @@ class ConfigWidget(QWidget):
             row += 1
 
         hlayout = QHBoxLayout()
-        hlayout.addStretch()
-        def conf_button (action,label):
+        def bottom_button (action,label,align):
             button=QPushButton(label, self)
             button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
-            hlayout.addWidget(button)
+            hlayout.addWidget(button,0,align)
             hlayout.addSpacing(10)
             self.connect(button, SIGNAL('clicked()'), getattr(self,action))
 
-        conf_button ('load','Load Conf. Dir')
+        bottom_button ('load','Load Config Dir',Qt.AlignLeft)
         
         # the config dir edit dialog
-        edit=QLineEdit (config.get_dirname(),self)
-        self.store_local('config_dirname',edit)
-        edit.setAttribute(Qt.WA_MacShowFocusRect, 0)
-        edit.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Maximum)
-        self.connect(edit,SIGNAL ('returnPressed()'), self.load)
-        hlayout.addWidget (edit)
+        confdir=QLineEdit (config.get_dirname(),self)
+        self.store_local('config_dirname',confdir)
+        confdir.setAttribute(Qt.WA_MacShowFocusRect, 0)
+        confdir.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Maximum)
+        confdir.setStyleSheet("QLineEdit { width: 200px; }")
+        self.connect(confdir,SIGNAL ('returnPressed()'), self.load)
+        hlayout.addWidget (confdir,0,Qt.AlignLeft)
         hlayout.addSpacing(10)
 
-        conf_button ('createSlice', 'Create New Slice'),
-        conf_button ('apply','Apply Only'),
-        conf_button ('save','Apply && Save')
+        hlayout.addStretch()
+        bottom_button ('createSlice', 'Create New Slice', Qt.AlignRight),
+        bottom_button ('apply','Apply Only',Qt.AlignRight),
+        bottom_button ('save','Apply && Save',Qt.AlignRight)
 
         layout = QVBoxLayout()
         layout.addLayout(glayout)
@@ -111,7 +112,6 @@ class ConfigWidget(QWidget):
             self.save()
 
     def apply(self):
-        print 'applying'
         for field in config.fields():
             widget=getattr(self,field)
             if isinstance(widget,QCheckBox):
index 5578fbc..90f8df1 100644 (file)
@@ -358,7 +358,10 @@ class SliceWidget(QWidget):
 
     def submitFinished(self):
         self.setStatus("<font color='green'>Slice data submitted.</font>")
-        QTimer.singleShot(1000, self.refresh)
+        # no need to do that anymore
+        # QTimer.singleShot(1000, self.refresh)
+        self.updateView()
+        self.parent().signalAll("rspecUpdated")
 
     def refreshFinished(self):
         self.setStatus("<font color='green'>Slice data refreshed.</font>", timeout=5000)
@@ -475,7 +478,7 @@ class SliceWidget(QWidget):
         self.disconnect(self.process, SIGNAL('finished()'), self.submitFinished)
         self.connect(self.process, SIGNAL('finished()'), self.refreshFinished)
 
-        self.process.getRSpecFromSM()
+        self.process.retrieveRspec()
         self.setStatus("Refreshing slice data. This will take some time...")
 
     def updateView(self):
index 34608de..108530c 100644 (file)
@@ -103,9 +103,10 @@ class SfiProcess(QObject):
 
         return self.faults[0].get("faultString","") + " (" + self.faults[0].get("faultCode","") + ")"
 
-    def __getRSpec(self, mgr):
+    def retrieveRspec(self):
         slice = config.getSlice()
-        # Write RSpec to file for testing.
+        mgr = config.getSlicemgr()
+        # Write RSpec to file
         filename = config.fullpath ("%s.rspec"%slice)
         try:
             os.remove(filename)
@@ -119,11 +120,6 @@ class SfiProcess(QObject):
         self.start()
         return filename
 
-    def getRSpecFromSM(self):
-        return self.__getRSpec(config.getSlicemgr())
-
-#    def getRSpecFromAM(self):
-#        return self.__getRSpec(config.getAggmgr())
 
     def listRecords(self, hrn, rectype=None, filename=None):
         args = ["-u", config.getUser(), "-a", config.getAuthority(),
@@ -162,14 +158,18 @@ class SfiProcess(QObject):
         self.getRecord(config.getAuthority(), config.getAuthorityRecordFile())
 
     def applyRSpec(self, rspec):
-        filename = config.getSliceRSpecFile() + "_new"
-        rspec.save(filename)
+        # that's what we pass, like in what we'd like to get
+        requested = config.getSliceRSpecFile() + "_new"
+        # that's what we actually receive
+        # just overwrite the slice file as if we'd used 'resources'
+        obtained = config.getSliceRSpecFile()
+        rspec.save(requested)
         args = ["-u", config.getUser(), "-a", config.getAuthority(),
                 "-r", config.getRegistry(), "-s", config.getSlicemgr(), "create",
-                config.getSlice(), filename]
+                "-o", obtained,
+                config.getSlice(), requested]
         self.__init_command(args)
         self.start()
-        return filename
 
     def updateRecord(self, filename):
         args = ["-u", config.getUser(), "-a", config.getAuthority(),