Skip to content

Commit

Permalink
convert_trace2dict, DO_jobInfo :: -unixtime arg to disable human time…
Browse files Browse the repository at this point in the history
… format
  • Loading branch information
adriansev committed Mar 13, 2024
1 parent ff45104 commit 3ca1dea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion alienpy/alien.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,14 @@ def DO_jobInfo(wb: WebSocketClientProtocol, args: list = None) -> RET:
-trace : will show the trace messages
-proc : will show the proc messages
-jdl : print jdl as a json object
-unixtime : do not convert to nice time
'''
return RET(0, msg)

show_trace = get_arg(args, '-trace')
show_proc = get_arg(args, '-proc')
show_jdl = get_arg(args, '-jdl')
unixtime = get_arg(args, '-unixtime')

jobid = args.pop(0)
job_info_query = SendMsg(wb, 'ps', ['-j', jobid, '-trace', '-jdl'], 'nomsg')
Expand All @@ -628,7 +630,7 @@ def DO_jobInfo(wb: WebSocketClientProtocol, args: list = None) -> RET:

for j in job_info_list_dict:
new_j = dict(j)
new_j['trace'] = convert_trace2dict(j['trace'])
new_j['trace'] = convert_trace2dict(j['trace'], nice_time = not unixtime)
new_j['jdl'] = convert_jdl2dict(j['jdl'])
job_processed_list.append(new_j)

Expand Down
5 changes: 3 additions & 2 deletions alienpy/tools_nowb.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,12 +943,13 @@ def import_aliases() -> None:
if os.path.exists(alias_file): AlienSessionInfo['alias_cache'] = read_conf_file(alias_file)


def convert_trace2dict(trace:str = '') -> dict:
def convert_trace2dict(trace:str = '', nice_time: bool = True) -> dict:
"""Convert an JAliEn trace output to a somewhat usable dictionary"""
trace_dict = { 'state': [], 'trace': [], 'proc': [], 'workdir': '', 'wn': '', 'queue': []}
procfmt = []
for line in trace.split('\n'):
nice_line = convert_time(str(line), False) # do not use color
# do not use color
nice_line = convert_time(str(line), False) if nice_time else line

rez = nice_line.split('[state ]: ')
if len(rez) > 1:
Expand Down

0 comments on commit 3ca1dea

Please sign in to comment.