Extended manifest files with Python system packages (if available) #275

Merged
blacklight merged 7 commits from 274/refactor-integrations-manifests into master 2023-08-17 02:56:15 +02:00
77 changed files with 624 additions and 176 deletions

View File

@ -1,13 +0,0 @@
#!python3
import sys
from platypush.app import Application
if __name__ == '__main__':
app = Application.build(*sys.argv[1:])
app.run()
# vim:sw=4:ts=4:et:

View File

@ -1,5 +1,3 @@
import sys
from platypush.runner import main from platypush.runner import main
main(*sys.argv[1:]) main()

View File

@ -441,6 +441,8 @@ class Backend(Thread, EventGenerator, ExtensionWithManifest):
""" """
Unregister the Zeroconf service configuration if available. Unregister the Zeroconf service configuration if available.
""" """
from redis import exceptions
if self.zeroconf and self.zeroconf_info: if self.zeroconf and self.zeroconf_info:
try: try:
self.zeroconf.unregister_service(self.zeroconf_info) self.zeroconf.unregister_service(self.zeroconf_info)
@ -458,17 +460,22 @@ class Backend(Thread, EventGenerator, ExtensionWithManifest):
except TimeoutError: except TimeoutError:
pass pass
if self.zeroconf_info: try:
self.bus.post( if self.zeroconf_info:
ZeroconfServiceRemovedEvent( self.bus.post(
service_type=self.zeroconf_info.type, ZeroconfServiceRemovedEvent(
service_name=self.zeroconf_info.name, service_type=self.zeroconf_info.type,
service_name=self.zeroconf_info.name,
)
) )
) else:
else: self.bus.post(
self.bus.post( ZeroconfServiceRemovedEvent(
ZeroconfServiceRemovedEvent(service_type=None, service_name=None) service_type=None, service_name=None
) )
)
except exceptions.ConnectionError:
pass
self.zeroconf_info = None self.zeroconf_info = None
self.zeroconf = None self.zeroconf = None

View File

@ -19,9 +19,18 @@ manifest:
platypush.message.event.assistant.TimerEndEvent: when a timer ends platypush.message.event.assistant.TimerEndEvent: when a timer ends
platypush.message.event.assistant.TimerStartedEvent: when a timer starts platypush.message.event.assistant.TimerStartedEvent: when a timer starts
install: install:
apk:
- py3-grpcio
- py3-google-auth
apt:
- python3-grpcio
- python3-google-auth
pacman:
- python-grpcio
- python-google-auth
pip: pip:
- google-assistant-library - google-assistant-library
- google-assistant-sdk[samples] - google-assistant-sdk[samples]
- google-auth - google-auth
package: platypush.backend.assistant.google package: platypush.backend.assistant.google
type: backend type: backend

View File

@ -1,9 +1,18 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-numpy
- py3-pillow
pacman:
- python-numpy
- python-pillow
apt:
- python3-numpy
- python3-pillow
pip: pip:
- picamera - picamera
- numpy - numpy
- Pillow - Pillow
package: platypush.backend.camera.pi package: platypush.backend.camera.pi
type: backend type: backend

View File

@ -4,7 +4,13 @@ manifest:
platypush.message.event.file.FileSystemDeleteEvent: if a resource is removed. platypush.message.event.file.FileSystemDeleteEvent: if a resource is removed.
platypush.message.event.file.FileSystemModifyEvent: if a resource is modified. platypush.message.event.file.FileSystemModifyEvent: if a resource is modified.
install: install:
apk:
- py3-watchdog
apt:
- python3-watchdog
pacman:
- python-watchdog
pip: pip:
- watchdog - watchdog
package: platypush.backend.file.monitor package: platypush.backend.file.monitor
type: backend type: backend

View File

@ -6,11 +6,13 @@ manifest:
platypush.message.event.gps.GPSVersionEvent: when a GPS device advertises its platypush.message.event.gps.GPSVersionEvent: when a GPS device advertises its
version data version data
install: install:
pip: apk:
- gps
pacman:
- gpsd - gpsd
apt: apt:
- gpsd - gpsd
pacman:
- gpsd
pip:
- gps
package: platypush.backend.gps package: platypush.backend.gps
type: backend type: backend

View File

@ -1,7 +1,6 @@
manifest: manifest:
events: {} events: {}
install: install:
pip: pip: []
- gunicorn
package: platypush.backend.http package: platypush.backend.http
type: backend type: backend

View File

@ -9,7 +9,11 @@ manifest:
platypush.message.event.inotify.InotifyPermissionsChangeEvent: if the permissions platypush.message.event.inotify.InotifyPermissionsChangeEvent: if the permissions
of a resource are changed of a resource are changed
install: install:
apk:
- py3-inotify
apt:
- python3-inotify
pip: pip:
- inotify - inotify
package: platypush.backend.inotify package: platypush.backend.inotify
type: backend type: backend

View File

