def _setup(self, setup_key, setup_mod): if setup_key: (delim, ds, de) = utils.optSplit(setup_key, '::') modifier = identity if setup_mod and (setup_mod.strip() != 'value'): try: modifier = eval('lambda value: ' + setup_mod) # pylint:disable=eval-used except Exception: raise ConfigError('Unable to parse delimeter modifier %r' % setup_mod) return (delim, parseStr(ds, int), parseStr(de, int), modifier)
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 __init__(self, config): InfoScanner.__init__(self, config) self._eventsCmd = config.get('events command', '') self._eventsKey = config.get('events key', '') ev_per_kv = parseStr(config.get('events per key value', ''), float, 1) kv_per_ev = parseStr(config.get('key value per events', ''), float, -1) if self._eventsKey: if ev_per_kv * kv_per_ev >= 0: # one is zero or both are negative/positive raise ConfigError('Invalid value for "events per key value" or "key value per events"!') elif ev_per_kv > 0: self._eventsKeyScale = ev_per_kv else: self._eventsKeyScale = 1.0 / kv_per_ev self._eventsDefault = config.getInt('events default', -1)
def display(self): (catStateDict, catDescDict, _) = CategoryBaseReport._getCategoryStateSummary(self) infos = [] head = set() stateCat = { Job.SUCCESS: 'SUCCESS', Job.FAILED: 'FAILED', Job.RUNNING: 'RUNNING', Job.DONE: 'RUNNING' } for catKey in catDescDict: tmp = dict(catDescDict[catKey]) head.update(tmp.keys()) for stateKey in catStateDict[catKey]: state = stateCat.get(stateKey, 'WAITING') tmp[state] = tmp.get(state, 0) + catStateDict[catKey][stateKey] infos.append(tmp) stateCatList = ['WAITING', 'RUNNING', 'FAILED', 'SUCCESS'] utils.printTabular(lmap(lambda x: (x, x), sorted(head) + stateCatList), infos, 'c' * len(head), fmt=dict.fromkeys( stateCatList, lambda x: '%7d' % parseStr(x, int, 0)))
def _getReportInfos(self): result = [] t_now = time.time() for jobNum in self._jobs: jobObj = self._jobDB.getJobTransient(jobNum) runtime = parseStr(jobObj.get('runtime'), int, 0) for attempt in jobObj.history: if (attempt != jobObj.attempt) and not self._useHistory: continue if (attempt == jobObj.attempt) and (jobObj.state == Job.SUCCESS): time_info = runtime elif (attempt == jobObj.attempt - 1) and (jobObj.state != Job.SUCCESS): time_info = runtime elif attempt == jobObj.attempt: time_info = t_now - float(jobObj.submitted) else: time_info = 0 state = jobObj.state if attempt != jobObj.attempt: state = Job.FAILED dest = jobObj.history[attempt] if dest == 'N/A': dest_info = [dest] else: dest_info = dest.split('/') wmsName = jobObj.gcID.split('.')[1] endpoint = 'N/A' if 'http:' in jobObj.gcID: endpoint = jobObj.gcID.split(':')[1].split('/')[0] result.append([state, time_info, wmsName, endpoint] + dest_info) return result
def __init__(self, config): InfoScanner.__init__(self, config) self._eventsCmd = config.get('events command', '') self._eventsKey = config.get('events key', '') ev_per_kv = parseStr(config.get('events per key value', ''), float, 1) kv_per_ev = parseStr(config.get('key value per events', ''), float, -1) if self._eventsKey: if ev_per_kv * kv_per_ev >= 0: # one is zero or both are negative/positive raise ConfigError( 'Invalid value for "events per key value" or "key value per events"!' ) elif ev_per_kv > 0: self._eventsKeyScale = ev_per_kv else: self._eventsKeyScale = 1.0 / kv_per_ev self._eventsDefault = config.getInt('events default', -1)
def display(self): (catStateDict, catDescDict, _) = CategoryBaseReport._getCategoryStateSummary(self) infos = [] head = set() stateCat = {Job.SUCCESS: 'SUCCESS', Job.FAILED: 'FAILED', Job.RUNNING: 'RUNNING', Job.DONE: 'RUNNING'} for catKey in catDescDict: tmp = dict(catDescDict[catKey]) head.update(tmp.keys()) for stateKey in catStateDict[catKey]: state = stateCat.get(stateKey, 'WAITING') tmp[state] = tmp.get(state, 0) + catStateDict[catKey][stateKey] infos.append(tmp) stateCatList = ['WAITING', 'RUNNING', 'FAILED', 'SUCCESS'] utils.printTabular(lmap(lambda x: (x, x), sorted(head) + stateCatList), infos, 'c' * len(head), fmt = dict.fromkeys(stateCatList, lambda x: '%7d' % parseStr(x, int, 0)))
def splitParse(opt): (delim, ds, de) = utils.optSplit(opt, '::') return (delim, parseStr(ds, int), parseStr(de, int))