X-Git-Url: http://git.onelab.eu/?p=sface.git;a=blobdiff_plain;f=sface%2Fscreens%2Fmainscreen.py;h=0452161a5ba1ff2e34834835f2a286f5a3e62ad8;hp=22c321f082d88db942fab8bf36b0b540a4f6a103;hb=a42adfb545b5810b301f43a6eede650c94ab5e9d;hpb=021a306d360da13a927d1c1d5811a205b09319b8 diff --git a/sface/screens/mainscreen.py b/sface/screens/mainscreen.py index 22c321f..0452161 100644 --- a/sface/screens/mainscreen.py +++ b/sface/screens/mainscreen.py @@ -24,6 +24,10 @@ tag_status = { "in": "Already Set", "add": "To be Added", "remove": "To be Removed"} +color_status = { "in": QColor.fromRgb(0, 250, 250), + "add": QColor.fromRgb(0, 250, 0), + "remove": QColor.fromRgb(250, 0, 0) } + default_tags = "Default tags" settable_tags = ['delegations', 'initscript'] @@ -189,44 +193,20 @@ class NodeNameDelegate(QStyledItemDelegate): painter.fillRect(option.rect, option.palette.color(QPalette.Active, QPalette.Highlight)) if itemType(index) == "node": - if status_data == node_status['in']: # already in the slice - painter.fillPath(path, QColor.fromRgb(0, 250, 250)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) + for x in node_status.keys(): + if (node_status[x] == status_data) and (x in color_status): + painter.fillPath(path, color_status[x]) - elif status_data == node_status['add']: # newly added to the slice - painter.fillPath(path, QColor.fromRgb(0, 250, 0)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) - - elif status_data == node_status['remove']: # removed from the slice - painter.fillPath(path, QColor.fromRgb(250, 0, 0)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) - - else: - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) + painter.setPen(QColor.fromRgb(0, 0, 0)) + painter.drawText(rect, 0, QString(data)) else: - if status_data == tag_status['in']: # already in the slice - painter.fillPath(path, QColor.fromRgb(0, 250, 250)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) + for x in tag_status.keys(): + if (tag_status[x] == status_data) and (x in color_status): + painter.fillPath(path, color_status[x]) - elif status_data == tag_status['add']: # newly added to the slice - painter.fillPath(path, QColor.fromRgb(0, 250, 0)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) - - elif status_data == tag_status['remove']: # removed from the slice - painter.fillPath(path, QColor.fromRgb(250, 0, 0)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) - - else: - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) + painter.setPen(QColor.fromRgb(0, 0, 0)) + painter.drawText(rect, 0, QString(data)) painter.restore() @@ -375,21 +355,29 @@ class SliceWidget(QWidget): else: self.setStatus("Slice submit failed: %s" % (faultString)) - # no need to do that anymore - # QTimer.singleShot(1000, self.refresh) self.updateView() self.parent().signalAll("rspecUpdated") def refreshResourcesFinished(self): self.disconnect(self.process, SIGNAL('finished()'), self.refreshResourcesFinished) - self.setStatus("Refreshing slice RSpec.") - self.connect(self.process, SIGNAL('finished()'), self.refreshRSpecFinished) - self.process.retrieveRspec() + faultString = self.process.getFaultString() + if not faultString: + self.setStatus("Refreshing slice RSpec.") + self.connect(self.process, SIGNAL('finished()'), self.refreshRSpecFinished) + self.process.retrieveRspec() + else: + self.setStatus("Resources refresh failed: %s" % (faultString)) def refreshRSpecFinished(self): self.disconnect(self.process, SIGNAL('finished()'), self.refreshRSpecFinished) - self.setStatus("Slice data refreshed.", timeout=5000) + + faultString = self.process.getFaultString() + if not faultString: + self.setStatus("Slice data refreshed.", timeout=5000) + else: + self.setStatus("Slice refresh failed: %s" % (faultString)) + self.updateView() self.parent().signalAll("rspecUpdated")