@ -13,9 +13,11 @@ manifest:
platypush.message.event.joystick.JoystickStateEvent: when the state of the joystick platypush.message.event.joystick.JoystickStateEvent: when the state of the joystick
(i.e. some of itsaxes or buttons values) changes. (i.e. some of itsaxes or buttons values) changes.
install: install:
apk:
- linuxconsoletools
apt: apt:
- joystick - joystick
pacman: pacman:
- jsutils - joyutils
package: platypush.backend.joystick.jstest package: platypush.backend.joystick.jstest
type: backend type: backend

View File

@ -1,7 +1,9 @@
manifest: manifest:
events: {} events: {}
install: install:
apt:
- python3-kafka
pip: pip:
- kafka - kafka
package: platypush.backend.kafka package: platypush.backend.kafka
type: backend type: backend

View File

@ -2,7 +2,13 @@ manifest:
events: events:
platypush.message.event.log.http.HttpLogEvent: when a new log line is created. platypush.message.event.log.http.HttpLogEvent: when a new log line is created.
install: install:
apk:
- py3-watchdog
apt:
- python3-watchdog
pacman:
- python-watchdog
pip: pip:
- watchdog - watchdog
package: platypush.backend.log.http package: platypush.backend.log.http
type: backend type: backend

View File

@ -2,7 +2,12 @@ manifest:
events: events:
platypush.message.event.midi.MidiMessageEvent: when a new MIDI event is received platypush.message.event.midi.MidiMessageEvent: when a new MIDI event is received
install: install:
apt:
- python3-rtmidi
pacman:
- rtmidi
- python-rtmidi
pip: pip:
- rtmidi - rtmidi
package: platypush.backend.midi package: platypush.backend.midi
type: backend type: backend

View File

@ -3,7 +3,13 @@ manifest:
platypush.message.event.mqtt.MQTTMessageEvent: when a newmessage is received on platypush.message.event.mqtt.MQTTMessageEvent: when a newmessage is received on
one of the custom listeners one of the custom listeners
install: install:
apk:
- py3-paho-mqtt
pacman:
- python-paho-mqtt
apt:
- python3-paho-mqtt
pip: pip:
- paho-mqtt - paho-mqtt
package: platypush.backend.mqtt package: platypush.backend.mqtt
type: backend type: backend

View File

@ -10,7 +10,11 @@ manifest:
platypush.message.event.music.PlaylistChangeEvent: if the main playlist has changed platypush.message.event.music.PlaylistChangeEvent: if the main playlist has changed
platypush.message.event.music.VolumeChangeEvent: if the main volume has changed platypush.message.event.music.VolumeChangeEvent: if the main volume has changed
install: install:
apt:
- python3-mpd2
pacman:
- python-mpd2
pip: pip:
- python-mpd2 - python-mpd2
package: platypush.backend.music.mpd package: platypush.backend.music.mpd
type: backend type: backend

View File

@ -9,6 +9,9 @@ manifest:
platypush.message.event.music.NewPlayingTrackEvent: if a new track is being played platypush.message.event.music.NewPlayingTrackEvent: if a new track is being played
platypush.message.event.music.VolumeChangeEvent: if the volume changes platypush.message.event.music.VolumeChangeEvent: if the volume changes
install: install:
apk:
- sudo
- cargo
apt: apt:
- sudo - sudo
- cargo - cargo

View File

@ -3,7 +3,13 @@ manifest:
platypush.message.event.scard.SmartCardDetectedEvent: when a smart card is detected platypush.message.event.scard.SmartCardDetectedEvent: when a smart card is detected
platypush.message.event.scard.SmartCardRemovedEvent: when a smart card is removed platypush.message.event.scard.SmartCardRemovedEvent: when a smart card is removed
install: install:
apk:
- py3-pyscard
pacman:
- python-pyscard
apt:
- python3-pyscard
pip: pip:
- pyscard - pyscard
package: platypush.backend.scard package: platypush.backend.scard
type: backend type: backend

View File

@ -14,7 +14,13 @@ manifest:
platypush.message.event.zwave.ZwaveValueChangedEvent: when the value of a node platypush.message.event.zwave.ZwaveValueChangedEvent: when the value of a node
on the networkchanges. on the networkchanges.
install: install:
apk:
- py3-paho-mqtt
pacman:
- python-paho-mqtt
apt:
- python3-paho-mqtt
pip: pip:
- paho-mqtt - paho-mqtt
package: platypush.backend.zwave.mqtt package: platypush.backend.zwave.mqtt
type: backend type: backend

View File

@ -52,7 +52,8 @@ def get_entities_engine(timeout: Optional[float] = None) -> EntitiesEngine:
Event().wait(1) Event().wait(1)
assert _engine, 'The entities engine has not been initialized' if not _engine:
raise TimeoutError('The entities engine has not been initialized')
return _engine return _engine

View File

