@@ -851,26 +851,39 @@ def list_log_configs():
851851 import glob
852852
853853 configs = []
854- active = os .path .realpath ("pifinder_logconf.json" ) if os .path .exists ("pifinder_logconf.json" ) else None
854+ active = (
855+ os .path .realpath ("pifinder_logconf.json" )
856+ if os .path .exists ("pifinder_logconf.json" )
857+ else None
858+ )
855859 for path in sorted (glob .glob ("logconf_*.json" )):
856- stem = path [len ("logconf_" ): - len (".json" )]
860+ stem = path [len ("logconf_" ) : - len (".json" )]
857861 display = stem .replace ("_" , " " ).title ()
858- configs .append ({
859- "file" : path ,
860- "name" : display ,
861- "active" : os .path .realpath (path ) == active ,
862- })
862+ configs .append (
863+ {
864+ "file" : path ,
865+ "name" : display ,
866+ "active" : os .path .realpath (path ) == active ,
867+ }
868+ )
863869 return {"configs" : configs }
864870
865871 @app .route ("/logs/switch_config" , method = "post" )
866872 @auth_required
867873 def switch_log_config ():
868874 """Atomically repoint pifinder_logconf.json to the chosen config, then restart."""
869875 logconf_file = request .forms .get ("logconf_file" , "" ).strip ()
870- if not logconf_file or not logconf_file .startswith ("logconf_" ) or not logconf_file .endswith (".json" ):
876+ if (
877+ not logconf_file
878+ or not logconf_file .startswith ("logconf_" )
879+ or not logconf_file .endswith (".json" )
880+ ):
871881 return {"status" : "error" , "message" : "Invalid log config file name" }
872882 if not os .path .exists (logconf_file ):
873- return {"status" : "error" , "message" : f"Log config file not found: { logconf_file } " }
883+ return {
884+ "status" : "error" ,
885+ "message" : f"Log config file not found: { logconf_file } " ,
886+ }
874887 try :
875888 link = "pifinder_logconf.json"
876889 tmp = link + ".tmp"
@@ -891,9 +904,15 @@ def upload_log_config():
891904 return {"status" : "error" , "message" : "No file provided" }
892905 filename = upload .filename
893906 if not filename .startswith ("logconf_" ) or not filename .endswith (".json" ):
894- return {"status" : "error" , "message" : "File must be named logconf_<name>.json" }
907+ return {
908+ "status" : "error" ,
909+ "message" : "File must be named logconf_<name>.json" ,
910+ }
895911 if os .path .exists (filename ):
896- return {"status" : "error" , "message" : f"File already exists: { filename } " }
912+ return {
913+ "status" : "error" ,
914+ "message" : f"File already exists: { filename } " ,
915+ }
897916 try :
898917 upload .save (filename , overwrite = False )
899918 logger .info ("Uploaded log config: %s" , filename )
0 commit comments