add before process callback

This commit is contained in:
Vladimir Mandic
2023-09-17 10:16:33 -04:00
parent e0c8d37d5e
commit 4887b0a631
2 changed files with 27 additions and 0 deletions
+25
View File
@@ -67,6 +67,20 @@ class Script:
"""
pass # pylint: disable=unnecessary-pass
def setup(self, p, *args):
"""For AlwaysVisible scripts, this function is called when the processing object is set up, before any processing starts.
args contains all values returned by components from ui().
"""
pass
def before_process(self, p, *args):
"""
This function is called very early during processing begins for AlwaysVisible scripts.
You can modify the processing object (p) here, inject hooks, etc.
args contains all values returned by components from ui()
"""
pass
def process(self, p, *args):
"""
This function is called before processing begins for AlwaysVisible scripts.
@@ -437,6 +451,17 @@ class ScriptRunner:
s.report()
return processed
def before_process(self, p, **kwargs):
s = ScriptSummary('before-process')
for script in self.alwayson_scripts:
try:
script_args = p.script_args[script.args_from:script.args_to]
script.before_process(p, *script_args, **kwargs)
except Exception as e:
errors.display(e, f"Error running before process: {script.filename}")
s.record(script.title())
s.report()
def process(self, p, **kwargs):
s = ScriptSummary('process')
for script in self.alwayson_scripts: