Backend Source-code

LoggerPlugin.py

jsonsocket.py

class Client[source]

Bases: object

A JSON socket client used to communicate with a JSON socket server. All the data is serialized in JSON. How to use it:

Parameters:keyword (str or None) – Set a keyword for encrypted communication. Leaf blank for unsecure connection. (default: None)
close()[source]

Close the client-socket. Do this at the end of every single communication!

connect(host, port, keyword=None, reuse_port=True, timeout=5)[source]

Establish a connection to a host (server)

Parameters:
  • host (str) – Hostname (e.g. 0.0.0.0)
  • port (int) – Port to bind tcp-socket (e.g. 5050)
  • keyword (str or None) – Set a keyword for encrypted communication. Leaf blank for unsecure connection. (default: None)
  • reuse_port (bool) – Enable/disable reuse_port (default: True)
recv()[source]

Receives a dict from server

Returns:The dict sent by the connected server
Return type:data (dict)
recv_and_close()[source]

Receives a dict from server and closes connection.

Returns:The dict sent by the connected server
Return type:data (dict)
send(data)[source]

Send a dict to the connected server

Parameters:data (dict) – The dict you want to transmit.
setKeyword(keyword=None)[source]

Set a keyword to protect the tcp communication.

Parameters:keyword (str or None) – A save passcode or None to disable protection
exception NoPasswordProtectionError(expression, message)[source]

Bases: exceptions.Exception

Raised when a password was provided, but server has no protectionAttributes.

expression -- input expression in which the error occurred
message -- explanation of the error
exception PasswordProtectedError(expression, message)[source]

Bases: exceptions.Exception

Raised when the server may be password protected.

expression -- input expression in which the error occurred
message -- explanation of the error
class Server(host, port, keyword=None, reuse_port=True, timeout=5)[source]

Bases: object

A JSON socket server used to communicate with a JSON socket client. All the data is serialized in JSON.

Parameters:
  • host (str) – Hostname (e.g. 0.0.0.0)
  • port (int) – Port to bind tcp-socket (e.g. 5050)
  • keyword (str or None) – Set a keyword for encrypted communication. Leaf blank for unsecure connection. Note: This will not encrypt host-intern-communication. (default: None)
  • reuse_port (bool) – Enable/disable reuse_port (default: True)
accept()[source]

Accept a new client connection

Returns:client
close()[source]

Close the server-socket. Do this at the very end of your communication!

recv()[source]

Receives a dict from client

Returns:The dict sent by the connected client
Return type:data (dict)
send(data)[source]

Send a dict to the connected client

Parameters:data (dict) – The dict you want to transmit.
setKeyword(keyword=None)[source]

Set a keyword to protect the tcp communication.

Parameters:keyword (str or None) – A save passcode or None to disable protection
exception WrongPasswordError(expression, message)[source]

Bases: exceptions.Exception

Raised when the password is wrong.

expression -- input expression in which the error occurred
message -- explanation of the error
deserializeJSON(json_bytes)[source]
pad(text, padding=16)[source]
readBlock(socket, blockLength)[source]

RTOC.RTLogger Submodules

RTOC.RTLogger.Daemon module

Generic linux daemon base class for python 3.x.

Source: https://web.archive.org/web/20160320091458/http://www.jejik.com/files/examples/daemon3x.py

class Daemon(pidfile)[source]

A generic daemon class.

Usage: subclass the daemon class and override the run() method.

daemonize()[source]

Deamonize class. UNIX double fork mechanism.

delpid()[source]
restart()[source]

Restart the daemon.

run()[source]

You should override this method when you subclass Daemon.

It will be called after the process has been daemonized by start() or restart().

start()[source]

Start the daemon.

stop()[source]

Stop the daemon.

RTOC.RTLogger.DeviceFunctions module

RTOC.RTLogger.EventActionFunctions module

class EventActionFunctions[source]

This class contains all global event/action-specific functions of RTLogger

addGlobalAction(name='testAction', listenID='testID', script='', parameters='', active=True)[source]
addGlobalEvent(name='testEvent', cond='', text='TestEvent', priority=0, retur='', id='testID', trigger='rising', sname='', dname='', active=True)[source]
checkGlobalActions(actions)[source]

Checks if actions are valid. Will add the key ‘errors’ to each event. ‘errors’ will be True, if it’s not valid.

Parameters:actions (dict) – actions to be checked.
Returns:Input-actions + ‘errors’-key
Return type:actions (dict)
checkGlobalEvents(events)[source]

Checks if events are valid. Will add the key ‘errors’ to each event. ‘errors’ will be True, if it’s not valid.

Parameters:events (dict) – events to be checked.
Returns:Input-events + ‘errors’-key
Return type:events (dict)
loadGlobalActions()[source]

Loads global actions from file and stores them in dict ‘self.globalActions’

loadGlobalEvents()[source]

Loads global events from file and stores them in dict ‘self.globalEvents’

performGlobalActions(id, value)[source]
performGlobalEvents(y, unit, devicename, signalname, x=None)[source]

Performs global events, if their conditions are fullfilled. This function is called any time data is added to signals.

Parameters:
  • y (float) – y-value of signal (not needed)
  • unit (str) – unit of signal (not needed)
  • devicename (str) – devicename of signal
  • signalname (str) – signalname of signal
  • x (float) – x-value of signal (not needed)
printGlobalActions()[source]
printGlobalEvents(wo=True)[source]
removeGlobalAction(key)[source]
removeGlobalEvent(key)[source]
saveGlobalActions()[source]

Saves global actions from ‘self.globalActions’ to file.

saveGlobalEvents()[source]

Saves global events from ‘self.globalEvents’ to file.

triggerGlobalAction(key)[source]
triggerGlobalEvent(key)[source]
translate(id, text)[source]

RTOC.RTLogger.NetworkFunctions module

RTOC.RTLogger.RTLogger module

RTOC.RTLogger.RTOC_Web module

RTOC.RTLogger.RTOC_Web_standalone module

RTOC.RTLogger.RTRemote module

RTOC.RTLogger.RT_data module

RTOC.RTLogger.ScriptFunctions module

class ScriptFunctions[source]

This class contains all script-execution-specific functions of RTLogger

checkCondition(conditionStr)[source]
createConditionFunction(s)[source]
createFunction(s)[source]
executeScript(scriptStr)[source]
generateCode(s, condition=False)[source]
generateTriggerCode(scriptStr)[source]
printfunction()[source]
replaceGlobalVariables(s)[source]
replaceLibraryFunctions(s)[source]
replaceLoggerFunctions(s)[source]
replacePluginMethods(s)[source]
replacePluginParameters(s)[source]
replaceSignalNames(s)[source]
triggerExpressionHandler(expression)[source]

RTOC.RTLogger.importCode module

importCode(code, name, add_to_sys_modules=0)[source]

Import dynamically generated code as a module. code is the object containing the code (a string, a file handle or an actual compiled code object, same types as accepted by an exec statement). The name is the name to give to the module, and the final argument says wheter to add it to sys.modules or not. If it is added, a subsequent import statement using name will return this module. If it is not added to sys.modules import will try to load it in the normal fashion.

import foo

is equivalent to

foofile = open(“/path/to/foo.py”) foo = importCode(foofile,”foo”,1)

Returns a newly generated module.

RTOC.RTLogger.loggerlib module

RTOC.RTLogger.scriptLibrary module

RTOC.RTLogger.telegramBot module