forked from Github/Axter-Stash
Change UI options
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# FileMonitor: Ver 0.8.8 (By David Maisonave)
|
||||
# FileMonitor: Ver 0.8.9 (By David Maisonave)
|
||||
FileMonitor is a [Stash](https://github.com/stashapp/stash) plugin with the following two main features:
|
||||
- Updates Stash when any file changes occurs in the Stash library.
|
||||
- **Task Scheduler**: Runs scheduled task based on the scheduler configuration in **filemonitor_config.py**.
|
||||
|
||||
@@ -172,6 +172,9 @@ class StashPluginHelper(StashInterface):
|
||||
super().__init__(self.FRAGMENT_SERVER)
|
||||
self.STASH_INTERFACE_INIT = True
|
||||
|
||||
if self.STASH_URL.startswith("http://0.0.0.0:"):
|
||||
self.STASH_URL = self.STASH_URL.replace("http://0.0.0.0:", "http://localhost:")
|
||||
|
||||
if self.STASH_INTERFACE_INIT:
|
||||
self.PLUGIN_CONFIGURATION = self.get_configuration()["plugins"]
|
||||
self.STASH_CONFIGURATION = self.get_configuration()["general"]
|
||||
|
||||
@@ -14,8 +14,10 @@ from filemonitor_task_examples import task_examples
|
||||
from filemonitor_self_unit_test import self_unit_test
|
||||
|
||||
config['task_scheduler'] = config['task_scheduler'] + task_examples['task_scheduler']
|
||||
if self_unit_test['selfUnitTest']:
|
||||
config['task_scheduler'] = config['task_scheduler'] + self_unit_test['task_scheduler']
|
||||
if self_unit_test['selfUnitTest_repeat']:
|
||||
config['task_scheduler'] = config['task_scheduler'] + self_unit_test['task_scheduler_repeat']
|
||||
if self_unit_test['selfUnitTest_set_time']:
|
||||
config['task_scheduler'] = config['task_scheduler'] + self_unit_test['task_scheduler_set_time']
|
||||
|
||||
CONTINUE_RUNNING_SIG = 99
|
||||
STOP_RUNNING_SIG = 32
|
||||
@@ -38,6 +40,7 @@ if parse_args.quit:
|
||||
settings = {
|
||||
"recursiveDisabled": False,
|
||||
"turnOnScheduler": False,
|
||||
"turnOnSchedulerDeleteDup": False,
|
||||
"zmaximumBackups": 1,
|
||||
"zzdebugTracing": False
|
||||
}
|
||||
@@ -82,6 +85,7 @@ if CREATE_SPECIAL_FILE_TO_EXIT and os.path.isfile(SPECIAL_FILE_NAME):
|
||||
fileExtTypes = stash.pluginConfig['fileExtTypes'].split(",") if stash.pluginConfig['fileExtTypes'] != "" else []
|
||||
includePathChanges = stash.pluginConfig['includePathChanges'] if len(stash.pluginConfig['includePathChanges']) > 0 else stash.STASH_PATHS
|
||||
excludePathChanges = stash.pluginConfig['excludePathChanges']
|
||||
turnOnSchedulerDeleteDup = stash.pluginSettings['turnOnSchedulerDeleteDup']
|
||||
|
||||
if stash.DRY_RUN:
|
||||
stash.Log("Dry run mode is enabled.")
|
||||
@@ -303,6 +307,9 @@ class StashScheduler: # Stash Scheduler
|
||||
if invalidDir:
|
||||
stash.Error(f"Could not run task '{task['task']}' because sub directory '{task['validateDir']}' does not exist under path '{stash.PLUGINS_PATH}'")
|
||||
else:
|
||||
if task['task'] == "Delete Duplicates" and not turnOnSchedulerDeleteDup:
|
||||
stash.Warn(f"Not running task {task['task']}, because [Delete Duplicate Scheduler] is NOT enabled. See Stash UI option Settings->Plugins->Plugins->FileMonitor->[Delete Duplicate Scheduler]")
|
||||
return None
|
||||
stash.Trace(f"Running plugin task pluginID={task['pluginId']}, task name = {task['task']}. {validDirMsg}")
|
||||
return stash.run_plugin_task(plugin_id=task['pluginId'], task_name=task['task'])
|
||||
else:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: FileMonitor
|
||||
description: Monitors the Stash library folders, and updates Stash if any changes occurs in the Stash library paths.
|
||||
version: 0.8.8
|
||||
version: 0.8.9
|
||||
url: https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/FileMonitor
|
||||
settings:
|
||||
recursiveDisabled:
|
||||
@@ -11,9 +11,13 @@ settings:
|
||||
displayName: Scheduler
|
||||
description: Enable to turn on the scheduler. See filemonitor_config.py for more details.
|
||||
type: BOOLEAN
|
||||
turnOnSchedulerDeleteDup:
|
||||
displayName: Delete Duplicate Scheduler
|
||||
description: Turn on scheduler for deleting duplicates in Stash library. (Requires plugin DupFileManager and [Scheduler] enabled)
|
||||
type: BOOLEAN
|
||||
zmaximumBackups:
|
||||
displayName: Max DB Backups
|
||||
description: When value greater than 1, will trim the number of database backup files to set value. Requires [Scheduler] enabled and backupDirectoryPath populated with path length longer than 4.
|
||||
description: Trim database backup files to set value. Requires [Scheduler] enabled and backupDirectoryPath path length longer than 4.
|
||||
type: NUMBER
|
||||
zzdebugTracing:
|
||||
displayName: Debug Tracing
|
||||
@@ -29,10 +33,10 @@ tasks:
|
||||
defaultArgs:
|
||||
mode: start_library_monitor_service
|
||||
- name: Stop Library Monitor
|
||||
description: Stops library monitoring within 2 minute.
|
||||
description: Stops library monitoring within 2 minutes.
|
||||
defaultArgs:
|
||||
mode: stop_library_monitor
|
||||
- name: Monitor as a Plugin
|
||||
description: Run [Library Monitor] as a plugin (*not recommended method*)
|
||||
description: Run [Library Monitor] as a plugin (*Not recommended*)
|
||||
defaultArgs:
|
||||
mode: start_library_monitor
|
||||
|
||||
@@ -17,6 +17,9 @@ config = {
|
||||
# Task "Create Tags" is a plugin task. All plugin task have a REQUIRED pluginId field and an optional validateDir field. For detail usage, see examples #B1 and #B2 in filemonitor_task_examples.py
|
||||
{"task" : "Create Tags", "pluginId" : "pathParser", "validateDir" : "pathParser",
|
||||
"weekday" : "monday,tuesday,wednesday,thursday,friday,saturday,sunday", "time" : "05:30"}, # [Plugin Tasks] - > [Path Parser] -> [Create Tags] (Daily at 5AM) : This task requires plugin [Path Parser]
|
||||
# The following task runs plugin DupFileManager if the plugin is installed.
|
||||
{"task" : "Tag Duplicates", "pluginId" : "DupFileManager", "validateDir" : "DupFileManager",
|
||||
"weekday" : "monday,tuesday,wednesday,thursday,friday,saturday,sunday", "time" : "02:30"}, # [Plugin Tasks] -> DupFileManager -> [Delete Duplicates] (Daily at 2:30AM)
|
||||
{"task" : "Optimise Database", "weekday" : "monday,tuesday,wednesday,thursday,friday", "time" : "07:00"}, # Maintenance -> [Optimise Database] (Every weekday at 7AM)
|
||||
|
||||
# The following tasks are scheduled weekly
|
||||
@@ -27,9 +30,6 @@ config = {
|
||||
{"task" : "Clean", "weekday" : "saturday", "time" : "04:30"}, # Maintenance -> [Clean] (Every saturday at 4:30AM)
|
||||
{"task" : "Clean Generated Files", "weekday" : "saturday", "time" : "05:00"}, # Maintenance -> [Clean Generated Files] (Every saturday at 5AM)
|
||||
{"task" : "Optimise Database", "weekday" : "saturday", "time" : "05:30"}, # Maintenance -> [Optimise Database] (Every saturday at 5:30AM)
|
||||
# The following task runs plugin DupFileManager if the plugin is installed.
|
||||
{"task" : "Delete Duplicates", "pluginId" : "DupFileManager", "validateDir" : "DupFileManager",
|
||||
"weekday" : "saturday", "time" : "02:30"}, # [Plugin Tasks] -> DupFileManager -> [Delete Duplicates] (Every saturday at 2:30AM)
|
||||
|
||||
# To perform a task monthly, specify the day of the month as in the weekly schedule format, and add a monthly field.
|
||||
# The monthly field value must be 1, 2, 3, or 4.
|
||||
@@ -40,6 +40,9 @@ config = {
|
||||
# The Backup task is scheduled monthly
|
||||
# Optional field for task "Backup" is maxBackup. For detail usage, see example #A5 in filemonitor_task_examples.py
|
||||
{"task" : "Backup", "weekday" : "sunday", "time" : "01:00", "monthly" : 2}, # Backup -> [Backup] 2nd sunday of the month at 1AM (01:00)
|
||||
# The following task requires plugin DupFileManager and UI option [Delete Duplicate Scheduler] enabled.
|
||||
{"task" : "Delete Duplicates", "pluginId" : "DupFileManager", "validateDir" : "DupFileManager",
|
||||
"weekday" : "sunday", "time" : "02:00", "monthly" : 2}, # [Plugin Tasks] -> DupFileManager -> [Delete Duplicates] 2nd sunday of the month at 2AM (02:00)
|
||||
|
||||
# The [CheckStashIsRunning] task checks if Stash is running. If not running, it will start up stash.
|
||||
# This task only works if FileMonitor is started as a service or in command line mode.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# These tasks are usually executed before updating major releases on https://github.com/David-Maisonave/Axter-Stash/blob/main/plugins/FileMonitor
|
||||
# These tasks are ALWAYS executed before updating to https://github.com/stashapp/CommunityScripts
|
||||
self_unit_test = {
|
||||
"task_scheduler": [
|
||||
"task_scheduler_repeat": [
|
||||
{"task" : "TestBadTaskNameError", "minutes" : 1}, # Test invalid task name
|
||||
{"task" : "execute", "minutes" : 1}, # Test invalid task (missing command)
|
||||
{"task" : "python", "minutes" : 1}, # Test invalid task (missing scripts)
|
||||
@@ -17,27 +17,30 @@ self_unit_test = {
|
||||
{"task" : "Trace", "minutes" : 1}, # Test plugin trace logging
|
||||
{"task" : "LogOnce", "seconds" :15}, # Test LogOnce
|
||||
{"task" : "TraceOnce", "seconds" : 5}, # Test TraceOnce
|
||||
# {"task" : "CheckStashIsRunning", "RunAfter" : [{"task" : "Scan"}], "seconds" :15}, # To test CheckStashIsRunning, kill Stash after starting FileMonitor service via following command:taskkill /F /IM "stash-win.exe"
|
||||
{"task" : "CheckStashIsRunning", "RunAfter" : [{"task" : "Scan"},{"task" : "Backup", "maxBackup" : 0},{"task" : "Clean"}], "seconds" :15}, # Test RunAfter
|
||||
{"task" : "CheckStashIsRunning", "command" : "<stash_path>stash-win.exe", "seconds" :10}, # Check if Stash is running. If not running, start up Stash.
|
||||
{"task" : "Generate", "weekday" : "friday", "time" : "12:03"},
|
||||
{"task" : "Clean", "weekday" : "friday", "time" : "12:03"},
|
||||
{"task" : "Auto Tag", "weekday" : "friday", "time" : "12:03"},
|
||||
{"task" : "Optimise Database", "weekday" : "friday", "time" : "12:03"},
|
||||
{"task" : "Create Tags", "pluginId" : "pathParser", "validateDir" : "pathParser", "weekday" : "friday", "time" : "12:03"}, # In task queue as -> Running plugin task: Create Tags
|
||||
{"task" : "Delete Duplicates", "pluginId" : "DupFileManager", "validateDir" : "DupFileManager","weekday" : "friday", "time" : "12:03"}, # [Plugin Tasks] -> DupFileManager -> [Delete Duplicates]
|
||||
{"task" : "Scan","paths": [r"B:\_\SpecialSet", r"C:\foo"], "weekday" : "friday", "time" : "12:03"},
|
||||
{"task" : "GQL", "input" : "mutation OptimiseDatabase { optimiseDatabase }", "weekday" : "friday", "time" : "12:03"}, # In task queue as -> Optimising database...
|
||||
{"task" : "Clean Generated Files", "weekday" : "friday", "time" : "12:03"},
|
||||
{"task" : "RenameGeneratedFiles", "weekday" : "friday", "time" : "12:03"}, # In task queue as -> Migrating scene hashes...
|
||||
{"task" : "Backup", "maxBackups" : 0, "weekday" : "friday", "time" : "12:03"}, # Does NOT show up in the Task Queue. Must check STASH log file to verify run.
|
||||
{"task" : "python", "script" : "<plugin_path>test_hello_world2.py", "weekday" : "friday", "time" : "12:03"}, # Does NOT show up in the Task Queue. Check FileMonitor log file, and look for -> Task 'python' result=???
|
||||
{"task" : "python", "script" : "<plugin_path>test_hello_world.py", "detach" : False, "weekday" : "friday", "time" : "12:03"}, # Does NOT show up in the Task Queue. Check FileMonitor log file, and look for -> Task 'python' result=???
|
||||
{"task" : "execute", "command" : "<plugin_path>test_hello_world2.cmd", "weekday" : "friday", "time" : "12:03"}, # Does NOT show up in the Task Queue. Check FileMonitor log file, and look for -> Task 'execute' result=???
|
||||
{"task" : "execute", "command" : "<plugin_path>test_hello_world.bat", "args" : "--name David", "weekday" : "friday", "time" : "12:03"}, # Does NOT show up in the Task Queue. Check FileMonitor log file, and look for -> Task 'execute' result=???
|
||||
{"task" : "CheckStashIsRunning", "command" : "<stash_path>stash-win.exe", "seconds" :10}, # Check if Stash is running. If not running, start up Stash.
|
||||
# {"task" : "CheckStashIsRunning", "RunAfter" : [{"task" : "Scan"}], "seconds" :15}, # To test CheckStashIsRunning, kill Stash after starting FileMonitor service via following command:taskkill /F /IM "stash-win.exe"
|
||||
],
|
||||
|
||||
"task_scheduler_set_time": [
|
||||
# Test [Delete Duplicates] with [Delete Duplicate Scheduler] disabled, and then with it enabled.
|
||||
{"task" : "Delete Duplicates", "pluginId" : "DupFileManager", "validateDir" : "DupFileManager","weekday" : "sunday", "time" : "17:56"}, # [Plugin Tasks] -> DupFileManager -> [Delete Duplicates]
|
||||
{"task" : "Generate", "weekday" : "sunday", "time" : "17:56"},
|
||||
{"task" : "Clean", "weekday" : "sunday", "time" : "17:56"},
|
||||
{"task" : "Auto Tag", "weekday" : "sunday", "time" : "17:56"},
|
||||
{"task" : "Optimise Database", "weekday" : "sunday", "time" : "17:56"},
|
||||
{"task" : "Create Tags", "pluginId" : "pathParser", "validateDir" : "pathParser", "weekday" : "sunday", "time" : "17:56"}, # In task queue as -> Running plugin task: Create Tags
|
||||
{"task" : "Tag Duplicates", "pluginId" : "DupFileManager", "validateDir" : "DupFileManager", "weekday" : "sunday", "time" : "17:56"}, # [Plugin Tasks] -> DupFileManager -> [Tag Duplicates]
|
||||
{"task" : "Scan","paths": [r"B:\_\SpecialSet", r"C:\foo"], "weekday" : "sunday", "time" : "17:56"},
|
||||
{"task" : "GQL", "input" : "mutation OptimiseDatabase { optimiseDatabase }", "weekday" : "sunday", "time" : "17:56"}, # In task queue as -> Optimising database...
|
||||
{"task" : "Clean Generated Files", "weekday" : "sunday", "time" : "17:56"},
|
||||
{"task" : "RenameGeneratedFiles", "weekday" : "sunday", "time" : "17:56"}, # In task queue as -> Migrating scene hashes...
|
||||
{"task" : "Backup", "maxBackups" : 0, "weekday" : "sunday", "time" : "17:56"}, # Does NOT show up in the Task Queue. Must check STASH log file to verify run.
|
||||
{"task" : "python", "script" : "<plugin_path>test_hello_world2.py", "weekday" : "sunday", "time" : "17:56"}, # Does NOT show up in the Task Queue. Check FileMonitor log file, and look for -> Task 'python' result=???
|
||||
{"task" : "python", "script" : "<plugin_path>test_hello_world.py", "detach" : False, "weekday" : "sunday", "time" : "17:56"}, # Does NOT show up in the Task Queue. Check FileMonitor log file, and look for -> Task 'python' result=???
|
||||
{"task" : "execute", "command" : "<plugin_path>test_hello_world2.cmd", "weekday" : "sunday", "time" : "17:56"}, # Does NOT show up in the Task Queue. Check FileMonitor log file, and look for -> Task 'execute' result=???
|
||||
{"task" : "execute", "command" : "<plugin_path>test_hello_world.bat", "args" : "--name David", "weekday" : "sunday", "time" : "17:56"}, # Does NOT show up in the Task Queue. Check FileMonitor log file, and look for -> Task 'execute' result=???
|
||||
],
|
||||
# MUST ToDo: Always set selfUnitTest to False before checking in this code!!!
|
||||
# Enable to turn on self unit test.
|
||||
"selfUnitTest": False,
|
||||
"selfUnitTest_repeat" : False , # Enable to turn on self unit test.
|
||||
"selfUnitTest_set_time" : False , # Enable to turn on self unit test.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user