introduce sfahelper
authorBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Thu, 9 Sep 2010 17:52:54 +0000 (19:52 +0200)
committerBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Thu, 9 Sep 2010 17:52:54 +0000 (19:52 +0200)
and add .gitignore for pyc files

.gitignore [new file with mode: 0644]
sface/screens/mainscreen.py
sface/sfahelper.py [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..7e99e36
--- /dev/null
@@ -0,0 +1 @@
+*.pyc
\ No newline at end of file
index f566b99..f552896 100644 (file)
@@ -1,9 +1,8 @@
 
-from PyQt4.QtCore import Qt, QString, SIGNAL
-from PyQt4.QtGui import QWidget, QLabel, QTreeView, QStandardItemModel, QVBoxLayout, QSizePolicy
-
-from sfa.util.rspecHelper import RSpec
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
 
+from sface.sfahelper import *
 from sface.sficonfig import config
 from sface.screens.sfascreen import SfaScreen
 
@@ -37,21 +36,6 @@ class SliceWidget(QWidget):
         self.setLayout(layout)
         self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
         
-    
-    # TODO: use the methods from sfa-trunk
-    def rspec_get_networks(self, rspec_string):
-        rspec = RSpec (rspec_string)
-        return rspec.rspec.xpath("./network[@name]/@name")
-    def rspec_get_xml_nodes_from_network(self, rspec_string, network):
-        rspec = RSpec (rspec_string)
-        return rspec.rspec.xpath("./network[@name='%s']/site/node" % network)
-    def rspec_get_sliver_nodes_from_network(self, rspec_string, network):
-        rspec = RSpec (rspec_string)
-        return rspec.rspec.xpath("./network[@name='%s']/site/node[sliver]/hostname/text()" % network)
-    def rspec_get_other_nodes_from_network(self, rspec_string, network):
-        rspec = RSpec (rspec_string)
-        # xxx todo - could not find the xpath syntax for 'does not have the sliver attribute'
-        return rspec.rspec.xpath("./network[@name='%s']/site/node[~sliver]/hostname/text()" % network)
 
     def refresh(self, link=None):
         data = SfaData()
@@ -94,7 +78,6 @@ class SliceWidget(QWidget):
         self.nodeModel.setData(self.nodeModel.index(0,2), QString(msg))
 
 
-
 class MainScreen(SfaScreen):
     def __init__(self, parent=None):
         SfaScreen.__init__(self, parent)
diff --git a/sface/sfahelper.py b/sface/sfahelper.py
new file mode 100644 (file)
index 0000000..53cf351
--- /dev/null
@@ -0,0 +1,27 @@
+
+# These functions are going to be merged in sfa and we'll get rid of
+# this sfahelper module. - baris
+
+from sfa.util.rspecHelper import RSpec
+
+    
+# TODO: already merged in sfa-trunk. Use the one there
+def rspec_get_networks(self, rspec_string):
+    rspec = RSpec (rspec_string)
+    return rspec.rspec.xpath("./network[@name]/@name")
+
+
+# TODO: already merged in sfa-trunk. Use the one there
+def rspec_get_xml_nodes_from_network(self, rspec_string, network):
+    rspec = RSpec (rspec_string)
+    return rspec.rspec.xpath("./network[@name='%s']/site/node" % network)
+
+
+def rspec_get_sliver_nodes_from_network(self, rspec_string, network):
+    rspec = RSpec (rspec_string)
+    return rspec.rspec.xpath("./network[@name='%s']/site/node[sliver]/hostname/text()" % network)
+
+def rspec_get_other_nodes_from_network(self, rspec_string, network):
+    rspec = RSpec (rspec_string)
+    # xxx todo - could not find the xpath syntax for 'does not have the sliver attribute'
+    return rspec.rspec.xpath("./network[@name='%s']/site/node[~sliver]/hostname/text()" % network)