@ -7,9 +7,18 @@ manifest:
platypush.message.event.assistant.SpeechRecognizedEvent: when a new voice command platypush.message.event.assistant.SpeechRecognizedEvent: when a new voice command
is recognized is recognized
install: install:
apk:
- py3-tenacity
- py3-google-auth
apt:
- python3-tenacity
- python3-google-auth
pacman:
- python-tenacity
- python-google-auth
pip: pip:
- tenacity - tenacity
- google-assistant-sdk - google-assistant-sdk
- google-auth - google-auth
package: platypush.plugins.assistant.google.pushtotalk package: platypush.plugins.assistant.google.pushtotalk
type: plugin type: plugin

View File

@ -13,14 +13,20 @@ manifest:
platypush.message.event.bluetooth.BluetoothScanResumedEvent: platypush.message.event.bluetooth.BluetoothScanResumedEvent:
platypush.message.event.entities.EntityUpdateEvent: platypush.message.event.entities.EntityUpdateEvent:
install: install:
pip: apk:
- bleak - py3-pydbus
- bluetooth-numbers
- TheengsDecoder
- pydbus
- git+https://github.com/pybluez/pybluez
- git+https://github.com/BlackLight/PyOBEX
apt: apt:
- libbluetooth-dev - libbluetooth-dev
- python3-pydbus
pacman:
- python-pydbus
- python-bleak
pip:
- bleak
- bluetooth-numbers
- TheengsDecoder
- pydbus
- git+https://github.com/pybluez/pybluez
- git+https://github.com/BlackLight/PyOBEX
package: platypush.plugins.bluetooth package: platypush.plugins.bluetooth
type: plugin type: plugin

View File

@ -1,7 +1,13 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-icalendar
apt:
- python3-icalendar
pacman:
- python-icalendar
pip: pip:
- icalendar - icalendar
package: platypush.plugins.calendar.ical package: platypush.plugins.calendar.ical
type: plugin type: plugin

View File

@ -1,9 +1,21 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-numpy
- py3-pillow
- py3-opencv
pacman:
- python-numpy
- python-pillow
- python-opencv
apt:
- python3-numpy
- python3-pillow
- python3-opencv
pip: pip:
- numpy - numpy
- opencv-python - opencv-python
- Pillow - Pillow
package: platypush.plugins.camera.cv package: platypush.plugins.camera.cv
type: plugin type: plugin

View File

@ -1,12 +1,20 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-numpy
- py3-pillow
- ffmpeg
pacman:
- python-numpy
- python-pillow
- ffmpeg
apt:
- python3-numpy
- python3-pillow
- ffmpeg
pip: pip:
- numpy - numpy
- Pillow - Pillow
apt:
- ffmpeg
pacman:
- ffmpeg
package: platypush.plugins.camera.ffmpeg package: platypush.plugins.camera.ffmpeg
type: plugin type: plugin

View File

@ -1,16 +1,25 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-numpy
- py3-pillow
- py3-gobject3
- py3-gst
pacman:
- python-numpy
- python-pillow
- gst-python
- python-gobject
apt:
- python3-numpy
- python3-pillow
- python3-gi
- python3-gst-1.0
pip: pip:
- numpy - numpy
- Pillow - Pillow
- pygobject - pygobject
apt:
- python3-gi
- python3-gst-1.0
pacman:
- gst-python
- python-gobject
package: platypush.plugins.camera.gstreamer package: platypush.plugins.camera.gstreamer
type: plugin type: plugin

View File

@ -1,12 +1,20 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- i2c-tools-dev
- py3-numpy
- py3-pillow
pacman:
- i2c-tools
- python-numpy
- python-pillow
apt:
- libi2c-dev
- python3-numpy
- python3-pillow
pip: pip:
- numpy - numpy
- Pillow - Pillow
apt:
- libi2c-dev
pacman:
- i2c-tools
package: platypush.plugins.camera.ir.mlx90640 package: platypush.plugins.camera.ir.mlx90640
type: plugin type: plugin

View File

@ -1,9 +1,18 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-numpy
- py3-pillow
pacman:
- python-numpy
- python-pillow
apt:
- python3-numpy
- python3-pillow
pip: pip:
- picamera - picamera
- numpy - numpy
- Pillow - Pillow
package: platypush.plugins.camera.pi package: platypush.plugins.camera.pi
type: plugin type: plugin

View File

@ -21,5 +21,9 @@ manifest:
package: platypush.plugins.chat.irc package: platypush.plugins.chat.irc
type: plugin type: plugin
install: install:
apt:
- python3-irc
pacman:
- python-irc
pip: pip:
- irc - irc

View File

@ -2,7 +2,9 @@ manifest:
events: events:
platypush.message.event.clipboard.ClipboardEvent: on clipboard update. platypush.message.event.clipboard.ClipboardEvent: on clipboard update.
install: install:
apk:
- py3-pyclip
pip: pip:
- pyclip - pyclip
package: platypush.plugins.clipboard package: platypush.plugins.clipboard
type: plugin type: plugin

