Skip to content

Commit

Permalink
add additional try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Aug 17, 2023
1 parent b127eac commit 49304a9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0-develop2
1.0.0-develop3
59 changes: 34 additions & 25 deletions plex_image_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,40 @@ def pic_thread(attrs):
executor.submit(run_plex_image_cleanup, *[attrs])

def run_plex_image_cleanup(attrs):
logger.header(pmmargs, sub=True, discord_update=True)
logger.separator("Validating Options", space=False, border=False)
do_transcode = attrs["photo-transcoder"] if "photo-transcoder" in attrs else pmmargs["photo-transcoder"]
do_trash = attrs["empty-trash"] if "empty-trash" in attrs else pmmargs["empty-trash"]
do_bundles = attrs["clean-bundles"] if "clean-bundles" in attrs else pmmargs["clean-bundles"]
do_optimize = attrs["optimize-db"] if "optimize-db" in attrs else pmmargs["optimize-db"]
if "mode" in attrs and attrs["mode"]:
mode = str(attrs["mode"]).lower()
elif pmmargs["mode"]:
mode = str(pmmargs["mode"]).lower()
else:
mode = "report"
description = f"Running in {mode.capitalize()} Mode"
extras = []
if do_trash:
extras.append("Empty Trash")
if do_bundles:
extras.append("Clean Bundles")
if do_optimize:
extras.append("Optimize DB")
if do_transcode:
extras.append("PhotoTrancoder")
if extras:
description += f" with {', '.join(extras[:-1])}{', and ' if len(extras) > 1 else ''}{extras[-1]} set to True"
logger.info(description)
try:
logger.header(pmmargs, sub=True, discord_update=True)
logger.separator("Validating Options", space=False, border=False)
do_transcode = attrs["photo-transcoder"] if "photo-transcoder" in attrs else pmmargs["photo-transcoder"]
do_trash = attrs["empty-trash"] if "empty-trash" in attrs else pmmargs["empty-trash"]
do_bundles = attrs["clean-bundles"] if "clean-bundles" in attrs else pmmargs["clean-bundles"]
do_optimize = attrs["optimize-db"] if "optimize-db" in attrs else pmmargs["optimize-db"]
if "mode" in attrs and attrs["mode"]:
mode = str(attrs["mode"]).lower()
elif pmmargs["mode"]:
mode = str(pmmargs["mode"]).lower()
else:
mode = "report"
description = f"Running in {mode.capitalize()} Mode"
extras = []
if do_trash:
extras.append("Empty Trash")
if do_bundles:
extras.append("Clean Bundles")
if do_optimize:
extras.append("Optimize DB")
if do_transcode:
extras.append("PhotoTrancoder")
if extras:
description += f" with {', '.join(extras[:-1])}{', and ' if len(extras) > 1 else ''}{extras[-1]} set to True"
logger.info(description)
except Exception as e:
logger.stacktrace()
logger.critical(e, discord=True)
raise
except KeyboardInterrupt:
logger.separator(f"User Canceled Run {script_name}")
logger.remove_main_handler()
raise

try:
logger.info("Script Started", log=False, discord=True, start="script")
Expand Down

0 comments on commit 49304a9

Please sign in to comment.