X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sface%2Fscreens%2Fuserscreen.py;h=f00192c97d291d79a1bff84357f4edcd4d80cbe5;hb=1e3be6f62cc6ae9bce88e95f243ac9cd1f92185c;hp=1f647a1da309ffc2133aa29fb92b5a4c27595735;hpb=eb430bcb674133ab6f8d18086aafa190819dd641;p=sface.git
diff --git a/sface/screens/userscreen.py b/sface/screens/userscreen.py
index 1f647a1..f00192c 100644
--- a/sface/screens/userscreen.py
+++ b/sface/screens/userscreen.py
@@ -5,10 +5,11 @@ import pickle
from PyQt4.QtCore import *
from PyQt4.QtGui import *
-from sfa.util.record import SfaRecord, SliceRecord, AuthorityRecord, UserRecord
+from sfa.storage.record import SfaRecord, SliceRecord, AuthorityRecord, UserRecord
from sface.config import config
from sface.sfiprocess import SfiProcess
from sface.screens.sfascreen import SfaScreen
+from sface.sfidata import SfiData
NAME_COLUMN = 0
#ROLE_COLUMN = 1
@@ -67,13 +68,10 @@ class UserNameDelegate(QStyledItemDelegate):
if option.state & QStyle.State_Selected:
painter.fillRect(option.rect, option.palette.color(QPalette.Active, QPalette.Highlight))
- color = None
for x in user_status.keys():
if (user_status[x] == status_data) and (x in color_status):
- color = color_status[x]
+ painter.fillPath(path, color_status[x])
- if color != None:
- painter.fillPath(path, color)
painter.setPen(QColor.fromRgb(0, 0, 0))
painter.drawText(textRect, Qt.AlignVCenter, QString(data))
@@ -127,7 +125,6 @@ class UserView(QTableView):
model = current.model()
node_index = model.index(current.row(), 0, current.parent())
node_data = node_index.data().toString()
- self.emit(SIGNAL('hostnameClicked(QString)'), node_data)
def hideUnusableColumns(self):
self.hideColumn(SERVER_MEMBERSHIP_STATUS_COLUMN)
@@ -155,15 +152,11 @@ class UserModel(QStandardItemModel):
slice_persons.append({"name": name, "role": "researcher", "member": user_status["in"]})
added_persons.append(name)
- i=0
- while (os.path.exists(config.getAuthorityListFile(i))):
- rec = self.readUserRecord(i)
- if rec:
- name = str(rec.get_name())
- if not name in added_persons:
- slice_persons.append({"name": name, "role": "", "member": user_status["out"]})
- added_persons.append(name)
- i=i+1
+ userNames = SfiData().getAuthorityHrns(type="user")
+ for name in userNames:
+ if not name in added_persons:
+ slice_persons.append({"name": name, "role": "", "member": user_status["out"]})
+ added_persons.append(name)
rootItem = self.invisibleRootItem()
@@ -216,15 +209,6 @@ class UserModel(QStandardItemModel):
return researchers
- def readUserRecord(self, i):
- rec_file = config.getAuthorityListFile(i)
- if os.path.exists(rec_file):
- xml = open(rec_file).read()
- rec = UserRecord()
- rec.load_from_string(xml)
- return rec
- return None
-
class UsersWidget(QWidget):
def __init__(self, parent):
QWidget.__init__(self, parent)
@@ -272,35 +256,35 @@ class UsersWidget(QWidget):
self.updateView()
def submitFinished(self):
- self.setStatus("Slice data submitted.")
- QTimer.singleShot(1000, self.refresh)
+ self.disconnect(self.process, SIGNAL('finished()'), self.submitFinished)
+
+ faultString = self.process.getFaultString()
+ if not faultString:
+ self.setStatus("Slice user data submitted.")
+ QTimer.singleShot(1000, self.refresh)
+ else:
+ self.setStatus("Slice user submit failed: %s" % (faultString))
def getSliceRecordFinished(self):
- self.setStatus("Authority data refreshed.", timeout=5000)
- self.refreshAuthority()
+ self.disconnect(self.process, SIGNAL('finished()'), self.getSliceRecordFinished)
+
+ faultString = self.process.getFaultString()
+ if not faultString:
+ self.setStatus("Slice record refreshed.")
+ self.refreshAuthority()
+ else:
+ self.setStatus("Slice rec refresh error: %s" % (faultString))
def getAuthorityRecordFinished(self):
- self.setStatus("Slice data refreshed.", timeout=5000)
- self.updateView()
- #self.parent().signalAll("usersUpdated")
+ self.disconnect(self.process, SIGNAL('finished()'), self.getAuthorityRecordFinished)
- def readSliceRecord(self):
- rec_file = config.getSliceRecordFile()
- if os.path.exists(rec_file):
- xml = open(rec_file).read()
- rec = SliceRecord()
- rec.load_from_string(xml)
- return rec
- return None
-
- def readAuthorityRecord(self):
- rec_file = config.getAuthorityRecordFile()
- if os.path.exists(rec_file):
- xml = open(rec_file).read()
- rec = AuthorityRecord()
- rec.load_from_string(xml)
- return rec
- return None
+ faultString = self.process.getFaultString()
+ if not faultString:
+ self.setStatus("User data refreshed.")
+ self.updateView()
+ #self.parent().signalAll("usersUpdated")
+ else:
+ self.setStatus("Authority rec refresh error: %s" % (faultString))
def setStatus(self, msg, timeout=None):
self.parent().setStatus(msg, timeout)
@@ -315,7 +299,7 @@ class UsersWidget(QWidget):
if self.checkRunningProcess():
return
- rec = self.readSliceRecord()
+ rec = SfiData().getSliceRecord()
change = self.userModel.updateRecord(rec)
if not change:
@@ -325,7 +309,6 @@ class UsersWidget(QWidget):
rec_file = config.getSliceRecordFile()
file(rec_file, "w").write(rec.save_to_string())
- self.disconnect(self.process, SIGNAL('finished()'), self.getAuthorityRecordFinished)
self.connect(self.process, SIGNAL('finished()'), self.submitFinished)
self.process.updateRecord(rec_file)
@@ -340,21 +323,19 @@ class UsersWidget(QWidget):
self.setStatus("There is already a process running. Please wait.")
return
- self.disconnect(self.process, SIGNAL('finished()'), self.submitFinished)
self.connect(self.process, SIGNAL('finished()'), self.getSliceRecordFinished)
self.process.getSliceRecord()
self.setStatus("Refreshing slice record. This will take some time...")
def refreshAuthority(self):
- self.disconnect(self.process, SIGNAL('finished()'), self.getSliceRecordFinished)
self.connect(self.process, SIGNAL('finished()'), self.getAuthorityRecordFinished)
- self.process.listRecords(config.getAuthority(), "user", config.getAuthorityListFile())
+ self.process.listRecords(config.getAuthority(), None)
self.setStatus("Refreshing user records. This will take some time...")
def updateView(self):
- sliceRec = self.readSliceRecord()
+ sliceRec = SfiData().getSliceRecord()
if not sliceRec:
# wait until we've resolved the slicerecord before displaying