j['location'] = j['location'][0] # queuedtime if j.get('starttime') in ('-1', 'BUG', 'N/A', None): j['queuedtime'] = get_elapsed_time(float(j.get('submittime')), time.time()) else: j['queuedtime'] = get_elapsed_time(float(j.get('submittime')), float(j['starttime'])) # runtime if j.get('starttime') in ('-1', 'BUG', 'N/A', None): j['runtime'] = 'N/A' else: j['runtime'] = get_elapsed_time( float(j['starttime']), time.time()) # starttime if j.get('starttime') in ('-1', 'BUG', None): j['starttime'] = 'N/A' else: j['starttime'] = sec_to_str(float(j['starttime'])) # jobname outputpath = j.get('outputpath') if outputpath: jobname = os.path.basename(outputpath).split('.output')[0] if jobname != j['jobid'].split()[0]: j['jobname'] = jobname # envs if j['envs'] is None: j.update({'envs':''}) else: j['envs'] = ' '.join([str(x) + '=' + str(y) for x, y in j['envs'].iteritems()]) # args j['args'] = ' '.join(j['args']) # make the SubmitTime readable by humans
j['queuedtime'] = get_elapsed_time(float(j.get('submittime')), time.time()) else: j['queuedtime'] = get_elapsed_time(float(j.get('submittime')), float(j['starttime'])) # runtime if j.get('starttime') in ('-1', 'BUG', 'N/A', None): j['runtime'] = 'N/A' else: j['runtime'] = get_elapsed_time(float(j['starttime']), time.time()) # starttime if j.get('starttime') in ('-1', 'BUG', None): j['starttime'] = 'N/A' else: j['starttime'] = sec_to_str(float(j['starttime'])) # jobname outputpath = j.get('outputpath') if outputpath: jobname = os.path.basename(outputpath).split('.output')[0] if jobname != j['jobid'].split()[0]: j['jobname'] = jobname # envs if j['envs'] is None: j.update({'envs': ''}) else: j['envs'] = ' '.join( [str(x) + '=' + str(y) for x, y in j['envs'].iteritems()]) # args j['args'] = ' '.join(j['args'])
if j.get("starttime") in ("-1", "BUG", "N/A", None): j["queuedtime"] = get_elapsed_time(float(j.get("submittime")), time.time()) else: j["queuedtime"] = get_elapsed_time(float(j.get("submittime")), float(j["starttime"])) # runtime if j.get("starttime") in ("-1", "BUG", "N/A", None): j["runtime"] = "N/A" else: currtime = time.time() j["runtime"] = get_elapsed_time(float(j["starttime"]), time.time()) # starttime if j.get("starttime") in ("-1", "BUG", None): j["starttime"] = "N/A" else: orig_starttime = float(j["starttime"]) j["starttime"] = sec_to_str(float(j["starttime"])) # timeremaining if j.get("starttime") in ["-1", "BUG", "N/A", None]: j["timeremaining"] = "N/A" else: time_remaining = walltime_secs - (currtime - orig_starttime) h = int(walltime_secs) / 3600 m = int(time_remaining) / 60 - (h * 60) s = (int(time_remaining) % 60) + 1 if s == 60: s = 0 m += 1 j["timeremaining"] = "%02d:%02d:%02d" % (h, m, s) # jobname outputpath = j.get("outputpath") if outputpath:
raise SystemExit, 1 if duration: try: minutes = Cobalt.Util.get_time(duration) except Cobalt.Exceptions.TimeFormatError, e: print "invalid duration specification: %s" % e.args[0] sys.exit(1) dsec = 60 * minutes if start: try: (day, rtime) = start.split('-') (syear, smonth, sday) = [int(field) for field in day.split('_')] (shour, smin) = [int(field) for field in rtime.split(':')] starttime = time.mktime((syear, smonth, sday, shour, smin, 0, 0, 0, -1)) print "Got starttime %s" % (sec_to_str(starttime)) except ValueError: print "Error: start time '%s' is invalid" % start print "start time is expected to be in the format: YYYY_MM_DD-HH:MM" raise SystemExit, 1 if '-u' in sys.argv[1:]: user = [opt[1] for opt in opts if opt[0] == '-u'][0] for usr in user.split(':'): try: pwd.getpwnam(usr) except KeyError: print "User %s does not exist" % (usr) else: user = None project_specified = False
cycle = "%02d:%02d" % (cycle/3600, (cycle/60)%60) else: cycle = "%0.1f days" % (cycle / (60 * 60 * 24)) else: cycle = None dmin = (duration/60)%60 dhour = duration/3600 time_fmt = "%c" starttime = time.strftime(time_fmt, time.localtime(start)) endtime = time.strftime(time_fmt, time.localtime(start + duration)) if not ('--oldts' in sys.argv): #time_fmt += " %z (%Z)" starttime = sec_to_str(start) endtime = sec_to_str(start + duration) if really_verbose: output.append((res['name'], res['queue'], res['users'], starttime, "%02d:%02d" % (dhour, dmin), endtime, cycle, mergelist(res['partitions'], cluster), res['project'], res['res_id'], res['cycle_id'])) elif verbose: output.append((res['name'], res['queue'], res['users'], starttime, "%02d:%02d" % (dhour, dmin), endtime, cycle,
if duration: try: minutes = Cobalt.Util.get_time(duration) except Cobalt.Exceptions.TimeFormatError, e: print "invalid duration specification: %s" % e.args[0] sys.exit(1) dsec = 60 * minutes if start: try: (day, rtime) = start.split('-') (syear, smonth, sday) = [int(field) for field in day.split('_')] (shour, smin) = [int(field) for field in rtime.split(':')] starttime = time.mktime( (syear, smonth, sday, shour, smin, 0, 0, 0, -1)) print "Got starttime %s" % (sec_to_str(starttime)) except ValueError: print "Error: start time '%s' is invalid" % start print "start time is expected to be in the format: YYYY_MM_DD-HH:MM" raise SystemExit, 1 if '-u' in sys.argv[1:]: user = [opt[1] for opt in opts if opt[0] == '-u'][0] for usr in user.split(':'): try: pwd.getpwnam(usr) except KeyError: print "User %s does not exist" % (usr) else: user = None project_specified = False