From efc79cceec95828cc4d205c4e5a4e4190af3a727 Mon Sep 17 00:00:00 2001 From: Brandon Marlowe Date: Sun, 7 Jan 2024 20:04:24 -0500 Subject: [PATCH] Merge develop into master (#161) * Hotfix/conditional deps (#154) * hotfix: conditional requirement for python<3.9 * conditional depedency added * bump version * silly mistake not calling get on the env vars * update changelog * updating for minor version bump * removed unnecessary Dockerfile --- .gitignore | 1 + CHANGELOG.md | 8 ++ mmpm/__version__.py | 4 +- mmpm/api/endpoints/ep_packages.py | 26 +++-- mmpm/api/repeater.py | 7 +- mmpm/magicmirror/database.py | 10 +- mmpm/magicmirror/package.py | 32 +++--- mmpm/subcommands/_sub_cmd_ui.py | 2 + mmpm/ui.py | 29 ++--- mmpm/wsgi.py | 2 +- pdm.lock | 108 +++++++++--------- pyproject.toml | 4 +- ui/Dockerfile | 23 ---- .../log-stream-viewer.component.ts | 2 +- ui/src/app/services/api/base-api.ts | 10 +- .../services/api/config-file-api.service.ts | 4 +- .../api/magicmirror-controller-api.service.ts | 2 +- .../api/magicmirror-package-api.service.ts | 4 +- 18 files changed, 137 insertions(+), 141 deletions(-) delete mode 100644 ui/Dockerfile diff --git a/.gitignore b/.gitignore index 4888a7f3..40da8170 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ htmlcov .idea mmpm/ui .pdm-python +mmpm/ui diff --git a/CHANGELOG.md b/CHANGELOG.md index d6e1e2bd..a9de312a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -316,3 +316,11 @@ ## Version 4.0.4 - hotfix of calling get on env vars + +## Version 4.1.0 + +- removed extra log messages to reduce log pollution +- changed casing of function names in UI to conform to camelCasing +- using appropriate interpreter based on environment in ecosystem.json +- removed custom package directory extension to prevent naming issues in config.json +- removed multi-threading options from gunicorn servers diff --git a/mmpm/__version__.py b/mmpm/__version__.py index 3044619f..9c8f6dc7 100644 --- a/mmpm/__version__.py +++ b/mmpm/__version__.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 major = 4 -minor = 0 -patch = 4 +minor = 1 +patch = 0 version = f"{major}.{minor}.{patch}" diff --git a/mmpm/api/endpoints/ep_packages.py b/mmpm/api/endpoints/ep_packages.py index dd43c2bd..45ed57bb 100644 --- a/mmpm/api/endpoints/ep_packages.py +++ b/mmpm/api/endpoints/ep_packages.py @@ -102,11 +102,13 @@ def remove() -> Response: failure = [] for package in packages: - if MagicMirrorPackage(**package).remove(): - logger.debug(f"Removed {package['title']}") + pkg = MagicMirrorPackage(**package) + + if pkg.remove(): + logger.debug(f"Removed {pkg.title}") success.append(package) else: # honestly, this should never fail anyway - logger.debug(f"Failed to remove {package['title']}") + logger.debug(f"Failed to remove {pkg.title}") failure.append(package) return self.success({"success": success, "failure": failure}) @@ -128,11 +130,13 @@ def upgrade() -> Response: failure = [] for package in packages: - if MagicMirrorPackage(**package).upgrade(): - logger.debug(f"Upgraded {package['title']}") + pkg = MagicMirrorPackage(**package) + + if pkg.upgrade(): + logger.debug(f"Upgraded {pkg.title}") success.append(package) else: - logger.debug(f"Failed to upgrade {package['title']}") + logger.debug(f"Failed to upgrade {pkg.title}") failure.append(package) return self.success({"success": success, "failure": failure}) @@ -168,15 +172,17 @@ def remove_mm_pkg() -> Response: Response: A Flask Response object containing the status of each custom package removal attempt. """ - packages = [MagicMirrorPackage(**pkg) for pkg in request.get_json()["packages"]] + packages = request.get_json()["packages"] success = [] failure = [] for package in packages: - if self.db.remove_mm_pkg(package.title): - success.append(package.serialize(full=True)) + pkg = MagicMirrorPackage(**package) + + if self.db.remove_mm_pkg(pkg.title): + success.append(package) else: - failure.append(package.serialize(full=True)) + failure.append(package) return self.success({"success": success, "failure": failure}) diff --git a/mmpm/api/repeater.py b/mmpm/api/repeater.py index 34ecb80e..1f1bde99 100644 --- a/mmpm/api/repeater.py +++ b/mmpm/api/repeater.py @@ -32,15 +32,14 @@ def setup_mm_client(): attempt = 0 max_retries = 250 + logger.debug("Attempting to connect to MagicMirror SocketIO server. Using a maximum of 250 retries") + while attempt < max_retries and not mm_client.connected: try: mm_client.connect(env.MMPM_MAGICMIRROR_URI.get(), wait_timeout=10, wait=True) - logger.debug("Successfully connected to the MagicMirror SocketIO server") break # Connection successful, break out of the loop - except Exception as error: - logger.error(error) - logger.error(f"Connection failed on attempt ({attempt+1}/{max_retries}). Retrying.") + except Exception: attempt += 1 sleep(1) diff --git a/mmpm/magicmirror/database.py b/mmpm/magicmirror/database.py index 64ab8a61..f1deb2de 100644 --- a/mmpm/magicmirror/database.py +++ b/mmpm/magicmirror/database.py @@ -53,14 +53,14 @@ def __download_packages__(self) -> List[MagicMirrorPackage]: table_soup = soup.find_all("table") categories_soup = soup.find_all(attrs={"class": "markdown-body"})[0].find_all("h3") - categories = [] + self.categories = [] for category in categories_soup[2:]: if hasattr(category, "contents"): if hasattr(category.contents, "contents"): - categories.append(category.contents[-1].contents[0]) + self.categories.append(category.contents[-1].contents[0]) else: - categories.append(category.contents[-1]) + self.categories.append(category.contents[-1]) # the first index is a row that literally says 'Title' 'Author' 'Description' tr_soup: list = [table.find_all("tr")[1:] for table in table_soup] @@ -73,7 +73,7 @@ def __download_packages__(self) -> List[MagicMirrorPackage]: if not table_data or not table_data[0].text or table_data[0].text == "mmpm": continue - pkg = MagicMirrorPackage.from_raw_data(table_data, category=categories[index]) + pkg = MagicMirrorPackage.from_raw_data(table_data, category=self.categories[index]) packages.append(pkg) except Exception as error: # broad exception isn't best, but there's a lot that can happen here @@ -357,7 +357,7 @@ def add_mm_pkg(self, title: str, author: str, repository: str, description: str category="Custom Packages", ) - package.directory = Path(f'{package.repository.split("/")[-1].replace(".git", "")}-ext-mm-pkg') + package.directory = Path(package.repository.split("/")[-1].replace(".git", "")) try: ext_pkgs_file = paths.MMPM_CUSTOM_PACKAGES_FILE diff --git a/mmpm/magicmirror/package.py b/mmpm/magicmirror/package.py index 1f584ead..04f1755c 100644 --- a/mmpm/magicmirror/package.py +++ b/mmpm/magicmirror/package.py @@ -336,7 +336,8 @@ class InstallationHandler: def __init__(self, package: MagicMirrorPackage): self.package = package - def execute(self, funk: Callable) -> bool: + def exec(self, funk: Callable) -> bool: + logger.debug(f"Calling exec wrapper to install dependencies for '{self.package.title}'") error_code, _, stderr = funk() if error_code: @@ -369,32 +370,31 @@ def install(self) -> bool: return False os.chdir(modules_dir) - error_code = 0 - if not self.package.directory.exists(): - self.package.directory.mkdir(exist_ok=True) + if not (self.package.directory / ".git").exists(): + logger.debug(f"{self.package.directory / '.git'} not found. Cloning repo.") error_code, _, stderr = self.package.clone() - os.chdir(self.package.directory) + if error_code: + logger.error(f"Failed to clone {self.package.title}: {stderr}") + return False - if error_code: - logger.error(f"Failed to clone {self.package.title}: {stderr}") - return False + os.chdir(self.package.directory) - elif self.exists("package.json"): - return self.execute(self.npm_install) + if self.exists("package.json"): + return self.exec(self.npm_install) elif self.exists("Gemfile"): - return self.execute(self.bundle_install) + return self.exec(self.bundle_install) elif self.exists("Makefile"): - return self.execute(self.make) + return self.exec(self.make) elif self.exists("CMakeLists.txt"): - return self.execute(self.cmake) + return self.exec(self.cmake) elif self.exists("requirements.txt"): - return self.execute(self.pip_install) + return self.exec(self.pip_install) elif self.exists("pom.xml"): - return self.execute(self.maven_install) + return self.exec(self.maven_install) elif self.exists("go.mod"): - return self.execute(self.go_build) + return self.exec(self.go_build) logger.debug(f"Unable to find any dependency file associated with {self.package.title}") return True diff --git a/mmpm/subcommands/_sub_cmd_ui.py b/mmpm/subcommands/_sub_cmd_ui.py index fb6ddd8d..20478cbd 100644 --- a/mmpm/subcommands/_sub_cmd_ui.py +++ b/mmpm/subcommands/_sub_cmd_ui.py @@ -158,6 +158,8 @@ def exec(self, args, extra): logger.error("Failed to remove MMPM UI") self.ui.delete() + sleep(2) + if not self.ui.install(): logger.error("Failed to install MMPM UI") self.ui.delete() diff --git a/mmpm/ui.py b/mmpm/ui.py index 085a7e78..a074457b 100644 --- a/mmpm/ui.py +++ b/mmpm/ui.py @@ -27,35 +27,38 @@ class MMPMui(Singleton): """ def __init__(self): - self.pm2_config_path = Path("/tmp/mmpm/ecosystem.json") + # make sure we have the right python environment + python = shutil.which("python") + namespace = "mmpm" + self.pm2_config_path = Path("/tmp/mmpm/ecosystem.json") self.pm2_ecosystem_config = { "apps": [ { - "namespace": "mmpm", - "name": "mmpm.api", - "script": f"python3 -m gunicorn -k gevent -b 0.0.0.0:{urls.MMPM_API_SERVER_PORT} mmpm.wsgi:app", + "namespace": namespace, + "name": f"{namespace}.api", + "script": f"{python} -m gunicorn -k gevent -b 0.0.0.0:{urls.MMPM_API_SERVER_PORT} mmpm.wsgi:app", "version": version, "watch": True, }, { - "namespace": "mmpm", - "name": "mmpm.log-server", - "script": f"python3 -m gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 'mmpm.log.server:create()' -b 0.0.0.0:{urls.MMPM_LOG_SERVER_PORT}", + "namespace": namespace, + "name": f"{namespace}.log-server", + "script": f"{python} -m gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 'mmpm.log.server:create()' -b 0.0.0.0:{urls.MMPM_LOG_SERVER_PORT}", "version": version, "watch": True, }, { - "namespace": "mmpm", - "name": "mmpm.repeater", - "script": f"python3 -m gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 'mmpm.api.repeater:create()' -b 0.0.0.0:{urls.MMPM_REPEATER_SERVER_PORT}", + "namespace": namespace, + "name": f"{namespace}.repeater", + "script": f"{python} -m gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 'mmpm.api.repeater:create()' -b 0.0.0.0:{urls.MMPM_REPEATER_SERVER_PORT}", "version": version, "watch": True, }, { - "namespace": "mmpm", - "name": "mmpm.ui", - "script": f"python3 -m http.server -d {pkg_resources.files('mmpm').resolve() / 'ui'} -b 0.0.0.0 {urls.MMPM_UI_PORT}", + "namespace": namespace, + "name": f"{namespace}.ui", + "script": f"{python} -m http.server -d {pkg_resources.files('mmpm').resolve() / 'ui'} -b 0.0.0.0 {urls.MMPM_UI_PORT}", "version": version, "watch": True, }, diff --git a/mmpm/wsgi.py b/mmpm/wsgi.py index f9d000dc..59848df4 100644 --- a/mmpm/wsgi.py +++ b/mmpm/wsgi.py @@ -33,7 +33,7 @@ if __name__ == "__main__": app.run( - threaded=True, + threaded=False, keepalive=True, log=logger, extra_files=[ diff --git a/pdm.lock b/pdm.lock index 5d2df038..8c9db0fa 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.1" -content_hash = "sha256:2115e3a80af2a69f91708ef1d79c61f586c8bf8fb2e73ceac819715f589a3b47" +content_hash = "sha256:015b75d7bbd040e2d73c5455f01b5294e089a9ce35a5425702f81417f62bb440" [[package]] name = "argcomplete" @@ -353,63 +353,63 @@ files = [ [[package]] name = "coverage" -version = "7.3.4" +version = "7.4.0" requires_python = ">=3.8" summary = "Code coverage measurement for Python" groups = ["dev"] files = [ - {file = "coverage-7.3.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:aff2bd3d585969cc4486bfc69655e862028b689404563e6b549e6a8244f226df"}, - {file = "coverage-7.3.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e4353923f38d752ecfbd3f1f20bf7a3546993ae5ecd7c07fd2f25d40b4e54571"}, - {file = "coverage-7.3.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ea473c37872f0159294f7073f3fa72f68b03a129799f3533b2bb44d5e9fa4f82"}, - {file = "coverage-7.3.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5214362abf26e254d749fc0c18af4c57b532a4bfde1a057565616dd3b8d7cc94"}, - {file = "coverage-7.3.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f99b7d3f7a7adfa3d11e3a48d1a91bb65739555dd6a0d3fa68aa5852d962e5b1"}, - {file = "coverage-7.3.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:74397a1263275bea9d736572d4cf338efaade2de9ff759f9c26bcdceb383bb49"}, - {file = "coverage-7.3.4-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:f154bd866318185ef5865ace5be3ac047b6d1cc0aeecf53bf83fe846f4384d5d"}, - {file = "coverage-7.3.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:e0d84099ea7cba9ff467f9c6f747e3fc3906e2aadac1ce7b41add72e8d0a3712"}, - {file = "coverage-7.3.4-cp310-cp310-win32.whl", hash = "sha256:3f477fb8a56e0c603587b8278d9dbd32e54bcc2922d62405f65574bd76eba78a"}, - {file = "coverage-7.3.4-cp310-cp310-win_amd64.whl", hash = "sha256:c75738ce13d257efbb6633a049fb2ed8e87e2e6c2e906c52d1093a4d08d67c6b"}, - {file = "coverage-7.3.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:997aa14b3e014339d8101b9886063c5d06238848905d9ad6c6eabe533440a9a7"}, - {file = "coverage-7.3.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8a9c5bc5db3eb4cd55ecb8397d8e9b70247904f8eca718cc53c12dcc98e59fc8"}, - {file = "coverage-7.3.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:27ee94f088397d1feea3cb524e4313ff0410ead7d968029ecc4bc5a7e1d34fbf"}, - {file = "coverage-7.3.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8ce03e25e18dd9bf44723e83bc202114817f3367789052dc9e5b5c79f40cf59d"}, - {file = "coverage-7.3.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:85072e99474d894e5df582faec04abe137b28972d5e466999bc64fc37f564a03"}, - {file = "coverage-7.3.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:a877810ef918d0d345b783fc569608804f3ed2507bf32f14f652e4eaf5d8f8d0"}, - {file = "coverage-7.3.4-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:9ac17b94ab4ca66cf803f2b22d47e392f0977f9da838bf71d1f0db6c32893cb9"}, - {file = "coverage-7.3.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:36d75ef2acab74dc948d0b537ef021306796da551e8ac8b467810911000af66a"}, - {file = "coverage-7.3.4-cp311-cp311-win32.whl", hash = "sha256:47ee56c2cd445ea35a8cc3ad5c8134cb9bece3a5cb50bb8265514208d0a65928"}, - {file = "coverage-7.3.4-cp311-cp311-win_amd64.whl", hash = "sha256:11ab62d0ce5d9324915726f611f511a761efcca970bd49d876cf831b4de65be5"}, - {file = "coverage-7.3.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:33e63c578f4acce1b6cd292a66bc30164495010f1091d4b7529d014845cd9bee"}, - {file = "coverage-7.3.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:782693b817218169bfeb9b9ba7f4a9f242764e180ac9589b45112571f32a0ba6"}, - {file = "coverage-7.3.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7c4277ddaad9293454da19121c59f2d850f16bcb27f71f89a5c4836906eb35ef"}, - {file = "coverage-7.3.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3d892a19ae24b9801771a5a989fb3e850bd1ad2e2b6e83e949c65e8f37bc67a1"}, - {file = "coverage-7.3.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3024ec1b3a221bd10b5d87337d0373c2bcaf7afd86d42081afe39b3e1820323b"}, - {file = "coverage-7.3.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:a1c3e9d2bbd6f3f79cfecd6f20854f4dc0c6e0ec317df2b265266d0dc06535f1"}, - {file = "coverage-7.3.4-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:e91029d7f151d8bf5ab7d8bfe2c3dbefd239759d642b211a677bc0709c9fdb96"}, - {file = "coverage-7.3.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:6879fe41c60080aa4bb59703a526c54e0412b77e649a0d06a61782ecf0853ee1"}, - {file = "coverage-7.3.4-cp312-cp312-win32.whl", hash = "sha256:fd2f8a641f8f193968afdc8fd1697e602e199931012b574194052d132a79be13"}, - {file = "coverage-7.3.4-cp312-cp312-win_amd64.whl", hash = "sha256:d1d0ce6c6947a3a4aa5479bebceff2c807b9f3b529b637e2b33dea4468d75fc7"}, - {file = "coverage-7.3.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:36797b3625d1da885b369bdaaa3b0d9fb8865caed3c2b8230afaa6005434aa2f"}, - {file = "coverage-7.3.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:bfed0ec4b419fbc807dec417c401499ea869436910e1ca524cfb4f81cf3f60e7"}, - {file = "coverage-7.3.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f97ff5a9fc2ca47f3383482858dd2cb8ddbf7514427eecf5aa5f7992d0571429"}, - {file = "coverage-7.3.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:607b6c6b35aa49defaebf4526729bd5238bc36fe3ef1a417d9839e1d96ee1e4c"}, - {file = "coverage-7.3.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a8e258dcc335055ab59fe79f1dec217d9fb0cdace103d6b5c6df6b75915e7959"}, - {file = "coverage-7.3.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:a02ac7c51819702b384fea5ee033a7c202f732a2a2f1fe6c41e3d4019828c8d3"}, - {file = "coverage-7.3.4-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:b710869a15b8caf02e31d16487a931dbe78335462a122c8603bb9bd401ff6fb2"}, - {file = "coverage-7.3.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:c6a23ae9348a7a92e7f750f9b7e828448e428e99c24616dec93a0720342f241d"}, - {file = "coverage-7.3.4-cp38-cp38-win32.whl", hash = "sha256:758ebaf74578b73f727acc4e8ab4b16ab6f22a5ffd7dd254e5946aba42a4ce76"}, - {file = "coverage-7.3.4-cp38-cp38-win_amd64.whl", hash = "sha256:309ed6a559bc942b7cc721f2976326efbfe81fc2b8f601c722bff927328507dc"}, - {file = "coverage-7.3.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:aefbb29dc56317a4fcb2f3857d5bce9b881038ed7e5aa5d3bcab25bd23f57328"}, - {file = "coverage-7.3.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:183c16173a70caf92e2dfcfe7c7a576de6fa9edc4119b8e13f91db7ca33a7923"}, - {file = "coverage-7.3.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4a4184dcbe4f98d86470273e758f1d24191ca095412e4335ff27b417291f5964"}, - {file = "coverage-7.3.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:93698ac0995516ccdca55342599a1463ed2e2d8942316da31686d4d614597ef9"}, - {file = "coverage-7.3.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fb220b3596358a86361139edce40d97da7458412d412e1e10c8e1970ee8c09ab"}, - {file = "coverage-7.3.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d5b14abde6f8d969e6b9dd8c7a013d9a2b52af1235fe7bebef25ad5c8f47fa18"}, - {file = "coverage-7.3.4-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:610afaf929dc0e09a5eef6981edb6a57a46b7eceff151947b836d869d6d567c1"}, - {file = "coverage-7.3.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d6ed790728fb71e6b8247bd28e77e99d0c276dff952389b5388169b8ca7b1c28"}, - {file = "coverage-7.3.4-cp39-cp39-win32.whl", hash = "sha256:c15fdfb141fcf6a900e68bfa35689e1256a670db32b96e7a931cab4a0e1600e5"}, - {file = "coverage-7.3.4-cp39-cp39-win_amd64.whl", hash = "sha256:38d0b307c4d99a7aca4e00cad4311b7c51b7ac38fb7dea2abe0d182dd4008e05"}, - {file = "coverage-7.3.4-pp38.pp39.pp310-none-any.whl", hash = "sha256:b1e0f25ae99cf247abfb3f0fac7ae25739e4cd96bf1afa3537827c576b4847e5"}, - {file = "coverage-7.3.4.tar.gz", hash = "sha256:020d56d2da5bc22a0e00a5b0d54597ee91ad72446fa4cf1b97c35022f6b6dbf0"}, + {file = "coverage-7.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36b0ea8ab20d6a7564e89cb6135920bc9188fb5f1f7152e94e8300b7b189441a"}, + {file = "coverage-7.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0676cd0ba581e514b7f726495ea75aba3eb20899d824636c6f59b0ed2f88c471"}, + {file = "coverage-7.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d0ca5c71a5a1765a0f8f88022c52b6b8be740e512980362f7fdbb03725a0d6b9"}, + {file = "coverage-7.4.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a7c97726520f784239f6c62506bc70e48d01ae71e9da128259d61ca5e9788516"}, + {file = "coverage-7.4.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:815ac2d0f3398a14286dc2cea223a6f338109f9ecf39a71160cd1628786bc6f5"}, + {file = "coverage-7.4.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:80b5ee39b7f0131ebec7968baa9b2309eddb35b8403d1869e08f024efd883566"}, + {file = "coverage-7.4.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:5b2ccb7548a0b65974860a78c9ffe1173cfb5877460e5a229238d985565574ae"}, + {file = "coverage-7.4.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:995ea5c48c4ebfd898eacb098164b3cc826ba273b3049e4a889658548e321b43"}, + {file = "coverage-7.4.0-cp310-cp310-win32.whl", hash = "sha256:79287fd95585ed36e83182794a57a46aeae0b64ca53929d1176db56aacc83451"}, + {file = "coverage-7.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:5b14b4f8760006bfdb6e08667af7bc2d8d9bfdb648351915315ea17645347137"}, + {file = "coverage-7.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:04387a4a6ecb330c1878907ce0dc04078ea72a869263e53c72a1ba5bbdf380ca"}, + {file = "coverage-7.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ea81d8f9691bb53f4fb4db603203029643caffc82bf998ab5b59ca05560f4c06"}, + {file = "coverage-7.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:74775198b702868ec2d058cb92720a3c5a9177296f75bd97317c787daf711505"}, + {file = "coverage-7.4.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:76f03940f9973bfaee8cfba70ac991825611b9aac047e5c80d499a44079ec0bc"}, + {file = "coverage-7.4.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:485e9f897cf4856a65a57c7f6ea3dc0d4e6c076c87311d4bc003f82cfe199d25"}, + {file = "coverage-7.4.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6ae8c9d301207e6856865867d762a4b6fd379c714fcc0607a84b92ee63feff70"}, + {file = "coverage-7.4.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:bf477c355274a72435ceb140dc42de0dc1e1e0bf6e97195be30487d8eaaf1a09"}, + {file = "coverage-7.4.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:83c2dda2666fe32332f8e87481eed056c8b4d163fe18ecc690b02802d36a4d26"}, + {file = "coverage-7.4.0-cp311-cp311-win32.whl", hash = "sha256:697d1317e5290a313ef0d369650cfee1a114abb6021fa239ca12b4849ebbd614"}, + {file = "coverage-7.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:26776ff6c711d9d835557ee453082025d871e30b3fd6c27fcef14733f67f0590"}, + {file = "coverage-7.4.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:13eaf476ec3e883fe3e5fe3707caeb88268a06284484a3daf8250259ef1ba143"}, + {file = "coverage-7.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:846f52f46e212affb5bcf131c952fb4075b55aae6b61adc9856222df89cbe3e2"}, + {file = "coverage-7.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:26f66da8695719ccf90e794ed567a1549bb2644a706b41e9f6eae6816b398c4a"}, + {file = "coverage-7.4.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:164fdcc3246c69a6526a59b744b62e303039a81e42cfbbdc171c91a8cc2f9446"}, + {file = "coverage-7.4.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:316543f71025a6565677d84bc4df2114e9b6a615aa39fb165d697dba06a54af9"}, + {file = "coverage-7.4.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:bb1de682da0b824411e00a0d4da5a784ec6496b6850fdf8c865c1d68c0e318dd"}, + {file = "coverage-7.4.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:0e8d06778e8fbffccfe96331a3946237f87b1e1d359d7fbe8b06b96c95a5407a"}, + {file = "coverage-7.4.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a56de34db7b7ff77056a37aedded01b2b98b508227d2d0979d373a9b5d353daa"}, + {file = "coverage-7.4.0-cp312-cp312-win32.whl", hash = "sha256:51456e6fa099a8d9d91497202d9563a320513fcf59f33991b0661a4a6f2ad450"}, + {file = "coverage-7.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:cd3c1e4cb2ff0083758f09be0f77402e1bdf704adb7f89108007300a6da587d0"}, + {file = "coverage-7.4.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e9d1bf53c4c8de58d22e0e956a79a5b37f754ed1ffdbf1a260d9dcfa2d8a325e"}, + {file = "coverage-7.4.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:109f5985182b6b81fe33323ab4707011875198c41964f014579cf82cebf2bb85"}, + {file = "coverage-7.4.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3cc9d4bc55de8003663ec94c2f215d12d42ceea128da8f0f4036235a119c88ac"}, + {file = "coverage-7.4.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cc6d65b21c219ec2072c1293c505cf36e4e913a3f936d80028993dd73c7906b1"}, + {file = "coverage-7.4.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5a10a4920def78bbfff4eff8a05c51be03e42f1c3735be42d851f199144897ba"}, + {file = "coverage-7.4.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b8e99f06160602bc64da35158bb76c73522a4010f0649be44a4e167ff8555952"}, + {file = "coverage-7.4.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:7d360587e64d006402b7116623cebf9d48893329ef035278969fa3bbf75b697e"}, + {file = "coverage-7.4.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:29f3abe810930311c0b5d1a7140f6395369c3db1be68345638c33eec07535105"}, + {file = "coverage-7.4.0-cp38-cp38-win32.whl", hash = "sha256:5040148f4ec43644702e7b16ca864c5314ccb8ee0751ef617d49aa0e2d6bf4f2"}, + {file = "coverage-7.4.0-cp38-cp38-win_amd64.whl", hash = "sha256:9864463c1c2f9cb3b5db2cf1ff475eed2f0b4285c2aaf4d357b69959941aa555"}, + {file = "coverage-7.4.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:936d38794044b26c99d3dd004d8af0035ac535b92090f7f2bb5aa9c8e2f5cd42"}, + {file = "coverage-7.4.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:799c8f873794a08cdf216aa5d0531c6a3747793b70c53f70e98259720a6fe2d7"}, + {file = "coverage-7.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e7defbb9737274023e2d7af02cac77043c86ce88a907c58f42b580a97d5bcca9"}, + {file = "coverage-7.4.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a1526d265743fb49363974b7aa8d5899ff64ee07df47dd8d3e37dcc0818f09ed"}, + {file = "coverage-7.4.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bf635a52fc1ea401baf88843ae8708591aa4adff875e5c23220de43b1ccf575c"}, + {file = "coverage-7.4.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:756ded44f47f330666843b5781be126ab57bb57c22adbb07d83f6b519783b870"}, + {file = "coverage-7.4.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:0eb3c2f32dabe3a4aaf6441dde94f35687224dfd7eb2a7f47f3fd9428e421058"}, + {file = "coverage-7.4.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:bfd5db349d15c08311702611f3dccbef4b4e2ec148fcc636cf8739519b4a5c0f"}, + {file = "coverage-7.4.0-cp39-cp39-win32.whl", hash = "sha256:53d7d9158ee03956e0eadac38dfa1ec8068431ef8058fe6447043db1fb40d932"}, + {file = "coverage-7.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:cfd2a8b6b0d8e66e944d47cdec2f47c48fef2ba2f2dff5a9a75757f64172857e"}, + {file = "coverage-7.4.0-pp38.pp39.pp310-none-any.whl", hash = "sha256:c530833afc4707fe48524a44844493f36d8727f04dcce91fb978c414a8556cc6"}, + {file = "coverage-7.4.0.tar.gz", hash = "sha256:707c0f58cb1712b8809ece32b68996ee1e609f71bd14615bd8f87a1293cb610e"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index e55139dc..a4f21d08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mmpm" -version = "4.0.4" +version = "4.1.0" description = "MMPM, the MagicMirror Package Manager CLI simplifies the installation, removal, and general maintenance of MagicMirror packages" authors = [ { name = "Brandon Marlowe", email = "bpmarlowe-software@protonmail.com" }, @@ -13,7 +13,7 @@ dependencies = [ "colorama>=0.4.3", "flask-socketio>=5.3.2", "flask>=2.2.0", - "gevent>=22.10.0", + "gevent>=23.9.1", "gunicorn>=20.1.0", "jinja2>=3.1.0", "pygments>=2.12.0", diff --git a/ui/Dockerfile b/ui/Dockerfile deleted file mode 100644 index bf64e298..00000000 --- a/ui/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -# Use a multi-stage build to keep the final image as small as possible -FROM node:18 as build-stage - -WORKDIR /app - -# Copy package.json and install dependencies -COPY angular-app/package*.json ./ -RUN npm install - -# Copy the rest of the Angular app and build it -COPY . ./ -RUN rm -rf node_modules -RUN npm run build - -# Copy the built Angular app from the previous stage -COPY --from=build-stage /app/dist/ /app/angular-app - -# Expose the port the app runs on -EXPOSE 6789 - -# Start both the Angular app and the Python server -CMD ["sh", "-c", "cd angular-app && npx http-server"] - diff --git a/ui/src/app/components/log-stream-viewer/log-stream-viewer.component.ts b/ui/src/app/components/log-stream-viewer/log-stream-viewer.component.ts index 0624ac57..962470c9 100644 --- a/ui/src/app/components/log-stream-viewer/log-stream-viewer.component.ts +++ b/ui/src/app/components/log-stream-viewer/log-stream-viewer.component.ts @@ -74,7 +74,7 @@ export class LogStreamViewerComponent implements OnInit, OnDestroy { } public onDownload() { - this.base_api.get_zip_archive("logs/archive").then((archive: ArrayBuffer) => { + this.base_api.getZipArchive("logs/archive").then((archive: ArrayBuffer) => { const blob = new Blob([archive], { type: "application/zip" }); const date = new Date(); diff --git a/ui/src/app/services/api/base-api.ts b/ui/src/app/services/api/base-api.ts index a60d350b..3912b776 100644 --- a/ui/src/app/services/api/base-api.ts +++ b/ui/src/app/services/api/base-api.ts @@ -31,10 +31,10 @@ export class BaseAPI { public get_(endpoint: string): Promise { console.log(`Requesting data from ${endpoint}`); - return firstValueFrom(this.http.get(this.route(endpoint), { headers: this.headers() }).pipe(retry(1), catchError(this.handle_error))); + return firstValueFrom(this.http.get(this.route(endpoint), { headers: this.headers() }).pipe(retry(1), catchError(this.handleError))); } - public get_zip_archive(endpoint: string): Promise { + public getZipArchive(endpoint: string): Promise { return firstValueFrom( this.http .get(this.route(endpoint), { @@ -44,14 +44,14 @@ export class BaseAPI { reportProgress: true, responseType: "arraybuffer", }) - .pipe(retry(1), catchError(this.handle_error)), + .pipe(retry(1), catchError(this.handleError)), ); } - public handle_error(error: any): Promise { + public handleError(error: any): Promise { const error_message = error.error instanceof ErrorEvent ? error.error.message : `Error Code: ${error.status}\nMessage: ${error.message}`; console.log(error_message); - throw error_message; + return Promise.reject(new Error(error_message)); } } diff --git a/ui/src/app/services/api/config-file-api.service.ts b/ui/src/app/services/api/config-file-api.service.ts index 677a3600..6c5bce8e 100644 --- a/ui/src/app/services/api/config-file-api.service.ts +++ b/ui/src/app/services/api/config-file-api.service.ts @@ -15,7 +15,7 @@ export class ConfigFileAPI extends BaseAPI { headers: this.headers(), responseType: "text", }) - .pipe(retry(1), catchError(this.handle_error)), + .pipe(retry(1), catchError(this.handleError)), ); } @@ -35,7 +35,7 @@ export class ConfigFileAPI extends BaseAPI { }), }, ) - .pipe(retry(1), catchError(this.handle_error)), + .pipe(retry(1), catchError(this.handleError)), ); } } diff --git a/ui/src/app/services/api/magicmirror-controller-api.service.ts b/ui/src/app/services/api/magicmirror-controller-api.service.ts index 144e4b0e..aa1f227f 100644 --- a/ui/src/app/services/api/magicmirror-controller-api.service.ts +++ b/ui/src/app/services/api/magicmirror-controller-api.service.ts @@ -37,7 +37,7 @@ export class MagicMirrorControllerAPI extends BaseAPI { return typeof response === "string" ? JSON.parse(response) : response; }), retry(1), - catchError(this.handle_error), + catchError(this.handleError), ), ); } diff --git a/ui/src/app/services/api/magicmirror-package-api.service.ts b/ui/src/app/services/api/magicmirror-package-api.service.ts index 5a10e63d..95c61e95 100644 --- a/ui/src/app/services/api/magicmirror-package-api.service.ts +++ b/ui/src/app/services/api/magicmirror-package-api.service.ts @@ -15,7 +15,7 @@ export class MagicMirrorPackageAPI extends BaseAPI { return typeof response === "string" ? JSON.parse(response) : response; }), retry(1), - catchError(this.handle_error), + catchError(this.handleError), ), ); } @@ -27,7 +27,7 @@ export class MagicMirrorPackageAPI extends BaseAPI { return typeof response === "string" ? JSON.parse(response) : response; }), retry(1), - catchError(this.handle_error), + catchError(this.handleError), ), ); }