From c9f2f3d2c0547f1bb06729799f692d55bada0b99 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver <thomas@kluyver.me.uk> Date: Mon, 3 Jul 2023 17:10:46 +0100 Subject: [PATCH] Use fractional seconds in timestamps from webservice --- webservice/webservice.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/webservice/webservice.py b/webservice/webservice.py index 9fa488f23..33cb29c43 100644 --- a/webservice/webservice.py +++ b/webservice/webservice.py @@ -956,7 +956,7 @@ class ActionsServer: This will trigger a correction process to be launched for that run in the given cycle and proposal. """ - request_time = datetime.now().strftime('%Y-%m-%dT%H:%M:%S') + request_time = datetime.now() try: runnr = runnr.strip('r') @@ -970,9 +970,9 @@ class ActionsServer: return msg.encode() with time_db_transaction(self.job_db, 'Insert request'): - cur = self.job_db.execute( # 2 + cur = self.job_db.execute( "INSERT INTO requests VALUES (NULL, ?, ?, ?, 'CORRECT', ?)", - (rid, proposal, int(runnr), request_time) + (rid, proposal, int(runnr), request_time.isoformat()) ) req_id = cur.lastrowid @@ -1105,7 +1105,7 @@ class ActionsServer: with time_db_transaction(self.job_db, 'Insert request'): cur = self.job_db.execute( "INSERT INTO requests VALUES (NULL, ?, ?, ?, 'CORRECT', ?)", - (rid, proposal, int(runnr), request_time.strftime('%Y-%m-%dT%H:%M:%S')) + (rid, proposal, int(runnr), request_time.isoformat()) ) req_id = cur.lastrowid @@ -1170,7 +1170,7 @@ class ActionsServer: '--env-cache', f'/gpfs/exfel/data/scratch/{getuser()}/calib-repeat-envs', '--report-to', - f'{reports_dir}/{karabo_id}_RECORRECT_{request_time:%y%m%d_%H%M%S}' + f'{reports_dir}/{karabo_id}_RECORRECT_{request_time:%y%m%d_%H%M%S.%f}' ] with time_db_transaction(self.job_db, 'Insert execution'): @@ -1216,7 +1216,7 @@ class ActionsServer: :param runnr: is the run number in integer form, i.e. without leading "r" """ - request_time = datetime.now().strftime('%Y-%m-%dT%H:%M:%S') + request_time = datetime.now() try: pdus, karabo_das, wait_runs = ast.literal_eval(','.join(extra)) @@ -1236,7 +1236,7 @@ class ActionsServer: with time_db_transaction(self.job_db, 'Insert request'): cur = self.job_db.execute( "INSERT INTO requests VALUES (NULL, ?, ?, ?, 'DARK', ?)", - (rid, proposal, int(wait_runs[-1]), request_time) + (rid, proposal, int(wait_runs[-1]), request_time.isoformat()) ) req_id = cur.lastrowid @@ -1445,9 +1445,9 @@ class ActionsServer: action=action, instrument=instrument, cycle=cycle, proposal=proposal, runs="_".join([f"r{r}" for r in run_nrs]), - time_stamp=datetime.now().strftime('%y%m%d_%H%M%S'), + time_stamp=request_time.strftime('%y%m%d_%H%M%S.%f'), det_instance=karabo_id, - request_time=request_time + request_time=request_time.isoformat(), ).split() cmd = parse_config(cmd, dconfig) -- GitLab