raspyre.rpc package¶
Submodules¶
raspyre.rpc.blink module¶
raspyre.rpc.functions module¶
This module implements the functions exposed by the Rapsyre RPC interface.
The functions are grouped in classes and should be invoked into different prefix namespaces. e.g.: class MeasurementHandler consists of functions to handle the Measurement Processes of the Pi’s GPIO interface and should reside in a namespace that identifies this behaviour as such.
-
class
raspyre.rpc.functions.
IPContextFilter
¶ Bases:
logging.Filter
-
filter
(record)¶ Determine if the specified record is to be logged.
Is the specified record to be logged? Returns 0 for no, nonzero for yes. If deemed appropriate, the record may be modified in-place.
-
-
class
raspyre.rpc.functions.
RaspyreService
(data_directory, configuration_directory)¶ Bases:
object
-
PROCESS_TIMEOUT
= 3¶
-
add_sensor
(sensorname, sensortype, config, frequency, axis)¶ This function adds a sensor to the current setup. Each installed raspyre-sensor-driver package can be used to instantiate a sensor for measurement usage (e.g. raspyre-mpu6050, raspyre-ads1115) Example call:
>>> add_sensor(sensorname="S1_left_bridge", sensor_type="MPU6050", config={address=0x69}, frequency=100, axis=['accx', 'accy', 'accz'])
Parameters: - sensorname – Unique String to identify sensor
- sensortype – String specifying the sensor driver package
- config – Dictionary of sensor configuration data. The dictionary keys are passed to the initialization method of the specified sensor driver package
- frequency – Polling frequency for the measurement
- axis – List of parameters to be polled from the sensor
Returns: True
Return type: Boolean
-
clear_sensors
()¶ This function removes all configured sensors from the current setup.
Returns: True Return type: Boolean
-
configuration_restore
(sensorname, path)¶ This function restores a sensor from a given configuration file.
Parameters: - sensorname – Unique String identifying the sensor
- path – File path relative to the configuration_directory
Returns: True
Return type: Boolean
-
configuration_save
(sensorname, path)¶ This function saves the configuration state of a sensor.
Parameters: - sensorname – String of sensor name
- path – Path relative to the configuration directory
Returns: True
Return type: Boolean
-
debug_log_msg
()¶
-
fs_ls
(path='.')¶ This function lists the contents of the data storage directory. It returns a list of 2 lists. The first list contains directories of the queried path, the second list contains the file names.
Parameters: path – path to be queried relative to the data directory Returns: list of 2 lists with [[directories], [files]] Return type: list of lists
-
fs_mkdir
(path)¶ This function creates a directory in the specified path below the data storage directory.
Parameters: path – Path relative to the data directory Returns: True Return type: Boolean
-
fs_mv
(src, dst)¶ This function renames src to dst. If dst is a directory an error will be raised. If dst is a file, it will be silently replaced.
Parameters: - src – Path relative to the data directory
- dst – Path relative to the data directory
Returns: True
Return type: Boolean
-
fs_rm
(path)¶ This function removes the specified file from the file system.
Parameters: path – Path relative to the data directory Returns: True Return type: Boolean
-
fs_rmdir
(path, recursive=False)¶ This function removes a directory relative to the data storage
Parameters: - path – Path relative to the data directory - not the data directory itself
- recursive – Boolean flag indicating recursive deletion
Returns: True
Return type: Boolean
-
fs_stat
(path)¶ This function returns the POSIX information of a stat system call. Please refer to
stat()
Parameters: path – Path relative to the data directory Returns: True Return type: Boolean
-
get_dns_info
()¶
-
get_extra
(extra)¶ This function is reserved for future usage
Parameters: extra – Dictionary Returns: True Return type: Boolean
-
get_info
()¶ This function returns the internal sensor dictionary.
Returns: Dictionary of current configuration Return type: Dictionary
-
get_network_nodes
()¶ FIXME: This function is not implemented
Returns: empty List Return type: List
-
get_status
()¶
-
get_system_date
()¶ This function returns a string representation of the current system time.
Returns: String of current datetime Return type: String
-
is_measuring
(sensorname)¶ This function returns True if the specified sensor is currently used by a measurement process.
Parameters: sensorname – String of sensor name Returns: True|False Return type: Boolean
-
list_files
()¶ DEPRECATED! This function lists the filenames in the data directory. ATTENTION: This function is DEPRECATED and will be removed in a later version. Please use fs_ls()
Returns: List of file names Return type: List of Strings
-
ntp_master
()¶
-
ntp_set_server
(ip_str)¶
-
ntp_sync
()¶
-
ping
()¶ This function simply returns True. It is used as simple connectivity checking function.
Returns: True Return type: Boolean
-
remove_sensor
(sensorname)¶ Removes the sensor specified by its name from the current setup.
Parameters: sensorname – String identifying sensor Returns: True Return type: Boolean
-
set_extra
(extra={})¶ This function is reserved for future usage.
Parameters: extra – Dictionary Returns: True Return type: Boolean
-
set_network_logger
(host, loglevel=10)¶
-
set_system_date
(date)¶ This function sets the current system date. NOTICE: This function does not modify any modified realtime clock!
Parameters: date – String of date. The parameter is passed to the system’s date operation thus accepts its format strings. Please refer to the Linux manual page date(1). Returns: True Return type: Boolean
-
start_blink
()¶
-
start_measurement
(measurementname, sensornames=None)¶ This function starts a measurement process for the specified sensors.
Parameters: - measurementname – String describing the measurement
- sensornames – None [all sensors], String [one specific sensor], List of Strings (optional)
Returns: True
Return type: Boolean
-
start_ntp
()¶
-
stop_blink
()¶
-
stop_measurement
(sensornames=None)¶ This function stops a currently running measurement.
Parameters: sensornames – None [all sensors], String [one specific sensor], List of Strings (optional) Returns: True Return type: Boolean
-
stop_ntp
()¶
-
toggle_blink
()¶
-
update_sensor
(sensorname, config)¶ FIXME: This function updates the configuration of a given sensor.
Parameters: - sensorname – String identifying the sensor
- config – Dictionary of changes configuration parameters. Each key value pair is passed to the sensor’s updateConfiguration()
Returns: True
Return type: Boolean
-
-
raspyre.rpc.functions.
get_ip_address
(ifname)¶
raspyre.rpc.handler module¶
-
class
raspyre.rpc.handler.
HandlerProcess
(sensor, sensor_name, config, frequency, axis, mmap_file, buffer_size, data_dir, csv=False, chunked=False, chunk_minutes=10)¶ Bases:
multiprocessing.context.Process
-
run
()¶ Method to be run in sub-process; can be overridden in sub-class
-
setMeasurementName
(measurement_name)¶
-
shutdown
()¶
-
raspyre.rpc.mplog module¶
-
class
raspyre.rpc.mplog.
MultiProcessingLog
(name, mode, maxsize, rotate)¶ Bases:
logging.Handler
-
close
()¶ Tidy up any resources used by the handler.
This version removes the handler from an internal map of handlers, _handlers, which is used for handler lookup by name. Subclasses should ensure that this gets called from overridden close() methods.
-
emit
(record)¶ Do whatever it takes to actually log the specified logging record.
This version is intended to be implemented by subclasses and so raises a NotImplementedError.
-
receive
()¶
-
send
(s)¶
-
setFormatter
(fmt)¶ Set the formatter for this handler.
-
raspyre.rpc.pollingprocess module¶
-
class
raspyre.rpc.pollingprocess.
PollingProcess
(sensor, sensor_name, config, frequency, axis, data_dir, mmap_file, buffer_size, chunked=False, chunk_minutes=10)¶ Bases:
multiprocessing.context.Process
-
PROCESS_PRIORITY
= 90¶
-
run
()¶ Method to be run in sub-process; can be overridden in sub-class
-
setMeasurementName
(measurement_name)¶
-
shutdown
()¶
-
raspyre.rpc.server module¶
Raspyre-RPCServer
This module is used to create a XMLRPC-Server for the Raspyre SHM platform.
-
class
raspyre.rpc.server.
RequestHandler
(*args, directory=None, **kwargs)¶ Bases:
xmlrpc.server.SimpleXMLRPCRequestHandler
,http.server.SimpleHTTPRequestHandler
-
do_GET
()¶ Serve a GET request.
-
rpc_paths
= ('/RPC2', '/')¶
-
send_head
()¶ Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied to the outputfile by the caller unless the command was HEAD, and must be closed by the caller under all circumstances), or None, in which case the caller has nothing further to do.
-
server_version
= 'RaspyreRPC/0.4'¶
-
-
class
raspyre.rpc.server.
ThreadedXMLRPCServer
(addr, requestHandler=<class 'xmlrpc.server.SimpleXMLRPCRequestHandler'>, logRequests=True, allow_none=False, encoding=None, bind_and_activate=True, use_builtin_types=False)¶ Bases:
xmlrpc.server.SimpleXMLRPCServer
,socketserver.ThreadingMixIn
-
class
raspyre.rpc.server.
VerboseFaultXMLRPCServer
(addr, requestHandler=<class 'xmlrpc.server.SimpleXMLRPCRequestHandler'>, logRequests=True, allow_none=False, encoding=None, bind_and_activate=True, use_builtin_types=False)¶
-
raspyre.rpc.server.
handle_exception
(exc_type, exc_value, exc_traceback)¶
-
raspyre.rpc.server.
main
()¶
-
raspyre.rpc.server.
run_rpc_server
(datadir, address='0.0.0.0', port=8000, logfile=None, configdir=None, verbose=False)¶