Remove commented out code, unused arguments and extra logging

This commit is contained in:
jaknapper 2025-05-07 18:26:26 +01:00
parent a88349dbfe
commit a9d06f7d7e

View file

@ -1096,7 +1096,6 @@ class SmartScanThing(Thing):
def update_zip( def update_zip(
self, self,
logger: InvocationLogger,
scan_name: str, scan_name: str,
final_version: bool = False, final_version: bool = False,
) -> None: ) -> None:
@ -1108,9 +1107,6 @@ class SmartScanThing(Thing):
zip_fname = os.path.join(scan_folder, "images.zip") zip_fname = os.path.join(scan_folder, "images.zip")
# if not os.path.isfile(zip_fname):
# raise RuntimeError("zip file hasn't been created yet")
# get a list of files in the existing zip # get a list of files in the existing zip
current_zip = self.get_files_in_zip(zip_fname) current_zip = self.get_files_in_zip(zip_fname)
@ -1140,7 +1136,6 @@ class SmartScanThing(Thing):
elif ".zip" in file: elif ".zip" in file:
pass pass
else: else:
logger.info(f"appending {file} to zip")
scan_zip.write(os.path.join(scan_folder, file), arcname=file) scan_zip.write(os.path.join(scan_folder, file), arcname=file)
# Finally zip the updating files we skipped previously # Finally zip the updating files we skipped previously
@ -1150,19 +1145,16 @@ class SmartScanThing(Thing):
with zipfile.ZipFile(zip_fname, mode="a") as scan_zip: with zipfile.ZipFile(zip_fname, mode="a") as scan_zip:
for file in files: for file in files:
if any(banned_name in file for banned_name in files_to_delay): if any(banned_name in file for banned_name in files_to_delay):
logger.info(f"we are finally adding {file} into zip")
scan_zip.write(os.path.join(scan_folder, file), arcname=file) scan_zip.write(os.path.join(scan_folder, file), arcname=file)
@thing_action @thing_action
def download_zip( def download_zip(
self, self,
scan_name: str, scan_name: str,
logger: InvocationLogger,
): ):
"""Update the zip to include the files we leave to the end, then return the """Update the zip to include the files we leave to the end, then return the
zip file as a Blob""" zip file as a Blob"""
self.update_zip( self.update_zip(
logger=logger,
scan_name=scan_name, scan_name=scan_name,
final_version=True, final_version=True,
) )
@ -1170,7 +1162,6 @@ class SmartScanThing(Thing):
scan_folder = self.dir_for_scan(scan_name=scan_name) scan_folder = self.dir_for_scan(scan_name=scan_name)
zip_fname = os.path.join(scan_folder, "images.zip") zip_fname = os.path.join(scan_folder, "images.zip")
logger.info("about to download zip")
return ZipBlob.from_file(zip_fname) return ZipBlob.from_file(zip_fname)
def get_files_in_zip(self, zip_path): def get_files_in_zip(self, zip_path):