powerpanel package¶
Submodules¶
powerpanel.power_panel module¶
-
class
powerpanel.power_panel.
PowerPanelServer
(config=None)¶ Bases:
object
Initializes a Power Tester Server with the following endpoints:
GET / - Home page. Lists all active devices. GET /reg/<name> - Registration endpoint for devices.
Parameters: config (str, default '~/.powerpannel/config.yml') – Path to configuration yaml. >>> # Example Configuration Yaml File >>> # Delay between a devices last registration (sec) allowed before the device is removed from the active testers >>> # list. >>> device_expiration: 3 >>> # The time after which the homepage should refresh to display the active devices. >>> refresh_delay: 1 >>> # The server port. >>> port: 5000 >>> # NOTE: device_expiration should be at least 2x the refresh_delay.
-
active_testers
()¶ Processes the list of devices, removing any device that has not registered itself in the last 3 seconds.
Returns: A list of device names that are currently active. Return type: list
-
home
()¶ The homepage of the server.
Returns: The template page built by templates/main.html template. Return type: str
-
reg
(name)¶ Endpoint which registers an active device.
Parameters: name (str) – Device name passed as a path parameter Returns: An empty string. Return type: str
-
run
()¶ Runs the server.
-
powerpanel.power_tester module¶
-
class
powerpanel.power_tester.
PowerTester
(config=None)¶ Bases:
object
Initializes a Power Tester which registers with a power panel server at a defined frequency.
Parameters: config (str, default '~/.powerpannel/config.yml') – Path to configuration yaml. >>> # Example Configuration Yaml File >>> # Human readable name of the device tester. >>> name: Upstairs Bathroom Outlets >>> # Url of the server. >>> endpoint_url: http://192.168.1.100:5000 >>> # The frequency at which to register the device. >>> reg_frequency: 1 >>> # NOTE: Must be smaller than the device_expiration time of the server.
-
run
()¶ Runs the tester process, registering at the reg_frequency specified in the configuration.
-