diff --git a/Dev/index.yml b/Dev/index.yml index e119ca0..18a759b 100644 --- a/Dev/index.yml +++ b/Dev/index.yml @@ -11,10 +11,10 @@ name: FileMonitor metadata: description: Monitors the Stash library folders, and updates Stash if any changes occurs in the Stash library paths. - version: 1.0.0 + version: 1.0.1 date: 2024-12-26 13:00:00 path: filemonitor.zip - sha256: e0b3f9c526593590adccf6c004fac63868abb517641a7e0ac049ab2b06bd51ec + sha256: 8800b061f0e2bb7f5f42a91eb1a27efef4f6b823739162c67380feb21d9a395d - id: renamefile name: RenameFile diff --git a/Docker/CreateContainer.cmd b/Docker/CreateContainer.cmd index afc2ea7..74832f0 100644 --- a/Docker/CreateContainer.cmd +++ b/Docker/CreateContainer.cmd @@ -25,7 +25,7 @@ set SharedMountPath2=%5 set SharedMountPath3=%6 set SharedMountPath4=%7 set SharedMountPath5=%8 -set VariableArg=%9 +set SharedMountPath6=%9 set SkipDockerCompose= set DLNAFunctionality="no" set PullDockerStashImage= @@ -54,16 +54,16 @@ if /I [%SharedMountPath5%]==[SKIP] (set SkipDockerCompose=yes) & (set SharedMou if /I [%SharedMountPath5%]==[IMAGE] (set PullDockerStashImage=yes) & (set SharedMountPath5=) if /I [%SharedMountPath5%]==[PULL] (set PullDockerStashImage=yes) & (set SharedMountPath5=) if /I [%SharedMountPath5%]==[WRITE] (set MountAccess=) & (set SharedMountPath5=) -if /I [%VariableArg%]==[DLNA] (set DLNAFunctionality=yes) -if /I [%VariableArg%]==[SKIP] (set SkipDockerCompose=yes) -if /I [%VariableArg%]==[IMAGE] (set PullDockerStashImage=yes) -if /I [%VariableArg%]==[PULL] (set PullDockerStashImage=yes) -if /I [%VariableArg%]==[WRITE] (set MountAccess=) +if /I [%SharedMountPath6%]==[DLNA] (set DLNAFunctionality=yes) & (set SharedMountPath6=) +if /I [%SharedMountPath6%]==[SKIP] (set SkipDockerCompose=yes) & (set SharedMountPath6=) +if /I [%SharedMountPath6%]==[IMAGE] (set PullDockerStashImage=yes) & (set SharedMountPath6=) +if /I [%SharedMountPath6%]==[PULL] (set PullDockerStashImage=yes) & (set SharedMountPath6=) +if /I [%SharedMountPath6%]==[WRITE] (set MountAccess=) & (set SharedMountPath6=) :: If user incorrectly enters below arguments instead of Stash-Port, fetch the values, and let CHECK_STASH_PORT get the required Stash-Port. -if /I [%STASH_PORT%]==[DLNA] (set DLNAFunctionality=yes) & (set SharedMountPath=) -if /I [%STASH_PORT%]==[SKIP] (set SkipDockerCompose=yes) & (set SharedMountPath=) -if /I [%STASH_PORT%]==[IMAGE] (set PullDockerStashImage=yes) & (set SharedMountPath=) -if /I [%STASH_PORT%]==[PULL] (set PullDockerStashImage=yes) & (set SharedMountPath=) +if /I [%STASH_PORT%]==[DLNA] (set DLNAFunctionality=yes) & (set STASH_PORT=) +if /I [%STASH_PORT%]==[SKIP] (set SkipDockerCompose=yes) & (set STASH_PORT=) +if /I [%STASH_PORT%]==[IMAGE] (set PullDockerStashImage=yes) & (set STASH_PORT=) +if /I [%STASH_PORT%]==[PULL] (set PullDockerStashImage=yes) & (set STASH_PORT=) echo SkipDockerCompose = %SkipDockerCompose% ; DLNAFunctionality = %DLNAFunctionality% set DockerComposeFile="docker-compose.yml" @@ -71,14 +71,14 @@ if [%NewContainerName%]==[] goto :MissingArgumentNewContainerName goto :HaveVariableNewContainerName :MissingArgumentNewContainerName set /p NewContainerName="Enter the new container name: " -if [%NewContainerName%]==[] goto :eof +if [%NewContainerName%]==[] call:ExitWithError 160 "ERROR_BAD_ARGUMENTS" :HaveVariableNewContainerName if [%Image%]==[] goto :MissingArgumentImage goto :HaveVariableImage :MissingArgumentImage set /p Image="Enter the image name: " -if [%Image%]==[] goto :eof +if [%Image%]==[] call:ExitWithError 160 "ERROR_BAD_ARGUMENTS" :HaveVariableImage :CHECK_STASH_PORT @@ -91,7 +91,7 @@ echo Argument #3 requires a numeric value for Stash-Port. You entered "%STASH_P :MissingArgumentSTASH_PORT set STASH_PORT= set /p STASH_PORT="Enter the Stash port number: " -if [%STASH_PORT%]==[] Goto :eof +if [%STASH_PORT%]==[] call:ExitWithError 160 "ERROR_BAD_ARGUMENTS" goto :CHECK_STASH_PORT :HaveVariableSTASH_PORT @@ -149,6 +149,8 @@ if [%SharedMountPath4%]==[] goto :SkipSharedMountPaths echo - %SharedMountPath4%:/external4%MountAccess%>> %DockerComposeFile% if [%SharedMountPath5%]==[] goto :SkipSharedMountPaths echo - %SharedMountPath5%:/external5%MountAccess%>> %DockerComposeFile% +if [%SharedMountPath6%]==[] goto :SkipSharedMountPaths +echo - %SharedMountPath6%:/external5%MountAccess%>> %DockerComposeFile% :SkipSharedMountPaths if [%SkipDockerCompose%] NEQ [] goto :DoNot_DockerCompose @@ -158,4 +160,9 @@ docker pull %Image% docker-compose up -d :DoNot_DockerCompose cd .. +Goto :eof +:ExitWithError +Echo Error: Exiting with error code %1 and error message %2 +Exit %~1 +Goto :eof diff --git a/plugins/FileMonitor/ModulesValidate.py b/plugins/FileMonitor/ModulesValidate.py index 4de2f3a..7943d4d 100644 --- a/plugins/FileMonitor/ModulesValidate.py +++ b/plugins/FileMonitor/ModulesValidate.py @@ -9,6 +9,7 @@ # To test, uninstall packages via command line: pip uninstall -y watchdog schedule requests import sys, os, pathlib, platform, traceback # ToDo: Add logic to optionally pull package requirements from requirements.txt file. +# Add logic to report error sys.exit(126) -- 126 (0x7E) ERROR_MOD_NOT_FOUND: The specified module could not be found. def modulesInstalled(moduleNames, install=True, silent=False): retrnValue = True diff --git a/plugins/FileMonitor/filemonitor.py b/plugins/FileMonitor/filemonitor.py index 4a39c4b..cc5a09a 100644 --- a/plugins/FileMonitor/filemonitor.py +++ b/plugins/FileMonitor/filemonitor.py @@ -111,6 +111,9 @@ dockerMapVolumes = {} dockerReverseMapVolumes = {} dockerObservedPaths = {} if not parse_args.docker == None and len(parse_args.docker) > 0: + if stash.IS_DOCKER: + stash.Error("You are running this script from within Docker. This is NOT supported. Run this script in the host machine instead. Performing early exit due to unsupported action.") + sys.exit(50) # ERROR_NOT_SUPPORTED: The request is not supported. stash.Log(f"Docker compose YML file = {parse_args.docker}") ModulesValidate.modulesInstalled(["pyyaml"], silent=True) import yaml @@ -140,6 +143,13 @@ if not parse_args.docker == None and len(parse_args.docker) > 0: tb = traceback.format_exc() stash.Error(f"Exception while parsing Docker file {parse_args.docker}; Error: {e}\nTraceBack={tb}") +if stash.IS_DOCKER: + stash.Error("You are running this script from within Docker. This is NOT supported. Run this script in the host machine instead.") + stash.Warn("For more information on running FileMonitor on host machine see following link:\n https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/FileMonitor#Docker") + stash.Warn("Performing early exit because FileMonitor has to run on the host machine, and can NOT run on Docker directly.") + sys.exit(10) # ERROR_BAD_ENVIRONMENT: The environment is incorrect. + # Alternate error: sys.exit(160) # ERROR_BAD_ARGUMENTS: One or more arguments are not correct. + if stash.DRY_RUN: stash.Log("Dry run mode is enabled.") stash.Trace(f"(SCAN_MODIFIED={SCAN_MODIFIED}) (SCAN_ON_ANY_EVENT={SCAN_ON_ANY_EVENT}) (RECURSIVE={RECURSIVE})") diff --git a/plugins/RenameFile/renamefile.py b/plugins/RenameFile/renamefile.py index e47740b..e620fcd 100644 --- a/plugins/RenameFile/renamefile.py +++ b/plugins/RenameFile/renamefile.py @@ -473,7 +473,7 @@ def rename_files_task(): all_scenes = scene_result['allScenes'] if not all_scenes: stash.Error("No scenes found.") - exit() + sys.exit(13) # Find the scene with the latest updated_at timestamp latest_scene = max(all_scenes, key=lambda scene: scene['updated_at']) # Extract the ID of the latest scene