From ec32b764aaea2419c6e43cca236aa7f91e5b6de1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Thu, 9 Sep 2010 19:52:54 +0200 Subject: [PATCH 1/1] introduce sfahelper and add .gitignore for pyc files --- .gitignore | 1 + sface/screens/mainscreen.py | 23 +++-------------------- sface/sfahelper.py | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 .gitignore create mode 100644 sface/sfahelper.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e99e36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc \ No newline at end of file diff --git a/sface/screens/mainscreen.py b/sface/screens/mainscreen.py index f566b99..f552896 100644 --- a/sface/screens/mainscreen.py +++ b/sface/screens/mainscreen.py @@ -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 index 0000000..53cf351 --- /dev/null +++ b/sface/sfahelper.py @@ -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) -- 2.43.0