View File

@ -2,8 +2,17 @@ manifest:
events: events:
platypush.message.event.dbus.DbusSignalEvent: When a signal is received platypush.message.event.dbus.DbusSignalEvent: When a signal is received
install: install:
apk:
- py3-pydbus
- py3-defusedxml
apt:
- python3-pydbus
- python3-defusedxml
pacman:
- python-pydbus
- python-defusedxml
pip: pip:
- pydbus - pydbus
- defusedxml - defusedxml
package: platypush.plugins.dbus package: platypush.plugins.dbus
type: plugin type: plugin

View File

@ -1,7 +1,11 @@
manifest: manifest:
events: {} events: {}
install: install:
apt:
- python3-dropbox
pacman:
- python-dropbox
pip: pip:
- dropbox - dropbox
package: platypush.plugins.dropbox package: platypush.plugins.dropbox
type: plugin type: plugin

View File

@ -1,11 +1,14 @@
manifest: manifest:
events: {} events: {}
install: install:
pip: apk:
- ffmpeg-python - ffmpeg
apt: apt:
- ffmpeg - ffmpeg
pacman: pacman:
- ffmpeg - ffmpeg
- python-ffmpeg
pip:
- ffmpeg-python
package: platypush.plugins.ffmpeg package: platypush.plugins.ffmpeg
type: plugin type: plugin

View File

@ -1,9 +1,20 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-google-api-python-client
- py3-google-auth
- py3-oauth2client
apt:
- python3-google-auth
- python3-oauth2client
pacman:
- python-google-api-python-client
- python-google-auth
- python-oauth2client
pip: pip:
- google-api-python-client - google-api-python-client
- google-auth - google-auth
- oauth2client - oauth2client
package: platypush.plugins.google.calendar package: platypush.plugins.google.calendar
type: plugin type: plugin

View File

@ -1,9 +1,20 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-google-api-python-client
- py3-google-auth
- py3-oauth2client
apt:
- python3-google-auth
- python3-oauth2client
pacman:
- python-google-api-python-client
- python-google-auth
- python-oauth2client
pip: pip:
- google-api-python-client - google-api-python-client
- google-auth - google-auth
- oauth2client - oauth2client
package: platypush.plugins.google.drive package: platypush.plugins.google.drive
type: plugin type: plugin

View File

@ -1,9 +1,20 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-google-api-python-client
- py3-google-auth
- py3-oauth2client
apt:
- python3-google-auth
- python3-oauth2client
pacman:
- python-google-api-python-client
- python-google-auth
- python-oauth2client
pip: pip:
- google-api-python-client - google-api-python-client
- google-auth - google-auth
- oauth2client - oauth2client
package: platypush.plugins.google.fit package: platypush.plugins.google.fit
type: plugin type: plugin

View File

@ -1,9 +1,20 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-google-api-python-client
- py3-google-auth
- py3-oauth2client
apt:
- python3-google-auth
- python3-oauth2client
pacman:
- python-google-api-python-client
- python-google-auth
- python-oauth2client
pip: pip:
- google-api-python-client - google-api-python-client
- google-auth - google-auth
- oauth2client - oauth2client
package: platypush.plugins.google.mail package: platypush.plugins.google.mail
type: plugin type: plugin

View File

@ -1,9 +1,20 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-google-api-python-client
- py3-google-auth
- py3-oauth2client
apt:
- python3-google-auth
- python3-oauth2client
pacman:
- python-google-api-python-client
- python-google-auth
- python-oauth2client
pip: pip:
- google-api-python-client - google-api-python-client
- google-auth - google-auth
- oauth2client - oauth2client
package: platypush.plugins.google.maps package: platypush.plugins.google.maps
type: plugin type: plugin

View File

@ -1,10 +1,21 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-google-api-python-client
- py3-google-auth
- py3-oauth2client
apt:
- python3-google-auth
- python3-oauth2client
pacman:
- python-google-api-python-client
- python-google-auth
- python-oauth2client
pip: pip:
- google-api-python-client - google-api-python-client
- google-auth - google-auth
- oauth2client - oauth2client
- google-cloud-pubsub - google-cloud-pubsub
package: platypush.plugins.google.pubsub package: platypush.plugins.google.pubsub
type: plugin type: plugin

View File

@ -1,10 +1,21 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-google-api-python-client
- py3-google-auth
- py3-oauth2client
apt:
- python3-google-auth
- python3-oauth2client
pacman:
- python-google-api-python-client
- python-google-auth
- python-oauth2client
pip: pip:
- google-api-python-client - google-api-python-client
- google-auth - google-auth
- oauth2client - oauth2client
- google-cloud-translate - google-cloud-translate
package: platypush.plugins.google.translate package: platypush.plugins.google.translate
type: plugin type: plugin

View File

