2727from werkzeug .utils import safe_join
2828
2929from . import HOSTNAME
30+ from . import publish_to_error_log
3031from . import query_temp_local_metadata_db
3132from . import tasks
3233from . import VERSION
@@ -547,15 +548,15 @@ def get_all_calibrations() -> ResponseReturnValue:
547548 with local_persistent_storage ("active_calibrations" ) as cache :
548549 for file in calibration_dir .glob ("*/*.yaml" ):
549550 try :
551+ device = file .parent .name
550552 cal = yaml_decode (file .read_bytes ())
551- device = cal ["device" ]
552553 cal ["is_active" ] = cache .get (device ) == cal ["calibration_name" ]
553554 if device in all_calibrations :
554555 all_calibrations [device ].append (cal )
555556 else :
556557 all_calibrations [device ] = [cal ]
557558 except Exception as e :
558- print (f"Error reading { file .stem } : { e } " )
559+ publish_to_error_log (f"Error reading { file .stem } : { e } " , "get_all_calibrations " )
559560
560561 return attach_cache_control (jsonify (all_calibrations ), max_age = 10 )
561562
@@ -572,11 +573,15 @@ def get_calibrations_by_device(device) -> ResponseReturnValue:
572573 with local_persistent_storage ("active_calibrations" ) as c :
573574 for file in calibration_dir .glob ("*.yaml" ):
574575 try :
575- cal = yaml_decode (file .read_bytes ())
576+ cal = yaml_decode (
577+ file .read_bytes ()
578+ ) # dict, don't make Struct since we can't add fields to structs.
576579 cal ["is_active" ] = c .get (device ) == cal ["calibration_name" ]
577580 calibrations .append (cal )
578581 except Exception as e :
579- print (f"Error reading { file .stem } : { e } " )
582+ publish_to_error_log (
583+ f"Error reading { file .stem } : { e } " , "get_calibrations_by_device"
584+ )
580585
581586 return attach_cache_control (jsonify (calibrations ), max_age = 10 )
582587
0 commit comments