From 8e52a84293bd4a05ee94668e0a94ebc9e2263d5b Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Fri, 3 May 2024 13:38:36 -0400 Subject: [PATCH] Checks requirement versions to print a message if one needs to be updated --- CHANGELOG | 9 +-------- kometa.py | 33 ++++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ca379dba..ef4de9bf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,19 +3,12 @@ # Removed Features # New Features -Added `overlay_artwork_filetype` and `overlay_artwork_quality` settings to control the filetype and quality of overlay images. Users can select from JPG, PNG and WEBP. +Checks requirement versions to print a message if one needs to be updated # Updates # Defaults -Added `starting_only` template variable to the `mal` Collection Default. -Changed streaming defaults to use names as their keys vs their TMDb IDs as keys -Fixed `amazon` ID in `streaming` when region is `CA` # Bug Fixes -Catch bad ID data from Plex -Fixes `- git` file calls -Ignore empty Environment Variables -Fixes collections being deleted under certain conditions when using translations Various other Minor Fixes \ No newline at end of file diff --git a/kometa.py b/kometa.py index 22d6a60b..9d13ed14 100644 --- a/kometa.py +++ b/kometa.py @@ -9,8 +9,8 @@ if sys.version_info[0] != 3 or sys.version_info[1] < 8: sys.exit(0) try: - import plexapi, psutil, requests, schedule - from dotenv import load_dotenv + import arrapi, git, lxml, pathvalidate, PIL, plexapi, psutil, dateutil, requests, ruamel.yaml, schedule, setuptools, tmdbapis + from dotenv import load_dotenv, version as dotenv_version from PIL import ImageFile from plexapi import server from plexapi.exceptions import NotFound @@ -19,6 +19,22 @@ except (ModuleNotFoundError, ImportError): print("Requirements Error: Requirements are not installed") sys.exit(0) +system_versions = { + "arrapi": arrapi.__version__, + "GitPython": git.__version__, + "lxml": lxml.__version__, + "pathvalidate": pathvalidate.__version__, + "pillow": PIL.__version__, + "PlexAPI": plexapi.__version__, + "psutil": psutil.__version__, + "python-dotenv": dotenv_version.__version__, + "python-dateutil": dateutil.__version__, # noqa + "requests": requests.__version__, + "ruamel.yaml": ruamel.yaml.__version__, + "setuptools": setuptools.__version__, + "tmdbapis": tmdbapis.__version__ +} + default_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config") load_dotenv(os.path.join(default_dir, ".env")) @@ -257,18 +273,17 @@ def start(attrs): new_version = latest_version[0] if latest_version and (version[1] != latest_version[1] or (version[2] and version[2] < latest_version[2])) else None if new_version: logger.info(f" Newest Version: {new_version}") - required_version = None + logger.info(f" Platform: {platform.platform()}") + logger.info(f" Memory: {round(psutil.virtual_memory().total / (1024.0 ** 3))} GB") if not is_docker and not is_linuxserver: try: with open(os.path.abspath(os.path.join(os.path.dirname(__file__), "requirements.txt")), "r") as file: - required_version = next(ln.strip()[9:] for ln in file.readlines() if ln.strip().startswith("PlexAPI==")) + required_versions = {ln.split("==")[0]: ln.split("==")[1].strip() for ln in file.readlines()} + for req_name, sys_ver in system_versions.items(): + if sys_ver != required_versions[req_name]: + logger.info(f" {req_name} version: {sys_ver} requires an update to: {required_versions[req_name]}") except FileNotFoundError: logger.error(" File Error: requirements.txt not found") - logger.info(f" PlexAPI Version: {plexapi.VERSION}") - if required_version is not None and required_version != plexapi.VERSION: - logger.info(f" PlexAPI Requires an Update to Version: {required_version}") - logger.info(f" Platform: {platform.platform()}") - logger.info(f" Memory: {round(psutil.virtual_memory().total / (1024.0 ** 3))} GB") if "time" in attrs and attrs["time"]: start_type = f"{attrs['time']} " elif run_args["tests"]: start_type = "Test " elif "collections" in attrs and attrs["collections"]: start_type = "Collections "