@ -1,9 +1,20 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-google-api-python-client
- py3-google-auth
- py3-oauth2client
apt:
- python3-google-auth
- python3-oauth2client
pacman:
- python-google-api-python-client
- python-google-auth
- python-oauth2client
pip: pip:
- google-api-python-client - google-api-python-client
- google-auth - google-auth
- oauth2client - oauth2client
package: platypush.plugins.google.youtube package: platypush.plugins.google.youtube
type: plugin type: plugin

View File

@ -4,6 +4,10 @@ manifest:
platypush.message.event.hid.HidDeviceDisconnectedEvent: when a previously available device is disconnected platypush.message.event.hid.HidDeviceDisconnectedEvent: when a previously available device is disconnected
platypush.message.event.hid.HidDeviceDataEvent: when a monitored device sends some data platypush.message.event.hid.HidDeviceDataEvent: when a monitored device sends some data
install: install:
apt:
- python3-hid
pacman:
- python-hid
pip: pip:
- hid - hid
package: platypush.plugins.hid package: platypush.plugins.hid

View File

@ -1,15 +1,20 @@
manifest: manifest:
events: {} events: {}
install: install:
pip: apk:
- weasyprint - sudo
- nodejs
- npm
apt: apt:
- sudo - sudo
- nodejs - nodejs
- npm - npm
pacman: pacman:
- sudo - sudo
- nodejs
- npm - npm
pip:
- weasyprint
exec: exec:
- sudo npm install -g @postlight/mercury-parser - sudo npm install -g @postlight/mercury-parser
package: platypush.plugins.http.webpage package: platypush.plugins.http.webpage

View File

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

View File

@ -1,7 +1,13 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-pylast
apt:
- python3-pylast
pacman:
- python-pylast
pip: pip:
- pylast - pylast
package: platypush.plugins.lastfm package: platypush.plugins.lastfm
type: plugin type: plugin

View File

@ -39,10 +39,13 @@ manifest:
message seen by a user in a room is updated. message seen by a user in a room is updated.
platypush.message.event.matrix.MatrixUserPresenceEvent: when a user comes platypush.message.event.matrix.MatrixUserPresenceEvent: when a user comes
online or goes offline. online or goes offline.
apk:
- olm-dev
apt: apt:
- libolm-devel - libolm-devel
pacman: pacman:
- libolm - libolm
- python-async-lru
pip: pip:
- matrix-nio[e2e] - matrix-nio[e2e]
- async_lru - async_lru

View File

@ -1,7 +1,11 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-pychromecast
apt:
- python3-pychromecast
pip: pip:
- pychromecast - pychromecast
package: platypush.plugins.media.chromecast package: platypush.plugins.media.chromecast
type: plugin type: plugin

View File

@ -1,14 +1,17 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-gobject3
- py3-gst
apt: apt:
- python3-gi - python3-gi
- python3-gst-1.0 - python3-gst-1.0
pip:
- pygobject
pacman: pacman:
- gst-python - gst-python
- python-gobject - python-gobject
pip:
- pygobject
package: platypush.plugins.media.gstreamer package: platypush.plugins.media.gstreamer
type: plugin type: plugin

View File

@ -1,7 +1,11 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-kodi
pacman:
- python-kodi-json
pip: pip:
- kodi-json - kodi-json
package: platypush.plugins.media.kodi package: platypush.plugins.media.kodi
type: plugin type: plugin

View File

@ -1,6 +1,8 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- mplayer
apt: apt:
- mplayer - mplayer
pacman: pacman:

View File

@ -1,11 +1,16 @@
manifest: manifest:
events: {} events: {}
install: install:
pip: apk:
- python-mpv - mpv
- py3-mpv
apt: apt:
- mpv - mpv
- python3-mpv
pacman: pacman:
- mpv - mpv
- python-mpv
pip:
- python-mpv
package: platypush.plugins.media.mpv package: platypush.plugins.media.mpv
type: plugin type: plugin

View File

@ -1,8 +1,10 @@
manifest: manifest:
events: {} events: {}
install: install:
apt:
- python3-webvtt
pip: pip:
- python-opensubtitles - python-opensubtitles
- webvtt-py - webvtt-py
package: platypush.plugins.media.subtitles package: platypush.plugins.media.subtitles
type: plugin type: plugin

View File

@ -1,11 +1,15 @@
manifest: manifest:
events: {} events: {}
install: install:
pip: apk:
- python-vlc - vlc
- py3-vlc
apt: apt:
- vlc - vlc
- python3-vlc
pacman: pacman:
- vlc - vlc
pip:
- python-vlc
package: platypush.plugins.media.vlc package: platypush.plugins.media.vlc
type: plugin type: plugin

View File

@ -1,7 +1,11 @@
manifest: manifest:
events: {} events: {}
install: install:
apt:
- python3-rtmidi
pacman:
- python-rtmidi
pip: pip:
- python-rtmidi - python-rtmidi
package: platypush.plugins.midi package: platypush.plugins.midi
type: plugin type: plugin

View File

@ -1,8 +1,17 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-numpy
- py3-opencv
pacman:
- python-numpy
- python-opencv
apt:
- python3-numpy
- python3-opencv
pip: pip:
- numpy - numpy
- opencv-python - opencv-python
package: platypush.plugins.ml.cv package: platypush.plugins.ml.cv
type: plugin type: plugin

View File

@ -1,7 +1,13 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-paho-mqtt
pacman:
- python-paho-mqtt
apt:
- python3-paho-mqtt
pip: pip:
- paho-mqtt - paho-mqtt
package: platypush.plugins.mqtt package: platypush.plugins.mqtt
type: plugin type: plugin

View File

@ -1,7 +1,11 @@
manifest: manifest:
events: {} events: {}
install: install:
apt:
- python-mpd
pacman:
- python-mpd2
pip: pip:
- python-mpd2 - python-mpd2
package: platypush.plugins.music.mpd package: platypush.plugins.music.mpd
type: plugin type: plugin

View File

@ -1,7 +1,13 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-otp
apt:
- python3-pyotp
pacman:
- python-pyotp
pip: pip:
- pyotp - pyotp
package: platypush.plugins.otp package: platypush.plugins.otp
type: plugin type: plugin

View File

@ -1,9 +1,14 @@
manifest: manifest:
events: {} events: {}
install: install:
pip: apk:
- pycups - py3-pycups
apt: apt:
- libcups2-dev - libcups2-dev
- python3-cups
pacman:
- python-pycups
pip:
- pycups
package: platypush.plugins.printer.cups package: platypush.plugins.printer.cups
type: plugin type: plugin

View File

@ -1,10 +1,25 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-numpy
- py3-pillow
- py3-qrcode
- py3-pyzbar
pacman:
- python-numpy
- python-pillow
- python-qrcode
- pyzbar
apt:
- python3-numpy
- python3-pillow
- python3-pyzbar
- python3-qrcode
pip: pip:
- numpy - numpy
- qrcode - qrcode
- pyzbar - pyzbar
- Pillow - Pillow
package: platypush.plugins.qrcode package: platypush.plugins.qrcode
type: plugin type: plugin

View File

@ -2,6 +2,15 @@ manifest:
events: events:
platypush.message.event.rss.NewFeedEntryEvent: when a new entry is received on a subscribed feed. platypush.message.event.rss.NewFeedEntryEvent: when a new entry is received on a subscribed feed.
install: install:
apk:
- py3-feedparser
- py3-defusedxml
apt:
- python3-feedparser
- python3-defusedxml
pacman:
- python-feedparser
- python-defusedxml
pip: pip:
- feedparser - feedparser
- defusedxml - defusedxml

View File

@ -15,6 +15,8 @@ manifest:
removed. removed.
platypush.message.event.torrent.TorrentResumedEvent: when a transfer is resumed. platypush.message.event.torrent.TorrentResumedEvent: when a transfer is resumed.
install: install:
apk:
- rtorrent
apt: apt:
- rtorrent - rtorrent
pacman: pacman:

View File

@ -2,6 +2,12 @@ manifest:
events: events:
- platypush.message.event.sensor.SensorDataChangeEvent: - platypush.message.event.sensor.SensorDataChangeEvent:
install: install:
apk:
- py3-pyserial
apt:
- python3-serial
pacman:
- python-pyserial
pip: pip:
- pyserial - pyserial
package: platypush.plugins.serial package: platypush.plugins.serial

View File

@ -9,14 +9,21 @@ manifest:
platypush.message.event.sound.SoundRecordingStartedEvent: on recording start platypush.message.event.sound.SoundRecordingStartedEvent: on recording start
platypush.message.event.sound.SoundRecordingStoppedEvent: on recording stop platypush.message.event.sound.SoundRecordingStoppedEvent: on recording stop
install: install:
pip: apk:
- sounddevice - ffmpeg
- numpy - portaudio-dev
- py3-numpy
apt: apt:
- ffmpeg - ffmpeg
- portaudio19-dev - portaudio19-dev
- python3-numpy
pacman: pacman:
- ffmpeg - ffmpeg
- portaudio - portaudio
- python-numpy
- python-sounddevice
pip:
- sounddevice
- numpy
package: platypush.plugins.sound package: platypush.plugins.sound
type: plugin type: plugin

View File

@ -1,7 +1,13 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-paramiko
apt:
- python3-paramiko
pacman:
- python-paramiko
pip: pip:
- paramiko - paramiko
package: platypush.plugins.ssh package: platypush.plugins.ssh
type: plugin type: plugin

View File

@ -1,9 +1,16 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-numpy
pacman:
- python-numpy
- python-sounddevice
apt:
- python3-numpy
pip: pip:
- deepspeech - deepspeech
- numpy - numpy
- sounddevice - sounddevice
package: platypush.plugins.stt.deepspeech package: platypush.plugins.stt.deepspeech
type: plugin type: plugin

