API Reference¶
Application¶
Application starts by running run.py, that in turns launches main() function in main.py.
Core component¶
-
class
easyplayer.core.App(*args, **kwargs)[source]¶ Main app component
Child components:
WebClient
AudioPlayer
VideoPlayer
Workshop
DownloadManager
-
started(component, *args)[source]¶ Handler for application started event. Starts timer for check_allowed event.
Audio Player¶
-
class
easyplayer.audio.fade_out(*args, **kwargs)[source]¶ start fading out current player until stop
-
class
easyplayer.audio.MediaPlayer(*args, **kwargs)[source]¶ Base class for Audio and Video players containg common functionality
-
class
easyplayer.audio.AudioPlayer(*args, **kwargs)[source]¶ Audio player communicates with 2 cmus players, schedules switching of songs with crossfade
Video Player¶
Web client¶
-
class
easyplayer.webclient.WebClient(*args, **kwargs)[source]¶ Sends heartbeat to server with status data, can get a command in response. Command will be sent to workshop component, web commands will be executed immediately - getting player info or program data. Another task is logging played songs to server.
Workshop¶
Download Manager¶
-
class
easyplayer.download.switch_storage(*args, **kwargs)[source]¶ switch current storage to the new one with downloaded files
-
easyplayer.download.communicate(song, dwld_info, token, remote_url)[source]¶ send request for media url that can be downloaded
Storage¶
Watchdog¶
-
class
easyplayer.circus.watchdog.WatchDog(endpoint, pubsub_endpoint, check_delay, ssh_server, **config)[source]¶ Plugin that binds an udp socket and waits for watchdog messages. For “watchdoged” processes, the watchdog will kill them (using the “kill” command) if they don’t send heartbeat in a certain period of time materialized by loop_rate * max_count. (circus will automatically restart the missing processes in the watcher)
Each monitored process should send udp message at least at the loop_rate. The udp message format is a line of text, decoded using msg_regex parameter. The heartbeat message MUST at least contain the pid of the process sending the message.
The list of monitored watchers are determined by the parameter watchers_regex in the configuration.
At startup, the plugin does not know all the circus watchers and pids, so it’s needed to discover all watchers and pids. After the discover, the monitoring list is updated by messages from circusd handled in self.handle_recv
Plugin Options –
loop_rate – watchdog loop rate in seconds. At each loop, WatchDog will looks for “dead” processes.
watchers_regex – regex for matching watcher names that should be monitored by the watchdog (default: “.*” all watchers are monitored)
msg_regex – regex for decoding the received heartbeat message in udp (default: “^(?P<pid>.*);(?P<timestamp>.*)$”) the default format is a simple text message: “pid;timestamp”
max_count – max number of passed loop without receiving any heartbeat before restarting process (default: 3)
ip – ip the watchdog will bind on (default: 127.0.0.1)
port – port the watchdog will bind on (default: 1664)
watchers_stop_signal – optionally override the stop_signal used when killing the processes
watchers_graceful_timeout – optionally override the graceful_timeout used when killing the processes
-
handle_init()[source]¶ Initialization of plugin
set the periodic call back for the process monitoring (at loop_rate)
create the listening UDP socket
-
handle_recv(data)[source]¶ Handle received message from circusd
We need to handle two messages: - spawn: add a new monitored child pid - reap: remove a killed child pid from monitoring