Skip to content

Commit

Permalink
Fix parsing of date when the task status is UNKNOWN
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Oct 13, 2023
1 parent d42470c commit 5abaf94
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bioluigi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,20 @@ def format_multiple(self, tasks):
count_by_status[task['status']] += 5
return '\n'.join('{:{key_fill}} {}'.format(TaskFormatter.format_status(k), v, key_fill=key_fill) for k, v in count_by_status.items())

def parse_date(d):
if d is None:
return ''
elif d == 'UNKNOWN':
return d
else:
return datetime.datetime.fromtimestamp(d)

def fix_tasks_dict(tasks):
for key, t in tasks.items():
t['id'] = key
t['start_time'] = t['start_time'] and datetime.datetime.fromtimestamp(t['start_time'])
t['time_running'] = t['time_running'] and datetime.datetime.fromtimestamp(t['time_running'])
t['last_updated'] = t['last_updated'] and datetime.datetime.fromtimestamp(t['last_updated'])
t['start_time'] = parse_date(t['start_time'])
t['time_running'] = parse_date(t['time_running']) if 'time_running' in t else 'UNKNOWN'
t['last_updated'] = parse_date(t['last_updated']) if 'last_updated' in t else 'UNKNOWN'

@click.group()
def main():
Expand Down

0 comments on commit 5abaf94

Please sign in to comment.