forked from platypush/platypush
Added application
plugin.
This commit is contained in:
parent
f51beb271e
commit
00863a176e
4 changed files with 43 additions and 0 deletions
5
docs/source/platypush/plugins/application.rst
Normal file
5
docs/source/platypush/plugins/application.rst
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
``application``
|
||||||
|
===============
|
||||||
|
|
||||||
|
.. automodule:: platypush.plugins.application
|
||||||
|
:members:
|
|
@ -8,6 +8,7 @@ Plugins
|
||||||
|
|
||||||
platypush/plugins/adafruit.io.rst
|
platypush/plugins/adafruit.io.rst
|
||||||
platypush/plugins/alarm.rst
|
platypush/plugins/alarm.rst
|
||||||
|
platypush/plugins/application.rst
|
||||||
platypush/plugins/arduino.rst
|
platypush/plugins/arduino.rst
|
||||||
platypush/plugins/assistant.echo.rst
|
platypush/plugins/assistant.echo.rst
|
||||||
platypush/plugins/assistant.google.rst
|
platypush/plugins/assistant.google.rst
|
||||||
|
|
31
platypush/plugins/application/__init__.py
Normal file
31
platypush/plugins/application/__init__.py
Normal 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())
|
6
platypush/plugins/application/manifest.yaml
Normal file
6
platypush/plugins/application/manifest.yaml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
manifest:
|
||||||
|
events: {}
|
||||||
|
install:
|
||||||
|
pip: []
|
||||||
|
package: platypush.plugins.application
|
||||||
|
type: plugin
|
Loading…
Reference in a new issue