View File

@ -1,7 +1,13 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-py-cpuinfo
apt:
- python3-cpuinfo
pacman:
- python-py-cpuinfo
pip: pip:
- py-cpuinfo - py-cpuinfo
package: platypush.plugins.system package: platypush.plugins.system
type: plugin type: plugin

View File

@ -13,10 +13,21 @@ manifest:
platypush.message.event.tensorflow.TensorflowTrainStartedEvent: when a Tensorflow platypush.message.event.tensorflow.TensorflowTrainStartedEvent: when a Tensorflow
model starts being trained. model starts being trained.
install: install:
apk:
- py3-numpy
- py3-pandas
pacman:
- python-numpy
- python-pandas
- python-tensorflow
- python-keras
apt:
- python3-numpy
- python3-pandas
pip: pip:
- numpy - numpy
- pandas - pandas
- tensorflow - tensorflow
- keras - keras
package: platypush.plugins.tensorflow package: platypush.plugins.tensorflow
type: plugin type: plugin

View File

@ -1,7 +1,13 @@
manifest: manifest:
events: {} events: {}
install: install:
apk:
- py3-libtorrent-rasterbar
apt:
- python3-libtorrent
pacman:
- libtorrent-rasterbar
pip: pip:
- python-libtorrent - libtorrent
package: platypush.plugins.torrent package: platypush.plugins.torrent
type: plugin type: plugin

View File

@ -1,7 +1,9 @@
manifest: manifest:
events: {} events: {}
install: install:
apt:
- python3-twilio
pip: pip:
- twilio - twilio
package: platypush.plugins.twilio package: platypush.plugins.twilio
type: plugin type: plugin

View File

