Make Sripthandler.add not fail if passed instantiated script. Resolve #3272
This commit is contained in:
parent
cf38de0922
commit
808bde0c7c
2 changed files with 10 additions and 3 deletions
|
|
@ -76,10 +76,14 @@ class ScriptHandler(object):
|
|||
script = create.create_script(
|
||||
scriptclass, key=key, account=self.obj, autostart=autostart
|
||||
)
|
||||
else:
|
||||
# adding to an Object. We wait to autostart so we can differentiate
|
||||
# a failing creation from a script that immediately starts/stops.
|
||||
elif isinstance(scriptclass, str) or callable(scriptclass):
|
||||
# a str or class to use create before adding to an Object. We wait to autostart
|
||||
# so we can differentiate a failing creation from a script that immediately starts/stops.
|
||||
script = create.create_script(scriptclass, key=key, obj=self.obj, autostart=False)
|
||||
else:
|
||||
# already an instantiated class
|
||||
script = scriptclass
|
||||
|
||||
if not script:
|
||||
logger.log_err(f"Script {scriptclass} failed to be created.")
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue