Added `application` plugin.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Fabio Manganiello 2023-08-15 11:13:57 +02:00
parent f51beb271e
commit 00863a176e
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
4 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,5 @@
``application``
===============
.. automodule:: platypush.plugins.application
:members:

View File

@ -8,6 +8,7 @@ Plugins
platypush/plugins/adafruit.io.rst
platypush/plugins/alarm.rst
platypush/plugins/application.rst
platypush/plugins/arduino.rst
platypush/plugins/assistant.echo.rst
platypush/plugins/assistant.google.rst

View File

@ -0,0 +1,31 @@
from typing import Optional
from platypush.commands import CommandStream, RestartCommand, StopCommand
from platypush.config import Config
from platypush.plugins import Plugin, action
class ApplicationPlugin(Plugin):
"""
This plugin is used to control and inspect the application state.
"""
@property
def _ctrl_sock(self) -> Optional[str]:
"""
:return: The path to the UNIX socket to control the application.
"""
return Config.get('ctrl_sock') # type: ignore
@action
def stop(self):
"""
Stop the application.
"""
CommandStream(self._ctrl_sock).write(StopCommand())
@action
def restart(self):
"""
Restart the application.
"""
CommandStream(self._ctrl_sock).write(RestartCommand())

View File

@ -0,0 +1,6 @@
manifest:
events: {}
install:
pip: []
package: platypush.plugins.application
type: plugin