This manager entity handles script execution in the CSE.
| Method | __init__ |
Constructor for the ScriptManager class. |
| Method | check |
This is the callback for the monitor to look for new, updated or outdated scripts. |
| Method | config |
Callback for the configUpdate event. |
| Method | cron |
This is the callback for the cron scheduler. |
| Method | cse |
Callback for the cseStartup event. |
| Method | find |
Find scripts by a filter. |
| Method | get |
Returns the context for the given script name or None if not found. |
| Method | initialize |
Initializer for the ScriptManager class. |
| Method | load |
Load and initialize a script. If no name is set in the script itself, then the filename's stem is set as the name. |
| Method | load |
Load and store a script from a file. |
| Method | load |
Load all scripts from a (monitored) directory. |
| Method | on |
Callback for the keyboard event. |
| Method | on |
Callback for the notification event. |
| Method | remove |
Remove all scripts. |
| Method | restart |
Callback for the cseReset event. |
| Method | restart |
Callback for the cseRestarted event. |
| Method | run |
Run a script by its name (only in the foreground). |
| Method | run |
Run a comparison query against a JSON strcture or a resource. |
| Method | run |
Get and run all the scripts for specific events. |
| Method | run |
Run a script. |
| Method | shutdown |
Shutdown the ScriptManager. |
| Method | storage |
Retrieve a key/value pair from the persistent storage storage. |
| Method | storage |
Test whether a key exists in the persistent storage storageID. |
| Method | storage |
Store a key/value pair in the persistent storage identified by storage. Existing values will be overwritten. |
| Method | storage |
Remove a key/value pair from the persistent storage. |
| Method | storage |
Remove all key/value pairs from the persistent storage. |
| Class Variable | __slots__ |
Slots of class attributes. |
| Class Variable | importer |
Importer instance |
| Class Variable | text |
TextUI plugin, if available. |
| Class Variable | validator |
Validator instance. |
| Instance Variable | category |
Dictionary of category descriptions. |
| Instance Variable | script |
BackgroundWorker worker to run cron-enabled scripts. |
| Instance Variable | scripts |
Dictionary of scripts and script ACMEPContext. The key is the script name. |
| Instance Variable | script |
BackgroundWorker worker to monitor script directories. |
| Instance Variable | storage |
Dictionary for internal global variable storage. |
| Class Variable | _allowed |
Allowed symbols for comparison queries. |
This is the callback for the monitor to look for new, updated or outdated scripts.
| Returns | |
bool | Boolean. Usually True to continue with monitoring. |
Callback for the configUpdate event.
| Parameters | |
eventEventData | The event data, containing the updated configuration key. |
This is the callback for the cron scheduler.
It looks for scripts with an @at meta tag and takes the argument as a cron pattern. Scripts that are scheduled to run now will be run, one after the other.
| Returns | |
bool | Boolean. Usually True to continue with monitoring. |
str | None = None, meta: str | list[ str] | None = None, ignoreCase: bool = False) -> list[ PContext]:
¶
Find scripts by a filter.
Filters are and-combined.
| Parameters | |
name:str | None | Filter by script name. The name can be a simple match. |
meta:str | list[ | Filter by script meta data. This can be a single string or a list of strings. |
ignorebool | Undocumented |
| Returns | |
list[ | List of PContext objects with the script(s), sorted by name, or None in case of an error. |
Returns the context for the given script name or None if not found.
| Parameters | |
name:str | The name of the script. |
| Returns | |
PContext | None | The context for the given script name or None if not found. |
Load and initialize a script. If no name is set in the script itself, then the filename's stem is set as the name.
The script is stored in the scripts dictionary.
| Parameters | |
script:str | The script as a single string. |
filename:str | The filename of the file. |
| Returns | |
ACMEPContext | None | ACMEPContext object with the script, or None. |
Load and store a script from a file.
| Parameters | |
filename:str | The filename of the file. |
| Returns | |
ACMEPContext | None | ACMEPContext object with the script, or None. |
Load all scripts from a (monitored) directory.
| Parameters | |
directory:str | list[ | The directory from which to load the scripts. |
| Returns | |
int | Number scripts loaded, or -1 in case of an error. |
Callback for the keyboard event.
Run script(s) with configured meta tags, if any.
| Parameters | |
eventEventData | The event data, containing the pressed key. |
Callback for the notification event.
Run script(s) with configured meta tags, if any.
| Parameters | |
eventEventData | The event data, containing the notification information. The first element is the notification URI, the second element is the request that caused the notification. |
Callback for the cseReset event.
Restart the script manager service, ie. clear the scripts and storage. They are reloaded during import.
str, arguments: list[ str] | str | None = '', metaFilter: list[ str] | None = [], ignoreCase: bool | None = False) -> tuple[ bool, SSymbol]:
¶
Run a script by its name (only in the foreground).
| Parameters | |
scriptstr | The name of the script to run.. |
arguments:list[ | Optional arguments to the script. These are available to the script via the argv macro. |
metalist[ | Extra filter to select a script. |
ignorebool | None | Undocumented |
| Returns | |
tuple[ | The result of the script run in a tuple. Boolean indicating success, and an optional result. |
Run a comparison query against a JSON strcture or a resource.
The query consists of logical or comparison operations, and only those are allowed. It can contain attributes, which values are taken from the JSON structure or resource.
| Parameters | |
query:str | String with a valid s-expression. |
resource:JSON | Resource | JSON dictionary or resource for the attributes. |
| Returns | |
bool | Boolean value indicating the success of the query. |
str, eventData: str | None = None, background: bool | None = True, environment: dict[ str, SSymbol] | None = {}):
¶
Get and run all the scripts for specific events.
If the argument is given then the event's parameter must match the argument.
This method is still called in the same thread as the console (the event is raised not in the background!), because otherwise the prompt input and the getch() function from the console are mixing up.
| Parameters | |
event:str | The event for which the script(s) are run. |
eventstr | None | The optional event data that needs to match the event's pararmeter of the script. |
background:bool | None | Run the script in the background |
environment:dict[ | Extra variables to set in the script's environment |
PContext, arguments: list[ str] | str | None = '', background: bool | None = False, finished: Callable | None = None, environment: dict[ str, SSymbol] | None = {}) -> bool:
¶
Run a script.
| Parameters | |
pcontext:PContext | The script context to run. |
arguments:list[ | Optional arguments to the script. These are available to the script via the argv macro. |
background:bool | None | Boolean to indicate whether to run the script in the backhround (as an Actor). |
finished:Callable | None | An optional function that will be called after the script finished. |
environment:dict[ | An optional set of variables that are passed to the script. |
| Returns | |
bool | Boolean that indicates the successful running of the script. A background script always returns True. |
Retrieve a key/value pair from the persistent storage storage.
| Parameters | |
storage:str | Name or ID of the storage. |
key:str | Key for the value to retrieve. |
| Returns | |
SSymbol | None | Previously stored value for the key, or None. |
Test whether a key exists in the persistent storage storageID.
| Parameters | |
storage:str | Name or ID of the storage. |
key:str | Key to check. |
| Returns | |
bool | Boolean result. |
Store a key/value pair in the persistent storage identified by storage. Existing values will be overwritten.
- Args:
- storage: Name or ID of the storage. key: Key where to store the value. value: Value to store.
Remove a key/value pair from the persistent storage.
| Parameters | |
storage:str | Name or ID of the storage. |
key:str | Key where to store the value. |
Remove all key/value pairs from the persistent storage.
| Parameters | |
storage:str | Name or ID of the storage. |