From 939c0a0f44beda10fdce7d09a5183ed58be07471 Mon Sep 17 00:00:00 2001 From: Tasha Upchurch Date: Fri, 8 Dec 2023 11:14:11 -0500 Subject: [PATCH] changes to adhere to comfy-ui dyanamic web extensions --- __init__.py | 3 +- update_js.py | 76 ------------------- moviemain.js => web/moviemain.js | 0 ui_helpers.js => web/ui_helpers.js | 0 .../ui_modifications.js | 0 5 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 update_js.py rename moviemain.js => web/moviemain.js (100%) rename ui_helpers.js => web/ui_helpers.js (100%) rename ui_modifications.js => web/ui_modifications.js (100%) diff --git a/__init__.py b/__init__.py index c2f2b3c..f289ac5 100644 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,7 @@ import os import importlib - +WEB_DIRECTORY = "./web" +__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"] OLD_NODE_CLASS_MAPPINGS = { "Interpolation": "LatentInterpolation", "Image Pad To Match": "PadToMatch", diff --git a/update_js.py b/update_js.py deleted file mode 100644 index 58ddfe6..0000000 --- a/update_js.py +++ /dev/null @@ -1,76 +0,0 @@ -import os -import shutil -import getpass -from custom_nodes.EternalKernelLiteGraphNodes.local_shared import ETK_PATH, GDE_PATH - -import time - - -def set_file_mtime(file_path, mtime): - """ - Set the modified time of the file to the specified time. - - :param file_path: Path of the file to modify. - :param mtime: The new modified time as a timestamp (seconds since the epoch). - """ - atime = os.path.getatime(file_path) # keep the original access time - os.utime(file_path, (atime, mtime)) - - -def check_directory_permissions(directory): - if not os.path.exists(directory): - os.makedirs(directory) - elif not os.access(directory, os.R_OK | os.W_OK): - raise PermissionError(f"Insufficient permissions for directory {directory}") - - -def check_for_js_extension(): - web_ext_path = os.path.normpath(os.path.join(GDE_PATH, "web", "extensions", "etk")) - repo_file_path = os.path.join(ETK_PATH) - - # Check permissions for both directories - check_directory_permissions(web_ext_path) - check_directory_permissions(repo_file_path) - - for fn in ["ui_modifications.js", "ui_helpers.js"]: - - file_web_path = os.path.join(web_ext_path, fn) - file_repo_path = os.path.join(repo_file_path, fn) - - try: - file_web_date = os.path.getmtime(file_web_path) - except FileNotFoundError: - file_web_date = 0 - - try: - file_repo_date = os.path.getmtime(file_repo_path) - except FileNotFoundError: - raise FileNotFoundError( - f"File {file_repo_path} does not exist. Please check that the ETK_PATH is set correctly." - ) - - if file_web_date == file_repo_date: - print(f"Files are identical: {file_web_path} = {file_repo_path}") - continue - - if file_web_date > file_repo_date: - direction = "web -> repo" - from_file = file_web_path - to_file = file_repo_path - from_time = file_web_date - else: - direction = "repo -> web" - from_file = file_repo_path - to_file = file_web_path - from_time = file_repo_date - - print(f"Copying {direction}: {from_file} -> {to_file}") - shutil.copyfile(from_file, to_file) - set_file_mtime(to_file, from_time) - - -# Print the current user -current_user = getpass.getuser() -print(f"This script is being executed as user: {current_user}") - -check_for_js_extension() diff --git a/moviemain.js b/web/moviemain.js similarity index 100% rename from moviemain.js rename to web/moviemain.js diff --git a/ui_helpers.js b/web/ui_helpers.js similarity index 100% rename from ui_helpers.js rename to web/ui_helpers.js diff --git a/ui_modifications.js b/web/ui_modifications.js similarity index 100% rename from ui_modifications.js rename to web/ui_modifications.js