Ejemplo n.º 1
0
 def _parseStatusX(self, lines):
     adder = lambda a, b: utils.QM('=====' not in b and b != '\n', a + b, a)
     remap = {
         'destination': 'dest',
         'status reason': 'reason',
         'status info for the job': 'id',
         'current status': 'status',
         'submitted': 'timestamp',
         'reached': 'timestamp',
         'exit code': 'gridexit'
     }
     for section in utils.accumulate(lines,
                                     lambda x, buf: ('=' * 70) in x,
                                     '',
                                     opAdd=adder):
         data = utils.DictFormat(':').parse(
             str.join('', section),
             keyParser={None: lambda k: remap.get(k, str)})
         data = utils.filterDict(data, vF=lambda v: v)
         if data:
             try:
                 if 'failed' in data['status']:
                     data['status'] = 'failed'
                 else:
                     data['status'] = data['status'].split()[0].lower()
             except Exception:
                 pass
             try:
                 data['timestamp'] = int(
                     time.mktime(parsedate(data['timestamp'])))
             except Exception:
                 pass
             yield data
Ejemplo n.º 2
0
		def format(data):
			data = copy.copy(data)
			status = data['status'].lower()
			try:
				if status.find('failed') >=0:
					status = 'failed'
				else:
					status = status.split('(')[0].split()[0]
			except Exception:
				pass
			data['status'] = status
			try:
				data['timestamp'] = int(time.mktime(parsedate(data['timestamp'])))
			except Exception:
				pass
			return data
Ejemplo n.º 3
0
	def _parseTickets(self, cached = True):
		# Return cached results if requested
		if cached and self._cache:
			return self._cache
		# Call klist and parse results
		proc = utils.LoggedProcess(self._klistExec, '-v')
		retCode = proc.wait()
		self._cache = {}
		for sectionInfo in utils.accumulate(proc.getOutput(), '', lambda x, buf: buf.endswith('\n\n')):
			parseDate = lambda x: time.mktime(parsedate(x))
			tmp = utils.DictFormat(':').parse(sectionInfo, valueParser = {'auth time': parseDate,
				'start time': parseDate, 'end time': parseDate, 'renew till': parseDate})
			if 'server' in tmp:
				self._cache[tmp['server']] = tmp
			else:
				self._cache[None] = tmp
		return self._cache
Ejemplo n.º 4
0
 def format(data):
     data = copy.copy(data)
     status = data['status'].lower()
     try:
         if status.find('failed') >= 0:
             status = 'failed'
         else:
             status = status.split('(')[0].split()[0]
     except Exception:
         pass
     data['status'] = status
     try:
         data['timestamp'] = int(
             time.mktime(parsedate(data['timestamp'])))
     except Exception:
         pass
     return data
Ejemplo n.º 5
0
	def _parseStatusX(self, lines):
		adder = lambda a, b: utils.QM('=====' not in b and b != '\n', a + b, a)
		remap = { 'destination': 'dest', 'status reason': 'reason',
			'status info for the job': 'id', 'current status': 'status',
			'submitted': 'timestamp', 'reached': 'timestamp', 'exit code': 'gridexit' }
		for section in utils.accumulate(lines, lambda x, buf: ('='*70) in x, '', opAdd = adder):
			data = utils.DictFormat(':').parse(str.join('', section), keyParser = {None: lambda k: remap.get(k, str)})
			data = utils.filterDict(data, vF = lambda v: v)
			if data:
				try:
					if 'failed' in data['status']:
						data['status'] = 'failed'
					else:
						data['status'] = data['status'].split()[0].lower()
				except Exception:
					pass
				try:
					data['timestamp'] = int(time.mktime(parsedate(data['timestamp'])))
				except Exception:
					pass
				yield data
Ejemplo n.º 6
0
	def _fill(self, job_info, key, value):
		if key.startswith('current status'):
			if 'failed' in value:
				value = 'failed'
			job_info[CheckInfo.RAW_STATUS] = value.split('(')[0].split()[0].lower()
		elif key.startswith('destination'):
			try:
				dest_info = value.split('/', 1)
				job_info[CheckInfo.SITE] = dest_info[0].strip()
				job_info[CheckInfo.QUEUE] = dest_info[1].strip()
			except Exception:
				return clear_current_exception()
		elif key.startswith('status reason'):
			job_info['reason'] = value
		elif key.startswith('reached') or key.startswith('submitted'):
			try:
				job_info['timestamp'] = int(calendar.timegm(parsedate(value)))
			except Exception:
				return clear_current_exception()
		elif key.startswith('bookkeeping information'):
			return
		elif value:
			job_info[key] = value
Ejemplo n.º 7
0
 def _fill(self, job_info, key, value):
     if key.startswith('current status'):
         if 'failed' in value:
             value = 'failed'
         job_info[CheckInfo.RAW_STATUS] = value.split(
             '(')[0].split()[0].lower()
     elif key.startswith('destination'):
         try:
             dest_info = value.split('/', 1)
             job_info[CheckInfo.SITE] = dest_info[0].strip()
             job_info[CheckInfo.QUEUE] = dest_info[1].strip()
         except Exception:
             return clear_current_exception()
     elif key.startswith('status reason'):
         job_info['reason'] = value
     elif key.startswith('reached') or key.startswith('submitted'):
         try:
             job_info['timestamp'] = int(calendar.timegm(parsedate(value)))
         except Exception:
             return clear_current_exception()
     elif key.startswith('bookkeeping information'):
         return
     elif value:
         job_info[key] = value