Fixed several errors in the arec preprocessor

* renamed the 'data' dict to 'arec_data' and made sure all references are consistent
* switched the recorder identifier from hostname to description, because there was a wild \n in the hostname for unknown reasons
* removed timezone awareness from starttime and endtime to make them compatible with times loaded from daisy
This commit is contained in:
Erik Thuning 2024-06-13 15:37:21 +02:00
parent b7a3d7dec2
commit 4842ed56f1

@ -38,18 +38,18 @@ class ArecProcessor(Preprocessor):
if not upload_dir.exists():
raise ValueError('Specified upload_dir does not exist.')
data = self._parse_arec_json(upload_dir)
arec_data = self._parse_arec_json(upload_dir)
required_strings = ['Title',
'Device_hostname']
'Device_description']
required_datetimes = ['Start_time',
'End_time']
for key in required_keys + required_datetimes:
if key not in data:
for key in required_strings + required_datetimes:
if key not in arec_data:
raise KeyError(f'{key} missing from arec json file.')
for key in required_datetimes:
# Will throw an exception if the format is invalid
datetime.fromisoformat(data[key])
datetime.fromisoformat(arec_data[key])
return True
@ -58,11 +58,13 @@ class ArecProcessor(Preprocessor):
queueitem = job['queueitem']
upload_dir = Path(queueitem['upload_dir'])
arec_data = self._parse_arec_json(upload_dir)
raw_title = data['Title']
recorder = data['Device_hostname']
raw_title = arec_data['Title']
recorder = arec_data['Device_description']
room_id = self.config[recorder]
starttime = datetime.fromisoformat(data['Start_time']).timestamp()
endtime = datetime.fromisoformat(data['End_time']).timestamp()
starttime_tz = datetime.fromisoformat(arec_data['Start_time'])
starttime = starttime_tz.replace(tzinfo=None)
endtime_tz = datetime.fromisoformat(arec_data['End_time'])
endtime = endtime_tz.replace(tzinfo=None)
outspec = self._init_jobspec(upload_dir,
starttime,