def loadState(self): try: assert(os.path.exists(self.statePath)) tmp = utils.PersistentDict(self.statePath, ' = ') pingDict = {} for wms in tmp: isOK, ping, ping_time = tuple(tmp[wms].split(',', 2)) if utils.parseBool(isOK): pingDict[wms] = (parseStr(ping, float), parseStr(ping_time, float, 0)) return (pingDict.keys(), tmp.keys(), pingDict, 0) except Exception: return ([], [], {}, None)
def updateState(self): tmp = {} for wms in self.wms_all: pingentry = self.pingDict.get(wms, (None, 0)) tmp[wms] = '%r,%s,%s' % (wms in self.wms_ok, pingentry[0], pingentry[1]) utils.PersistentDict(self.statePath, ' = ').write(tmp)
def __init__(self, persistencyFile): self._persistencyDict = {} if os.path.exists(persistencyFile): self._persistencyDict = utils.PersistentDict(persistencyFile, ' = ')