@ -1,11 +1,45 @@
from typing import Collection, Dict, Iterable, Optional, Union from functools import wraps
from threading import Event, RLock
from typing import Any, Callable, Collection, Dict, Iterable, Optional, Union
from typing_extensions import override from typing_extensions import override
from platypush.entities import EntityManager from platypush.entities import EntityManager, get_entities_engine
from platypush.entities.variables import Variable from platypush.entities.variables import Variable
from platypush.plugins import Plugin, action from platypush.plugins import Plugin, action
# pylint: disable=protected-access
def ensure_initialized(f: Callable[..., Any]):
"""
Ensures that the entities engine has been initialized before
reading/writing the db.
It also performs lazy initialization of the variables in the local cache.
"""
@wraps(f)
def wrapper(*args, **kwargs):
self: VariablePlugin = args[0]
if not self._initialized.is_set():
with self._init_lock:
get_entities_engine(timeout=20)
if not self._initialized.is_set():
self._initialized.set()
with self._db.get_session() as session:
self._db_vars.update(
{ # type: ignore
str(var.name): var.value
for var in session.query(Variable).all()
}
)
return f(*args, **kwargs)
return wrapper
class VariablePlugin(Plugin, EntityManager): class VariablePlugin(Plugin, EntityManager):
""" """
This plugin allows you to manipulate context variables that can be This plugin allows you to manipulate context variables that can be
@ -17,18 +51,15 @@ class VariablePlugin(Plugin, EntityManager):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
db = self._db
self._db_vars: Dict[str, Optional[str]] = {} self._db_vars: Dict[str, Optional[str]] = {}
""" Local cache for db variables. """ """ Local cache for db variables. """
self._initialized = Event()
with db.get_session() as session: """ Lazy initialization event for the _db_vars map. """
self._db_vars.update( self._init_lock = RLock()
{ # type: ignore """ Lock for the _db_vars map initialization. """
str(var.name): var.value for var in session.query(Variable).all()
}
)
@action @action
@ensure_initialized
def get(self, name: Optional[str] = None, default_value=None): def get(self, name: Optional[str] = None, default_value=None):
""" """
Get the value of a variable by name from the local db. Get the value of a variable by name from the local db.
@ -45,6 +76,7 @@ class VariablePlugin(Plugin, EntityManager):
) )
@action @action
@ensure_initialized
def set(self, **kwargs): def set(self, **kwargs):
""" """
Set a variable or a set of variables on the local db. Set a variable or a set of variables on the local db.
@ -57,6 +89,7 @@ class VariablePlugin(Plugin, EntityManager):
return kwargs return kwargs
@action @action
@ensure_initialized
def delete(self, name: str): def delete(self, name: str):
""" """
Delete a variable from the database. Delete a variable from the database.
@ -76,6 +109,7 @@ class VariablePlugin(Plugin, EntityManager):
return True return True
@action @action
@ensure_initialized
def unset(self, name: str): def unset(self, name: str):
""" """
Unset a variable by name if it's set on the local db. Unset a variable by name if it's set on the local db.
@ -89,6 +123,7 @@ class VariablePlugin(Plugin, EntityManager):
return self.set(**{name: None}) return self.set(**{name: None})
@action @action
@ensure_initialized
def mget(self, name: str): def mget(self, name: str):
""" """
Get the value of a variable by name from Redis. Get the value of a variable by name from Redis.
@ -100,6 +135,7 @@ class VariablePlugin(Plugin, EntityManager):
return self._redis.mget([name]) return self._redis.mget([name])
@action @action
@ensure_initialized
def mset(self, **kwargs): def mset(self, **kwargs):
""" """
Set a variable or a set of variables on Redis. Set a variable or a set of variables on Redis.
@ -112,6 +148,7 @@ class VariablePlugin(Plugin, EntityManager):
return kwargs return kwargs
@action @action
@ensure_initialized
def munset(self, name: str): def munset(self, name: str):
""" """
Unset a Redis variable by name if it's set Unset a Redis variable by name if it's set
@ -122,6 +159,7 @@ class VariablePlugin(Plugin, EntityManager):
return self._redis.delete(name) return self._redis.delete(name)
@action @action
@ensure_initialized
def expire(self, name: str, expire: int): def expire(self, name: str, expire: int):
""" """
Set a variable expiration on Redis Set a variable expiration on Redis
@ -157,6 +195,7 @@ class VariablePlugin(Plugin, EntityManager):
@override @override
@action @action
@ensure_initialized
def status(self, *_, **__): def status(self, *_, **__):
variables = { variables = {
name: value for name, value in self._db_vars.items() if value is not None name: value for name, value in self._db_vars.items() if value is not None

View File

@ -29,6 +29,13 @@ manifest:
platypush.message.event.xmpp.XmppRoomUserUnavailableEvent: platypush.message.event.xmpp.XmppRoomUserUnavailableEvent:
platypush.message.event.xmpp.XmppUserAvailableEvent: platypush.message.event.xmpp.XmppUserAvailableEvent:
platypush.message.event.xmpp.XmppUserUnavailableEvent: platypush.message.event.xmpp.XmppUserUnavailableEvent:
apk:
- py3-tz
apt:
- python3-aioxmpp
- python3-tz
pacman:
- python-pytz
pip: pip:
- aioxmpp - aioxmpp
- pytz - pytz

View File

@ -7,7 +7,6 @@ manifest:
platypush.message.event.zeroconf.ZeroconfServiceUpdatedEvent: when a service is platypush.message.event.zeroconf.ZeroconfServiceUpdatedEvent: when a service is
updated. updated.
install: install:
pip: pip: []
- zeroconf
package: platypush.plugins.zeroconf package: platypush.plugins.zeroconf
type: plugin type: plugin

View File

@ -39,7 +39,13 @@ manifest:
platypush.message.event.zigbee.mqtt.ZigbeeMqttOnlineEvent: > platypush.message.event.zigbee.mqtt.ZigbeeMqttOnlineEvent: >
when the service comes online. when the service comes online.
install: install:
apk:
- py3-paho-mqtt
pacman:
- python-paho-mqtt
apt:
- python3-paho-mqtt
pip: pip:
- paho-mqtt - paho-mqtt
package: platypush.plugins.zigbee.mqtt package: platypush.plugins.zigbee.mqtt
type: plugin type: plugin

View File

@ -17,7 +17,13 @@ manifest:
platypush.message.event.zwave.ZwaveValueChangedEvent: > platypush.message.event.zwave.ZwaveValueChangedEvent: >
when the value of a node on the network changes. when the value of a node on the network changes.
install: install:
apk:
- py3-paho-mqtt
pacman:
- python-paho-mqtt
apt:
- python3-paho-mqtt
pip: pip:
- paho-mqtt - paho-mqtt
package: platypush.plugins.zwave.mqtt package: platypush.plugins.zwave.mqtt
type: plugin type: plugin

View File

@ -1,7 +1,9 @@
import sys
from ._runner import ApplicationRunner from ._runner import ApplicationRunner
def main(*args: str): def main():
""" """
Main application entry point. Main application entry point.
@ -11,7 +13,7 @@ def main(*args: str):
""" """
app_runner = ApplicationRunner() app_runner = ApplicationRunner()
app_runner.run(*args) app_runner.run(*sys.argv[1:])
__all__ = ["ApplicationRunner", "main"] __all__ = ["ApplicationRunner", "main"]

View File

@ -20,7 +20,6 @@ requests
rsa rsa
sqlalchemy sqlalchemy
tornado tornado
tz
websocket-client websocket-client
websockets websockets
zeroconf>=0.27.0 zeroconf>=0.27.0

View File

@ -77,7 +77,6 @@ setup(
'rsa', 'rsa',
'sqlalchemy', 'sqlalchemy',
'tornado', 'tornado',
'tz',
'websocket-client', 'websocket-client',
'websockets', 'websockets',
'wheel', 'wheel',