Module: base¶
Classes in the base module are only accessible from Python applications.
Application¶
-
class
base.
Application
(run=True)¶ This is the main application object in the server. There can only be once instance of this object. The default constructor returns the instance of this object.
-
registerScheduledTask
(fn, seconds=0, minutes=0, hours=0, days=0, runAtOnce=False, strictInterval=False, args=None, kwargs=None)¶ Register a semi regular scheduled task to run at a predefined interval. All calls will be made by the main thread.
Parameters: - func (func) – The function to be called.
- seconds (integer) – The interval in seconds. Optional.
- minutes (integer) – The interval in minutes. Optional.
- hours (integer) – The interval in hours. Optional.
- days (integer) – The interval in days. Optional.
- runAtOnce (bool) – If the function should be called right away or wait one interval?
- strictInterval (bool) – Set this to True if the interval should be strict. That means if the interval is set to 60 seconds and it was run ater 65 seconds the next run will be in 55 seconds.
- args (list) – Any args to be supplied to the function. Supplied as *args.
- kwargs (dict) – Any keyworded args to be supplied to the function. Supplied as **kwargs.
Note
The interval in which this task is run is not exact and can be delayed one minute depending on the server load.
Note
Calls to this method are threadsafe.
-
static
defaultContext
()¶ Returns: the default context used by the application
-
queue
(func, *args, **kwargs)¶ Queue a function to be executed later. All tasks in this queue will be run by the main thread. This is a thread safe function and can safely be used to syncronize with the main thread
Returns: True if the task was queued Returns: False if the server is shutting down
-
registerShutdown
(func)¶ Register shutdown method. The method func will be called the the server shuts down. Use this to clean up resources on shutdown.
Parameters: func (func) – A function callback to call when the server shuts down
-
static
signal
(msg, *args, **kwargs)¶ Send a global signal to registered slots. It is not recommended to call this method directly but instead use the signal decorator. Any extra parameters supplied will be forwarded to the slot.
Parameters: msg (str) – The signal name
-
-
@
base.
mainthread
¶ This decorator forces a method to be run in the main thread regardless of which thread calls the method.
Configurations¶
-
@
base.
configuration
¶ This decorator should be applied on the Plugin class to add configuration values. Configuration values will be exposed automatically to the user.
Example:
@configuration( companyName = ConfigurationString( defaultValue='Telldus Technologies', title='Company Name', description='Name of the Company' ), ) class MyPlugin(Plugin): pass
-
class
base.
ConfigurationValue
(valueType, defaultValue, writable=True, readable=True, hidden=False, sortOrder=0)¶ Base class for configuration values. Do not use this class directly but use one of the subclasses instead.
Changed in version 1.2: Added parameter sortOrder
Parameters: - valueType (str) – The type of the configuration value. Only set this in subclasses..
- defaultValue (str) – The default value used if not value is set.
- writable (bool) – If this value can be set by the user in the UI.
- readable (bool) – True if the current value could be read by user interfaces. Set this to False for fields such as password where the current value should not be exposed to the UI.
- hidden (bool) – If this field should be user configurable in the UI or not.
- sortOrder (int) – The order the values should be sorted by in the UI.
-
class
base.
ConfigurationBool
(defaultValue=False)¶ Configuration class used to store boolean values
New in version 1.2.
-
class
base.
ConfigurationDict
(defaultValue={})¶ Configuration class used to store dictionaries
-
class
base.
ConfigurationNumber
(defaultValue=0)¶ Configuration class used to store numbers
-
class
base.
ConfigurationList
(defaultValue=[])¶ Configuration class used to store lists
-
class
base.
ConfigurationSelect
(defaultValue='', options={})¶ Configuration class used to store one value out of a predefined selection
New in version 1.2.
-
class
base.
ConfigurationString
(defaultValue='', minLength=0, maxLength=0)¶ Configuration class used to store strings
Signals & Slots¶
-
class
base.
ISignalObserver
¶ Bases:
base.Plugin.IInterface
Implement this IInterface to recieve signals using the decorator
@slot
-
@
base.
signal
¶ This is a decorator for sending signals. Decorate any of your Plugins methods with this decorator and whenever the method is called the signal will be fired.
Parameters: name (str) – The signal name. This can be omitted and then the function name will be used as the name of the signal.
-
@
base.
slot
(message = '')¶ This is a decorator for receiveing signals. The class must implement
base.ISignalObserver
Parameters: message (str) – This is the signal name to receive