5050
5151# Endpoint to check the status of a background task. unit_api is required to ping workers (who only expose unit_api)
5252@unit_api .route ("/task_results/<task_id>" , methods = ["GET" ])
53- def task_status (task_id ):
53+ def task_status (task_id : str ):
5454 try :
5555 task = huey .result (task_id )
5656 except TaskLockedException :
@@ -80,7 +80,7 @@ def task_status(task_id):
8080
8181
8282@unit_api .route ("/system/update/<target>" , methods = ["POST" , "PATCH" ])
83- def update_target (target ) -> ResponseReturnValue :
83+ def update_target (target : str ) -> ResponseReturnValue :
8484 if target not in ("app" , "ui" ): # todo: firmware
8585 abort (404 , "Invalid target" )
8686
@@ -378,7 +378,7 @@ def get_all_running_jobs() -> ResponseReturnValue:
378378
379379
380380@unit_api .route ("/jobs/running/<job>" , methods = ["GET" ])
381- def get_running_job (job ) -> ResponseReturnValue :
381+ def get_running_job (job : str ) -> ResponseReturnValue :
382382 jobs = query_temp_local_metadata_db (
383383 "SELECT * FROM pio_job_metadata where is_running=1 and job_name=?" , (job ,)
384384 )
@@ -398,7 +398,7 @@ def get_all_long_running_jobs() -> ResponseReturnValue:
398398
399399
400400@unit_api .route ("/jobs/settings/job_name/<job_name>" , methods = ["GET" ])
401- def get_settings_for_a_specific_job (job_name ) -> ResponseReturnValue :
401+ def get_settings_for_a_specific_job (job_name : str ) -> ResponseReturnValue :
402402 """
403403 {
404404 "settings": {
@@ -425,8 +425,8 @@ def get_settings_for_a_specific_job(job_name) -> ResponseReturnValue:
425425
426426
427427@unit_api .route ("/jobs/settings/job_name/<job_name>/setting/<setting>" , methods = ["GET" ])
428- def get_specific_setting_for_a_job (job_name , setting ) -> ResponseReturnValue :
429- setting = query_temp_local_metadata_db (
428+ def get_specific_setting_for_a_job (job_name : str , setting : str ) -> ResponseReturnValue :
429+ setting_metadata = query_temp_local_metadata_db (
430430 """
431431 SELECT s.setting, s.value FROM
432432 pio_job_published_settings s
@@ -437,8 +437,9 @@ def get_specific_setting_for_a_job(job_name, setting) -> ResponseReturnValue:
437437 (job_name , setting ),
438438 one = True ,
439439 )
440- if setting :
441- return jsonify ({setting ["setting" ]: setting ["value" ]})
440+ assert isinstance (setting_metadata , dict )
441+ if setting_metadata :
442+ return jsonify ({setting_metadata ["setting" ]: setting_metadata ["value" ]})
442443 else :
443444 return {"status" : "error" }, 404
444445
@@ -597,7 +598,7 @@ def get_ui_version() -> ResponseReturnValue:
597598
598599
599600@unit_api .route ("/calibrations/<device>" , methods = ["POST" ])
600- def create_calibration (device ) -> ResponseReturnValue :
601+ def create_calibration (device : str ) -> ResponseReturnValue :
601602 """
602603 Create a new calibration for the specified device.
603604 """
@@ -744,7 +745,7 @@ def get_all_calibrations_as_zipped_yaml() -> ResponseReturnValue:
744745
745746
746747@unit_api .route ("/calibrations/<device>" , methods = ["GET" ])
747- def get_calibrations_by_device (device ) -> ResponseReturnValue :
748+ def get_calibrations_by_device (device : str ) -> ResponseReturnValue :
748749 calibration_dir = Path (env ["DOT_PIOREACTOR" ]) / "storage" / "calibrations" / device
749750
750751 if not calibration_dir .exists ():
@@ -768,7 +769,7 @@ def get_calibrations_by_device(device) -> ResponseReturnValue:
768769
769770
770771@unit_api .route ("/calibrations/<device>/<cal_name>" , methods = ["GET" ])
771- def get_calibration (device , cal_name ) -> ResponseReturnValue :
772+ def get_calibration (device : str , cal_name : str ) -> ResponseReturnValue :
772773 calibration_path = (
773774 Path (env ["DOT_PIOREACTOR" ]) / "storage" / "calibrations" / device / f"{ cal_name } .yaml"
774775 )
@@ -787,15 +788,15 @@ def get_calibration(device, cal_name) -> ResponseReturnValue:
787788
788789
789790@unit_api .route ("/active_calibrations/<device>/<cal_name>" , methods = ["PATCH" ])
790- def set_active_calibration (device , cal_name ) -> ResponseReturnValue :
791+ def set_active_calibration (device : str , cal_name : str ) -> ResponseReturnValue :
791792 with local_persistent_storage ("active_calibrations" ) as c :
792793 c [device ] = cal_name
793794
794795 return {"status" : "success" }, 200
795796
796797
797798@unit_api .route ("/active_calibrations/<device>" , methods = ["DELETE" ])
798- def remove_active_status_calibration (device ) -> ResponseReturnValue :
799+ def remove_active_status_calibration (device : str ) -> ResponseReturnValue :
799800 with local_persistent_storage ("active_calibrations" ) as c :
800801 if device in c :
801802 c .pop (device )
0 commit comments