Compare commits
81 commits
Author | SHA1 | Date | |
---|---|---|---|
db8ea33b68 | |||
03631bcebc | |||
ade3a7c2cf | |||
1f6c7aae60 | |||
a6c7d64511 | |||
af7977bcf7 | |||
0762004838 | |||
|
c8bfbae4f0 | ||
|
d35a9729a4 | ||
a39452124d | |||
fc1d9ad3e6 | |||
7ee869ce42 | |||
df36a9f811 | |||
abf793e703 | |||
132c659d3c | |||
acc4f1c0e3 | |||
d7d5bcdd0c | |||
def8c0dd76 | |||
6cc28a3c3b | |||
93c3327bcd | |||
85d975edc6 | |||
d767cafafe | |||
cee8f9f8e0 | |||
b2e2ae9538 | |||
f296f4b161 | |||
9eab526e47 | |||
8f6404d0b1 | |||
eac26b9b22 | |||
b42c491390 | |||
c7fb97cdc7 | |||
18e99c6f12 | |||
664ce4050d | |||
69583d2e15 | |||
2f840200be | |||
46aef7c8b5 | |||
5ca15937e3 | |||
ce882381c0 | |||
99b35b292f | |||
|
174439a8ed | ||
3a18e9faf4 | |||
f8d76fe4eb | |||
9fa3385766 | |||
|
4fe5322600 | ||
2224681e3c | |||
68c44c0c3c | |||
02a22d4a88 | |||
b9bc4b5fe0 | |||
c006c4b368 | |||
75e1f35523 | |||
9e08b731a5 | |||
|
edfa5ed16f | ||
|
f2628f4f2c | ||
f1faa1141e | |||
2a78f81a7b | |||
86761e7088 | |||
89beab4767 | |||
8db8f3e6c4 | |||
ee0685363e | |||
33276bf697 | |||
99831bf0c7 | |||
641d9c0d41 | |||
95625a401d | |||
a147a4d37a | |||
177c697f83 | |||
eb486df1ee | |||
a4c70f1e4d | |||
c16f8aa39e | |||
570f1d0cf6 | |||
|
4313b6e883 | ||
00fabf3853 | |||
cad184fc1f | |||
928bb3667a | |||
782be7794b | |||
40dc739d09 | |||
4821fe086b | |||
8d621b2688 | |||
1355f7a3f6 | |||
3ce98305f0 | |||
0a4cadba3e | |||
9e46ab0b60 | |||
c74d2fb124 |
460 changed files with 25136 additions and 5527 deletions
104
CHANGELOG.md
104
CHANGELOG.md
|
@ -5,6 +5,104 @@ Given the high speed of development in the first phase, changes are being report
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
- Added `music.spotify.connect` backend to emulate a Spotify Connect receiver through Platypush.
|
||||
|
||||
## [0.21.1] - 2021-06-22
|
||||
|
||||
### Added
|
||||
|
||||
- Added `switchbot` plugin to interact with Switchbot devices over the cloud API instead of
|
||||
directly accessing the device's Bluetooth interface.
|
||||
|
||||
- Added `marshmallow` dependency - it will be used from now own to dump and document schemas
|
||||
and responses instead of the currently mixed approach with `Response` objects and plain
|
||||
dictionaries and lists.
|
||||
|
||||
- Support for custom MQTT timeout on all the `zwavejs2mqtt` calls.
|
||||
|
||||
- Added generic joystick backend `backend.joystick.jstest` which uses `jstest` from the
|
||||
standard `joystick` system package to read the state of joysticks not compatible with
|
||||
`python-inputs`.
|
||||
|
||||
- Added PWM PCA9685 plugin.
|
||||
|
||||
- Added Linux native joystick plugin, ``backend.joystick.linux``, for the cases where
|
||||
``python-inputs`` doesn't work and ``jstest`` is too slow.
|
||||
|
||||
### Changed
|
||||
|
||||
- `switch.switchbot` plugin renamed to `switchbot.bluetooth` plugin, while the new plugin
|
||||
that uses the Switchbot API is simply named `switchbot`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- More robust reconnection logic on the Pushbullet backend in case of websocket errors.
|
||||
|
||||
## [0.21.0] - 2021-05-06
|
||||
|
||||
### Added
|
||||
|
||||
- Support for custom PopcornTime API mirror/base URL.
|
||||
|
||||
- Full support for TV series search.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed torrent search (now using a different PopcornTime API mirror).
|
||||
|
||||
- Migrated SASS engine from `node-sass` (currently deprecated and broken on Node 16) to `sass`.
|
||||
|
||||
- Fixed alignment of Z-Wave UI header on Chrome/Webkit.
|
||||
|
||||
## [0.20.10] - 2021-04-28
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed zwave/zwavejs2mqtt interoperability.
|
||||
|
||||
## [0.20.9] - 2021-04-12
|
||||
|
||||
### Added
|
||||
|
||||
- Added zwavejs2mqtt integration (see [#186](https://git.platypush.tech/platypush/platypush/-/issues/186).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Major LINT fixes.
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed unmaintained integrations: TorrentCast and Booking.com
|
||||
|
||||
## [0.20.8] - 2021-04-04
|
||||
|
||||
### Added
|
||||
|
||||
- Added `<Camera>` dashboard widget.
|
||||
|
||||
- Added support for custom dashboard widgets with customized (see https://git.platypush.tech/platypush/platypush/-/wikis/Backends#creating-custom-widgets).
|
||||
|
||||
- Added support for controls on `music.mpd` dashboard widget.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed zigbee2mqtt backend error in case of messages with empty payload (see [#184](https://git.platypush.tech/platypush/platypush/-/issues/184)).
|
||||
|
||||
- Fixed compatibility with all versions of websocket-client - versions >= 0.58.0 pass a `WebSocketApp` object as a first
|
||||
argument to the callbacks, as well as versions < 0.54.0 do, but the versions in between don't pass this argument.
|
||||
|
||||
## [0.20.7] - 2021-03-26
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed race condition on `media.vlc.stop` when clearing the VLC instance.
|
||||
|
||||
- Fixed dashboard widgets custom classes being propagated both to the container and to the widget content [see #179]
|
||||
|
||||
- Fixed compatibility with SQLAlchemy >= 1.4.
|
||||
|
||||
## [0.20.6] - 2021-03-16
|
||||
|
||||
### Added
|
||||
|
||||
- Added `log.http` backend to monitor changes to HTTP log files
|
||||
|
@ -17,6 +115,12 @@ Given the high speed of development in the first phase, changes are being report
|
|||
|
||||
- Removed legacy `pusher` script and `local` backend.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed support for Z-Wave switches.
|
||||
|
||||
- Fixed possible race condition on VLC stop.
|
||||
|
||||
## [0.20.5] - 2021-03-12
|
||||
|
||||
### Added
|
||||
|
|
10
README.md
10
README.md
|
@ -7,6 +7,8 @@ Platypush
|
|||
[![License](https://img.shields.io/github/license/BlackLight/platypush.svg)](https://git.platypush.tech/platypush/platypush/-/blob/master/LICENSE.txt)
|
||||
[![Last Commit](https://img.shields.io/github/last-commit/BlackLight/platypush.svg)](https://git.platypush.tech/platypush/platypush/-/commits/master/)
|
||||
[![Contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://git.platypush.tech/platypush/platypush/-/blob/master/CONTRIBUTING.md)
|
||||
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/BlackLight/platypush.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/BlackLight/platypush/context:python)
|
||||
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/BlackLight/platypush.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/BlackLight/platypush/context:javascript)
|
||||
|
||||
- Recommended read: [**Getting started with Platypush**](https://blog.platypush.tech/article/Ultimate-self-hosted-automation-with-Platypush).
|
||||
|
||||
|
@ -474,9 +476,15 @@ platydock stop device_id
|
|||
4. Remove the instance:
|
||||
|
||||
```shell
|
||||
platyvdock rm device_id
|
||||
platydock rm device_id
|
||||
```
|
||||
|
||||
## Mobile app
|
||||
|
||||
An [official Android app](https://f-droid.org/en/packages/tech.platypush.platypush/) is provided on the F-Droid store.
|
||||
It allows to easily discover and manage multiple Platypush services on a network through the web interface, and it
|
||||
easily brings the power of Platypush to your fingertips.
|
||||
|
||||
## Tests
|
||||
|
||||
To run the tests simply run `pytest` either from the project root folder or the `tests/` folder.
|
||||
|
|
59
docs/source/_ext/sphinx_marshmallow.py
Normal file
59
docs/source/_ext/sphinx_marshmallow.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
import importlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from typing import Union, List
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive
|
||||
|
||||
|
||||
class SchemaDirective(Directive):
|
||||
"""
|
||||
Support for response/message schemas in the docs. Format: ``.. schema:: rel_path.SchemaClass(arg1=value1, ...)``,
|
||||
where ``rel_path`` is the path of the schema relative to ``platypush/schemas``.
|
||||
"""
|
||||
has_content = True
|
||||
_schema_regex = re.compile(r'^\s*(.+?)\s*(\((.+?)\))?\s*$')
|
||||
_schemas_path = os.path.abspath(
|
||||
os.path.join(
|
||||
os.path.dirname(os.path.relpath(__file__)), '..', '..', '..', 'platypush', 'schemas'))
|
||||
|
||||
sys.path.insert(0, _schemas_path)
|
||||
|
||||
@staticmethod
|
||||
def _get_field_value(field) -> str:
|
||||
metadata = getattr(field, 'metadata', {})
|
||||
return metadata.get('example', metadata.get('description', str(field.__class__.__name__).lower()))
|
||||
|
||||
def _parse_schema(self) -> Union[dict, List[dict]]:
|
||||
m = self._schema_regex.match('\n'.join(self.content))
|
||||
schema_module_name = '.'.join(['platypush.schemas', *(m.group(1).split('.')[:-1])])
|
||||
schema_module = importlib.import_module(schema_module_name)
|
||||
schema_class = getattr(schema_module, m.group(1).split('.')[-1])
|
||||
schema_args = eval(f'dict({m.group(3)})')
|
||||
schema = schema_class(**schema_args)
|
||||
output = {
|
||||
name: self._get_field_value(field)
|
||||
for name, field in schema.fields.items()
|
||||
if not field.load_only
|
||||
}
|
||||
|
||||
return [output] if schema.many else output
|
||||
|
||||
def run(self):
|
||||
content = json.dumps(self._parse_schema(), sort_keys=True, indent=2)
|
||||
block = nodes.literal_block(content, content)
|
||||
block['language'] = 'json'
|
||||
return [block]
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_directive('schema', SchemaDirective)
|
||||
|
||||
return {
|
||||
'version': '0.1',
|
||||
'parallel_read_safe': True,
|
||||
'parallel_write_safe': True,
|
||||
}
|
|
@ -32,6 +32,8 @@ Backends
|
|||
platypush/backend/http.poll.rst
|
||||
platypush/backend/inotify.rst
|
||||
platypush/backend/joystick.rst
|
||||
platypush/backend/joystick.jstest.rst
|
||||
platypush/backend/joystick.linux.rst
|
||||
platypush/backend/kafka.rst
|
||||
platypush/backend/light.hue.rst
|
||||
platypush/backend/linode.rst
|
||||
|
@ -42,6 +44,7 @@ Backends
|
|||
platypush/backend/music.mopidy.rst
|
||||
platypush/backend/music.mpd.rst
|
||||
platypush/backend/music.snapcast.rst
|
||||
platypush/backend/music.spotify.connect.rst
|
||||
platypush/backend/nextcloud.rst
|
||||
platypush/backend/nfc.rst
|
||||
platypush/backend/nodered.rst
|
||||
|
@ -80,3 +83,4 @@ Backends
|
|||
platypush/backend/wiimote.rst
|
||||
platypush/backend/zigbee.mqtt.rst
|
||||
platypush/backend/zwave.rst
|
||||
platypush/backend/zwave.mqtt.rst
|
||||
|
|
|
@ -18,6 +18,7 @@ import sys
|
|||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
sys.path.insert(0, os.path.abspath("./_ext"))
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
@ -50,6 +51,7 @@ extensions = [
|
|||
'sphinx.ext.viewcode',
|
||||
'sphinx.ext.githubpages',
|
||||
'sphinx_rtd_theme',
|
||||
'sphinx_marshmallow',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
|
@ -134,6 +136,11 @@ html_theme_options = {
|
|||
'title': 'Firefox Extension',
|
||||
'internal': False,
|
||||
},
|
||||
{
|
||||
'href': 'https://f-droid.org/en/packages/tech.platypush.platypush/',
|
||||
'title': 'Android App',
|
||||
'internal': False,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ Events
|
|||
platypush/events/gps.rst
|
||||
platypush/events/http.rst
|
||||
platypush/events/http.hook.rst
|
||||
platypush/events/http.ota.booking.rst
|
||||
platypush/events/http.rss.rst
|
||||
platypush/events/inotify.rst
|
||||
platypush/events/joystick.rst
|
||||
|
|
5
docs/source/platypush/backend/joystick.jstest.rst
Normal file
5
docs/source/platypush/backend/joystick.jstest.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
``platypush.backend.joystick.jstest``
|
||||
=====================================
|
||||
|
||||
.. automodule:: platypush.backend.joystick.jstest
|
||||
:members:
|
5
docs/source/platypush/backend/joystick.linux.rst
Normal file
5
docs/source/platypush/backend/joystick.linux.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
``platypush.backend.joystick.linux``
|
||||
====================================
|
||||
|
||||
.. automodule:: platypush.backend.joystick.linux
|
||||
:members:
|
5
docs/source/platypush/backend/music.spotify.connect.rst
Normal file
5
docs/source/platypush/backend/music.spotify.connect.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
``platypush.backend.music.spotify.connect``
|
||||
===========================================
|
||||
|
||||
.. automodule:: platypush.backend.music.spotify.connect
|
||||
:members:
|
5
docs/source/platypush/backend/zwave.mqtt.rst
Normal file
5
docs/source/platypush/backend/zwave.mqtt.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
``platypush.backend.zwave.mqtt``
|
||||
================================
|
||||
|
||||
.. automodule:: platypush.backend.zwave.mqtt
|
||||
:members:
|
|
@ -1,5 +0,0 @@
|
|||
``platypush.message.event.http.ota.booking``
|
||||
============================================
|
||||
|
||||
.. automodule:: platypush.message.event.http.ota.booking
|
||||
:members:
|
|
@ -1,5 +0,0 @@
|
|||
``platypush.plugins.http.request.ota.booking``
|
||||
==============================================
|
||||
|
||||
.. automodule:: platypush.plugins.http.request.ota.booking
|
||||
:members:
|
5
docs/source/platypush/plugins/pwm.pca9685.rst
Normal file
5
docs/source/platypush/plugins/pwm.pca9685.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
``platypush.plugins.pwm.pca9685``
|
||||
=================================
|
||||
|
||||
.. automodule:: platypush.plugins.pwm.pca9685
|
||||
:members:
|
|
@ -1,6 +0,0 @@
|
|||
``platypush.plugins.switch.switchbot``
|
||||
======================================
|
||||
|
||||
.. automodule:: platypush.plugins.switch.switchbot
|
||||
:members:
|
||||
|
5
docs/source/platypush/plugins/switchbot.bluetooth.rst
Normal file
5
docs/source/platypush/plugins/switchbot.bluetooth.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
``platypush.plugins.switchbot.bluetooth``
|
||||
=========================================
|
||||
|
||||
.. automodule:: platypush.plugins.switchbot.bluetooth
|
||||
:members:
|
5
docs/source/platypush/plugins/switchbot.rst
Normal file
5
docs/source/platypush/plugins/switchbot.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
``platypush.plugins.switchbot``
|
||||
===============================
|
||||
|
||||
.. automodule:: platypush.plugins.switchbot
|
||||
:members:
|
|
@ -1,5 +0,0 @@
|
|||
``platypush.plugins.video.torrentcast``
|
||||
=======================================
|
||||
|
||||
.. automodule:: platypush.plugins.video.torrentcast
|
||||
:members:
|
5
docs/source/platypush/plugins/zwave._base.rst
Normal file
5
docs/source/platypush/plugins/zwave._base.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
``platypush.plugins.zwave._base``
|
||||
=================================
|
||||
|
||||
.. automodule:: platypush.plugins.zwave._base
|
||||
:members:
|
5
docs/source/platypush/plugins/zwave.mqtt.rst
Normal file
5
docs/source/platypush/plugins/zwave.mqtt.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
``platypush.plugins.zwave.mqtt``
|
||||
================================
|
||||
|
||||
.. automodule:: platypush.plugins.zwave.mqtt
|
||||
:members:
|
|
@ -61,7 +61,6 @@ Plugins
|
|||
platypush/plugins/graphite.rst
|
||||
platypush/plugins/homeseer.rst
|
||||
platypush/plugins/http.request.rst
|
||||
platypush/plugins/http.request.ota.booking.rst
|
||||
platypush/plugins/http.request.rss.rst
|
||||
platypush/plugins/http.webpage.rst
|
||||
platypush/plugins/ifttt.rst
|
||||
|
@ -105,6 +104,7 @@ Plugins
|
|||
platypush/plugins/ping.rst
|
||||
platypush/plugins/printer.cups.rst
|
||||
platypush/plugins/pushbullet.rst
|
||||
platypush/plugins/pwm.pca9685.rst
|
||||
platypush/plugins/qrcode.rst
|
||||
platypush/plugins/redis.rst
|
||||
platypush/plugins/rtorrent.rst
|
||||
|
@ -119,9 +119,10 @@ Plugins
|
|||
platypush/plugins/stt.picovoice.hotword.rst
|
||||
platypush/plugins/stt.picovoice.speech.rst
|
||||
platypush/plugins/switch.rst
|
||||
platypush/plugins/switch.switchbot.rst
|
||||
platypush/plugins/switch.tplink.rst
|
||||
platypush/plugins/switch.wemo.rst
|
||||
platypush/plugins/switchbot.rst
|
||||
platypush/plugins/switchbot.bluetooth.rst
|
||||
platypush/plugins/system.rst
|
||||
platypush/plugins/tcp.rst
|
||||
platypush/plugins/tensorflow.rst
|
||||
|
@ -137,7 +138,6 @@ Plugins
|
|||
platypush/plugins/user.rst
|
||||
platypush/plugins/utils.rst
|
||||
platypush/plugins/variable.rst
|
||||
platypush/plugins/video.torrentcast.rst
|
||||
platypush/plugins/weather.rst
|
||||
platypush/plugins/weather.buienradar.rst
|
||||
platypush/plugins/weather.darksky.rst
|
||||
|
@ -147,3 +147,5 @@ Plugins
|
|||
platypush/plugins/zeroconf.rst
|
||||
platypush/plugins/zigbee.mqtt.rst
|
||||
platypush/plugins/zwave.rst
|
||||
platypush/plugins/zwave._base.rst
|
||||
platypush/plugins/zwave.mqtt.rst
|
||||
|
|
|
@ -24,7 +24,7 @@ from .utils import set_thread_name
|
|||
|
||||
|
||||
__author__ = 'Fabio Manganiello <info@fabiomanganiello.com>'
|
||||
__version__ = '0.20.6'
|
||||
__version__ = '0.21.1'
|
||||
|
||||
logger = logging.getLogger('platypush')
|
||||
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
import logging
|
||||
import re
|
||||
import socket
|
||||
import threading
|
||||
import time
|
||||
|
||||
from threading import Thread
|
||||
from threading import Thread, Event as ThreadEvent, get_ident
|
||||
from typing import Optional, Dict
|
||||
|
||||
from platypush.bus import Bus
|
||||
|
@ -62,7 +61,7 @@ class Backend(Thread, EventGenerator):
|
|||
self.poll_seconds = float(poll_seconds) if poll_seconds else None
|
||||
self.device_id = Config.get('device_id')
|
||||
self.thread_id = None
|
||||
self._stop_event = threading.Event()
|
||||
self._stop_event = ThreadEvent()
|
||||
self._kwargs = kwargs
|
||||
self.logger = logging.getLogger('platypush:backend:' + get_backend_name_by_class(self.__class__))
|
||||
self.zeroconf = None
|
||||
|
@ -220,7 +219,7 @@ class Backend(Thread, EventGenerator):
|
|||
|
||||
def run(self):
|
||||
""" Starts the backend thread. To be implemented in the derived classes if the loop method isn't defined. """
|
||||
self.thread_id = threading.get_ident()
|
||||
self.thread_id = get_ident()
|
||||
set_thread_name(self._thread_name)
|
||||
if not callable(self.loop):
|
||||
return
|
||||
|
|
|
@ -65,11 +65,11 @@ class AdafruitIoBackend(Backend):
|
|||
def on_message(self, msg):
|
||||
# noinspection PyUnusedLocal
|
||||
def _handler(client, feed, data):
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
data = float(data)
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
self.logger.debug('Not a number: {}: {}'.format(data, e))
|
||||
|
||||
self.bus.post(FeedUpdateEvent(feed=feed, data=data))
|
||||
|
||||
return _handler
|
||||
|
|
|
@ -55,16 +55,17 @@ class Alarm:
|
|||
self._runtime_snooze_interval = snooze_interval
|
||||
|
||||
def get_next(self) -> float:
|
||||
now = datetime.datetime.now().replace(tzinfo=gettz())
|
||||
now = datetime.datetime.now().replace(tzinfo=gettz()) # lgtm [py/call-to-non-callable]
|
||||
|
||||
try:
|
||||
cron = croniter.croniter(self.when, now)
|
||||
return cron.get_next()
|
||||
except (AttributeError, croniter.CroniterBadCronError):
|
||||
try:
|
||||
timestamp = datetime.datetime.fromisoformat(self.when).replace(tzinfo=gettz())
|
||||
timestamp = datetime.datetime.fromisoformat(self.when).replace(
|
||||
tzinfo=gettz()) # lgtm [py/call-to-non-callable]
|
||||
except (TypeError, ValueError):
|
||||
timestamp = (datetime.datetime.now().replace(tzinfo=gettz()) +
|
||||
timestamp = (datetime.datetime.now().replace(tzinfo=gettz()) + # lgtm [py/call-to-non-callable]
|
||||
datetime.timedelta(seconds=int(self.when)))
|
||||
|
||||
return timestamp.timestamp() if timestamp >= now else None
|
||||
|
|
|
@ -13,25 +13,28 @@ Bd addr are represented as standard python strings, e.g. "aa:bb:cc:dd:ee:ff".
|
|||
import asyncio
|
||||
from enum import Enum
|
||||
from collections import namedtuple
|
||||
import time
|
||||
import struct
|
||||
import itertools
|
||||
|
||||
|
||||
class CreateConnectionChannelError(Enum):
|
||||
NoError = 0
|
||||
MaxPendingConnectionsReached = 1
|
||||
|
||||
|
||||
class ConnectionStatus(Enum):
|
||||
Disconnected = 0
|
||||
Connected = 1
|
||||
Ready = 2
|
||||
|
||||
|
||||
class DisconnectReason(Enum):
|
||||
Unspecified = 0
|
||||
ConnectionEstablishmentFailed = 1
|
||||
TimedOut = 2
|
||||
BondingKeysMismatch = 3
|
||||
|
||||
|
||||
class RemovedReason(Enum):
|
||||
RemovedByThisClient = 0
|
||||
ForceDisconnectedByThisClient = 1
|
||||
|
@ -44,6 +47,7 @@ class RemovedReason(Enum):
|
|||
|
||||
CouldntLoadDevice = 7
|
||||
|
||||
|
||||
class ClickType(Enum):
|
||||
ButtonDown = 0
|
||||
ButtonUp = 1
|
||||
|
@ -52,20 +56,24 @@ class ClickType(Enum):
|
|||
ButtonDoubleClick = 4
|
||||
ButtonHold = 5
|
||||
|
||||
|
||||
class BdAddrType(Enum):
|
||||
PublicBdAddrType = 0
|
||||
RandomBdAddrType = 1
|
||||
|
||||
|
||||
class LatencyMode(Enum):
|
||||
NormalLatency = 0
|
||||
LowLatency = 1
|
||||
HighLatency = 2
|
||||
|
||||
|
||||
class BluetoothControllerState(Enum):
|
||||
Detached = 0
|
||||
Resetting = 1
|
||||
Attached = 2
|
||||
|
||||
|
||||
class ScanWizardResult(Enum):
|
||||
WizardSuccess = 0
|
||||
WizardCancelledByUser = 1
|
||||
|
@ -75,6 +83,7 @@ class ScanWizardResult(Enum):
|
|||
WizardInternetBackendError = 5
|
||||
WizardInvalidData = 6
|
||||
|
||||
|
||||
class ButtonScanner:
|
||||
"""ButtonScanner class.
|
||||
|
||||
|
@ -90,6 +99,7 @@ class ButtonScanner:
|
|||
self._scan_id = next(ButtonScanner._cnt)
|
||||
self.on_advertisement_packet = lambda scanner, bd_addr, name, rssi, is_private, already_verified: None
|
||||
|
||||
|
||||
class ScanWizard:
|
||||
"""ScanWizard class
|
||||
|
||||
|
@ -113,6 +123,7 @@ class ScanWizard:
|
|||
self.on_button_connected = lambda scan_wizard, bd_addr, name: None
|
||||
self.on_completed = lambda scan_wizard, result, bd_addr, name: None
|
||||
|
||||
|
||||
class ButtonConnectionChannel:
|
||||
"""ButtonConnectionChannel class.
|
||||
|
||||
|
@ -164,7 +175,9 @@ class ButtonConnectionChannel:
|
|||
|
||||
self._latency_mode = latency_mode
|
||||
if not self._client._closed:
|
||||
self._client._send_command("CmdChangeModeParameters", {"conn_id": self._conn_id, "latency_mode": self._latency_mode, "auto_disconnect_time": self._auto_disconnect_time})
|
||||
self._client._send_command("CmdChangeModeParameters",
|
||||
{"conn_id": self._conn_id, "latency_mode": self._latency_mode,
|
||||
"auto_disconnect_time": self._auto_disconnect_time})
|
||||
|
||||
@property
|
||||
def auto_disconnect_time(self):
|
||||
|
@ -178,7 +191,10 @@ class ButtonConnectionChannel:
|
|||
|
||||
self._auto_disconnect_time = auto_disconnect_time
|
||||
if not self._client._closed:
|
||||
self._client._send_command("CmdChangeModeParameters", {"conn_id": self._conn_id, "latency_mode": self._latency_mode, "auto_disconnect_time": self._auto_disconnect_time})
|
||||
self._client._send_command("CmdChangeModeParameters",
|
||||
{"conn_id": self._conn_id, "latency_mode": self._latency_mode,
|
||||
"auto_disconnect_time": self._auto_disconnect_time})
|
||||
|
||||
|
||||
class FlicClient(asyncio.Protocol):
|
||||
"""FlicClient class.
|
||||
|
@ -212,7 +228,8 @@ class FlicClient(asyncio.Protocol):
|
|||
("EvtButtonSingleOrDoubleClick", "<IBBI", "conn_id click_type was_queued time_diff"),
|
||||
("EvtButtonSingleOrDoubleClickOrHold", "<IBBI", "conn_id click_type was_queued time_diff"),
|
||||
("EvtNewVerifiedButton", "<6s", "bd_addr"),
|
||||
("EvtGetInfoResponse", "<B6sBBhBBH", "bluetooth_controller_state my_bd_addr my_bd_addr_type max_pending_connections max_concurrently_connected_buttons current_pending_connections currently_no_space_for_new_connection nb_verified_buttons"),
|
||||
("EvtGetInfoResponse", "<B6sBBhBBH",
|
||||
"bluetooth_controller_state my_bd_addr my_bd_addr_type max_pending_connections max_concurrently_connected_buttons current_pending_connections currently_no_space_for_new_connection nb_verified_buttons"),
|
||||
("EvtNoSpaceForNewConnection", "<B", "max_concurrently_connected_buttons"),
|
||||
("EvtGotSpaceForNewConnection", "<B", "max_concurrently_connected_buttons"),
|
||||
("EvtBluetoothControllerStateChange", "<B", "state"),
|
||||
|
@ -223,8 +240,8 @@ class FlicClient(asyncio.Protocol):
|
|||
("EvtScanWizardButtonConnected", "<I", "scan_wizard_id"),
|
||||
("EvtScanWizardCompleted", "<IB", "scan_wizard_id result")
|
||||
]
|
||||
_EVENT_STRUCTS = list(map(lambda x: None if x == None else struct.Struct(x[1]), _EVENTS))
|
||||
_EVENT_NAMED_TUPLES = list(map(lambda x: None if x == None else namedtuple(x[0], x[2]), _EVENTS))
|
||||
_EVENT_STRUCTS = list(map(lambda x: None if x is None else struct.Struct(x[1]), _EVENTS))
|
||||
_EVENT_NAMED_TUPLES = list(map(lambda x: None if x is None else namedtuple(x[0], x[2]), _EVENTS))
|
||||
|
||||
_COMMANDS = [
|
||||
("CmdGetInfo", "", ""),
|
||||
|
@ -244,10 +261,11 @@ class FlicClient(asyncio.Protocol):
|
|||
_COMMAND_NAMED_TUPLES = list(map(lambda x: namedtuple(x[0], x[2]), _COMMANDS))
|
||||
_COMMAND_NAME_TO_OPCODE = dict((x[0], i) for i, x in enumerate(_COMMANDS))
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _bdaddr_bytes_to_string(bdaddr_bytes):
|
||||
return ":".join(map(lambda x: "%02x" % x, reversed(bdaddr_bytes)))
|
||||
|
||||
@staticmethod
|
||||
def _bdaddr_string_to_bytes(bdaddr_string):
|
||||
return bytearray.fromhex("".join(reversed(bdaddr_string.split(":"))))
|
||||
|
||||
|
@ -273,7 +291,6 @@ class FlicClient(asyncio.Protocol):
|
|||
if self.parent:
|
||||
self.parent.register_protocol(self)
|
||||
|
||||
|
||||
def close(self):
|
||||
"""Closes the client. The handle_events() method will return."""
|
||||
if self._closed:
|
||||
|
@ -342,7 +359,9 @@ class FlicClient(asyncio.Protocol):
|
|||
channel._client = self
|
||||
|
||||
self._connection_channels[channel._conn_id] = channel
|
||||
self._send_command("CmdCreateConnectionChannel", {"conn_id": channel._conn_id, "bd_addr": channel.bd_addr, "latency_mode": channel._latency_mode, "auto_disconnect_time": channel._auto_disconnect_time})
|
||||
self._send_command("CmdCreateConnectionChannel", {"conn_id": channel._conn_id, "bd_addr": channel.bd_addr,
|
||||
"latency_mode": channel._latency_mode,
|
||||
"auto_disconnect_time": channel._auto_disconnect_time})
|
||||
|
||||
def remove_connection_channel(self, channel):
|
||||
"""Remove a connection channel.
|
||||
|
@ -384,7 +403,6 @@ class FlicClient(asyncio.Protocol):
|
|||
"""
|
||||
self._send_command("CmdGetButtonUUID", {"bd_addr": bd_addr})
|
||||
|
||||
|
||||
def run_on_handle_events_thread(self, callback):
|
||||
"""Run a function on the thread that handles the events."""
|
||||
if threading.get_ident() == self._handle_event_thread_ident:
|
||||
|
@ -399,7 +417,7 @@ class FlicClient(asyncio.Protocol):
|
|||
items[key] = value.value
|
||||
|
||||
if "bd_addr" in items:
|
||||
items["bd_addr"] = FlicClient._bdaddr_string_to_bytes(items["bd_addr"])
|
||||
items["bd_addr"] = FlicClient._bdaddr_string_to_bytes()
|
||||
|
||||
opcode = FlicClient._COMMAND_NAME_TO_OPCODE[name]
|
||||
data_bytes = FlicClient._COMMAND_STRUCTS[opcode].pack(*FlicClient._COMMAND_NAMED_TUPLES[opcode](**items))
|
||||
|
@ -415,7 +433,7 @@ class FlicClient(asyncio.Protocol):
|
|||
return
|
||||
opcode = data[0]
|
||||
|
||||
if opcode >= len(FlicClient._EVENTS) or FlicClient._EVENTS[opcode] == None:
|
||||
if opcode >= len(FlicClient._EVENTS) or FlicClient._EVENTS[opcode] is None:
|
||||
return
|
||||
|
||||
event_name = FlicClient._EVENTS[opcode][0]
|
||||
|
@ -424,7 +442,7 @@ class FlicClient(asyncio.Protocol):
|
|||
|
||||
# Process some kind of items whose data type is not supported by struct
|
||||
if "bd_addr" in items:
|
||||
items["bd_addr"] = FlicClient._bdaddr_bytes_to_string(items["bd_addr"])
|
||||
items["bd_addr"] = FlicClient._bdaddr_bytes_to_string()
|
||||
|
||||
if "name" in items:
|
||||
items["name"] = items["name"].decode("utf-8")
|
||||
|
@ -445,13 +463,14 @@ class FlicClient(asyncio.Protocol):
|
|||
|
||||
if event_name == "EvtGetInfoResponse":
|
||||
items["bluetooth_controller_state"] = BluetoothControllerState(items["bluetooth_controller_state"])
|
||||
items["my_bd_addr"] = FlicClient._bdaddr_bytes_to_string(items["my_bd_addr"])
|
||||
items["my_bd_addr"] = FlicClient._bdaddr_bytes_to_string()
|
||||
items["my_bd_addr_type"] = BdAddrType(items["my_bd_addr_type"])
|
||||
items["bd_addr_of_verified_buttons"] = []
|
||||
|
||||
pos = FlicClient._EVENT_STRUCTS[opcode].size
|
||||
for i in range(items["nb_verified_buttons"]):
|
||||
items["bd_addr_of_verified_buttons"].append(FlicClient._bdaddr_bytes_to_string(data[1 + pos : 1 + pos + 6]))
|
||||
items["bd_addr_of_verified_buttons"].append(
|
||||
FlicClient._bdaddr_bytes_to_string())
|
||||
pos += 6
|
||||
|
||||
if event_name == "EvtBluetoothControllerStateChange":
|
||||
|
@ -469,7 +488,8 @@ class FlicClient(asyncio.Protocol):
|
|||
if event_name == "EvtAdvertisementPacket":
|
||||
scanner = self._scanners.get(items["scan_id"])
|
||||
if scanner is not None:
|
||||
scanner.on_advertisement_packet(scanner, items["bd_addr"], items["name"], items["rssi"], items["is_private"], items["already_verified"])
|
||||
scanner.on_advertisement_packet(scanner, items["bd_addr"], items["name"], items["rssi"],
|
||||
items["is_private"], items["already_verified"])
|
||||
|
||||
if event_name == "EvtCreateConnectionChannelResponse":
|
||||
channel = self._connection_channels[items["conn_id"]]
|
||||
|
@ -494,10 +514,12 @@ class FlicClient(asyncio.Protocol):
|
|||
channel.on_button_click_or_hold(channel, items["click_type"], items["was_queued"], items["time_diff"])
|
||||
if event_name == "EvtButtonSingleOrDoubleClick":
|
||||
channel = self._connection_channels[items["conn_id"]]
|
||||
channel.on_button_single_or_double_click(channel, items["click_type"], items["was_queued"], items["time_diff"])
|
||||
channel.on_button_single_or_double_click(channel, items["click_type"], items["was_queued"],
|
||||
items["time_diff"])
|
||||
if event_name == "EvtButtonSingleOrDoubleClickOrHold":
|
||||
channel = self._connection_channels[items["conn_id"]]
|
||||
channel.on_button_single_or_double_click_or_hold(channel, items["click_type"], items["was_queued"], items["time_diff"])
|
||||
channel.on_button_single_or_double_click_or_hold(channel, items["click_type"], items["was_queued"],
|
||||
items["time_diff"])
|
||||
|
||||
if event_name == "EvtNewVerifiedButton":
|
||||
self.on_new_verified_button(items["bd_addr"])
|
||||
|
@ -536,7 +558,6 @@ class FlicClient(asyncio.Protocol):
|
|||
del self._scan_wizards[items["scan_wizard_id"]]
|
||||
scan_wizard.on_completed(scan_wizard, items["result"], scan_wizard._bd_addr, scan_wizard._name)
|
||||
|
||||
|
||||
def data_received(self, data):
|
||||
cdata = self.buffer + data
|
||||
self.buffer = b""
|
||||
|
@ -550,5 +571,3 @@ class FlicClient(asyncio.Protocol):
|
|||
if len(cdata):
|
||||
self.buffer = cdata # unlikely to happen but.....
|
||||
break
|
||||
|
||||
|
||||
|
|
|
@ -229,8 +229,8 @@ class FlicClient:
|
|||
("EvtScanWizardButtonConnected", "<I", "scan_wizard_id"),
|
||||
("EvtScanWizardCompleted", "<IB", "scan_wizard_id result")
|
||||
]
|
||||
_EVENT_STRUCTS = list(map(lambda x: None if x == None else struct.Struct(x[1]), _EVENTS))
|
||||
_EVENT_NAMED_TUPLES = list(map(lambda x: None if x == None else namedtuple(x[0], x[2]), _EVENTS))
|
||||
_EVENT_STRUCTS = list(map(lambda x: None if x is None else struct.Struct(x[1]), _EVENTS))
|
||||
_EVENT_NAMED_TUPLES = list(map(lambda x: None if x is None else namedtuple(x[0], x[2]), _EVENTS))
|
||||
|
||||
_COMMANDS = [
|
||||
("CmdGetInfo", "", ""),
|
||||
|
@ -250,9 +250,11 @@ class FlicClient:
|
|||
_COMMAND_NAMED_TUPLES = list(map(lambda x: namedtuple(x[0], x[2]), _COMMANDS))
|
||||
_COMMAND_NAME_TO_OPCODE = dict((x[0], i) for i, x in enumerate(_COMMANDS))
|
||||
|
||||
@staticmethod
|
||||
def _bdaddr_bytes_to_string(bdaddr_bytes):
|
||||
return ":".join(map(lambda x: "%02x" % x, reversed(bdaddr_bytes)))
|
||||
|
||||
@staticmethod
|
||||
def _bdaddr_string_to_bytes(bdaddr_string):
|
||||
return bytearray.fromhex("".join(reversed(bdaddr_string.split(":"))))
|
||||
|
||||
|
@ -438,7 +440,7 @@ class FlicClient:
|
|||
return
|
||||
opcode = data[0]
|
||||
|
||||
if opcode >= len(FlicClient._EVENTS) or FlicClient._EVENTS[opcode] == None:
|
||||
if opcode >= len(FlicClient._EVENTS) or FlicClient._EVENTS[opcode] is None:
|
||||
return
|
||||
|
||||
event_name = FlicClient._EVENTS[opcode][0]
|
||||
|
|
|
@ -34,7 +34,7 @@ class CameraPiBackend(Backend):
|
|||
return self.value == other
|
||||
|
||||
# noinspection PyUnresolvedReferences,PyPackageRequirements
|
||||
def __init__(self, listen_port, x_resolution=640, y_resolution=480,
|
||||
def __init__(self, listen_port, bind_address='0.0.0.0', x_resolution=640, y_resolution=480,
|
||||
redis_queue='platypush/camera/pi',
|
||||
start_recording_on_startup=True,
|
||||
framerate=24, hflip=False, vflip=False,
|
||||
|
@ -49,13 +49,17 @@ class CameraPiBackend(Backend):
|
|||
|
||||
:param listen_port: Port where the camera process will provide the video output while recording
|
||||
:type listen_port: int
|
||||
|
||||
:param bind_address: Bind address (default: 0.0.0.0).
|
||||
:type bind_address: str
|
||||
"""
|
||||
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self.bind_address = bind_address
|
||||
self.listen_port = listen_port
|
||||
self.server_socket = socket.socket()
|
||||
self.server_socket.bind(('0.0.0.0', self.listen_port))
|
||||
self.server_socket.bind((self.bind_address, self.listen_port))
|
||||
self.server_socket.listen(0)
|
||||
|
||||
import picamera
|
||||
|
@ -134,13 +138,13 @@ class CameraPiBackend(Backend):
|
|||
self.logger.info('Client closed connection')
|
||||
try:
|
||||
self.stop_recording()
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
self.logger.warning('Could not stop recording: {}'.format(str(e)))
|
||||
|
||||
try:
|
||||
connection.close()
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
self.logger.warning('Could not close connection: {}'.format(str(e)))
|
||||
|
||||
self.send_camera_action(self.CameraAction.START_RECORDING)
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ class EventHandler(FileSystemEventHandler):
|
|||
def on_modified(self, event):
|
||||
get_bus().post(FileSystemModifyEvent(path=event.src_path, is_directory=event.is_directory))
|
||||
|
||||
def on_moved(self, event):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def from_resource(cls, resource: MonitoredResource):
|
||||
if isinstance(resource, MonitoredPattern):
|
||||
|
|
|
@ -51,11 +51,10 @@ class GooglePubsubBackend(Backend):
|
|||
def _message_callback(self, topic):
|
||||
def callback(msg):
|
||||
data = msg.data.decode()
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
data = json.loads(data)
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
self.logger.debug('Not a valid JSON: {}: {}'.format(data, str(e)))
|
||||
|
||||
msg.ack()
|
||||
self.bus.post(GooglePubsubMessageEvent(topic=topic, msg=data))
|
||||
|
|
|
@ -31,8 +31,8 @@ def _hook(hook_name):
|
|||
# noinspection PyBroadException
|
||||
try:
|
||||
event_args['data'] = json.loads(event_args['data'])
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger().warning('Not a valid JSON string: {}: {}'.format(event_args['data'], str(e)))
|
||||
|
||||
event = WebhookEvent(**event_args)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ def login():
|
|||
if session_token:
|
||||
user, session = user_manager.authenticate_user_session(session_token)
|
||||
if user:
|
||||
return redirect(redirect_page, 302)
|
||||
return redirect(redirect_page, 302) # lgtm [py/url-redirection]
|
||||
|
||||
if request.form:
|
||||
username = request.form.get('username')
|
||||
|
@ -44,7 +44,7 @@ def login():
|
|||
expires_at=expires)
|
||||
|
||||
if session:
|
||||
redirect_target = redirect(redirect_page, 302)
|
||||
redirect_target = redirect(redirect_page, 302) # lgtm [py/url-redirection]
|
||||
response = make_response(redirect_target)
|
||||
response.set_cookie('session_token', session.session_token, expires=expires)
|
||||
return response
|
||||
|
|
|
@ -25,7 +25,7 @@ def logout():
|
|||
if not user:
|
||||
return abort(403, 'Invalid session token')
|
||||
|
||||
redirect_target = redirect(redirect_page, 302)
|
||||
redirect_target = redirect(redirect_page, 302) # lgtm [py/url-redirection]
|
||||
response = make_response(redirect_target)
|
||||
response.set_cookie('session_token', '', expires=0)
|
||||
return response
|
||||
|
|
|
@ -45,14 +45,12 @@ def get_args(kwargs):
|
|||
if k == 'resolution':
|
||||
v = json.loads('[{}]'.format(v))
|
||||
else:
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
v = int(v)
|
||||
except:
|
||||
# noinspection PyBroadException
|
||||
except (ValueError, TypeError):
|
||||
try:
|
||||
v = float(v)
|
||||
except:
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
|
||||
kwargs[k] = v
|
||||
|
|
|
@ -32,8 +32,8 @@ def add_media():
|
|||
args = {}
|
||||
try:
|
||||
args = json.loads(request.data.decode('utf-8'))
|
||||
except:
|
||||
abort(400, 'Invalid JSON request')
|
||||
except Exception as e:
|
||||
abort(400, 'Invalid JSON request: {}'.format(str(e)))
|
||||
|
||||
source = args.get('source')
|
||||
if not source:
|
||||
|
|
|
@ -40,7 +40,7 @@ def audio_feed(device, fifo, sample_rate, blocksize, latency, channels):
|
|||
channels=channels)
|
||||
|
||||
try:
|
||||
with open(fifo, 'rb') as f:
|
||||
with open(fifo, 'rb') as f: # lgtm [py/path-injection]
|
||||
send_header = True
|
||||
|
||||
while True:
|
||||
|
|
|
@ -31,10 +31,10 @@ def register():
|
|||
if session_token:
|
||||
user, session = user_manager.authenticate_user_session(session_token)
|
||||
if user:
|
||||
return redirect(redirect_page, 302)
|
||||
return redirect(redirect_page, 302) # lgtm [py/url-redirection]
|
||||
|
||||
if user_manager.get_user_count() > 0:
|
||||
return redirect('/login?redirect=' + redirect_page, 302)
|
||||
return redirect('/login?redirect=' + redirect_page, 302) # lgtm [py/url-redirection]
|
||||
|
||||
if request.form:
|
||||
username = request.form.get('username')
|
||||
|
@ -49,7 +49,7 @@ def register():
|
|||
if not remember else None)
|
||||
|
||||
if session:
|
||||
redirect_target = redirect(redirect_page, 302)
|
||||
redirect_target = redirect(redirect_page, 302) # lgtm [py/url-redirection]
|
||||
response = make_response(redirect_target)
|
||||
response.set_cookie('session_token', session.session_token)
|
||||
return response
|
||||
|
|
|
@ -123,7 +123,8 @@ def _authenticate_token():
|
|||
try:
|
||||
user_manager.validate_jwt_token(user_token)
|
||||
return True
|
||||
except:
|
||||
except Exception as e:
|
||||
logger().debug(str(e))
|
||||
return token and user_token == token
|
||||
|
||||
|
||||
|
|
|
@ -78,11 +78,11 @@ class HttpRequest(object):
|
|||
|
||||
def get_new_items(self, response):
|
||||
""" Gets new items out of a response """
|
||||
raise ("get_new_items must be implemented in a derived class")
|
||||
raise NotImplementedError("get_new_items must be implemented in a derived class")
|
||||
|
||||
def __iter__(self):
|
||||
for (key, value) in self.request_args.items():
|
||||
yield (key, value)
|
||||
yield key, value
|
||||
|
||||
|
||||
class JsonHttpRequest(HttpRequest):
|
||||
|
@ -96,7 +96,7 @@ class JsonHttpRequest(HttpRequest):
|
|||
new_entries = []
|
||||
|
||||
if self.path:
|
||||
m = re.match('\$\{\s*(.*)\s*\}', self.path)
|
||||
m = re.match(r'\${\s*(.*)\s*}', self.path)
|
||||
response = eval(m.group(1))
|
||||
|
||||
for entry in response:
|
||||
|
|
|
@ -238,15 +238,15 @@ class RssUpdates(HttpRequest):
|
|||
with open(digest_filename, 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
elif self.digest_format == 'pdf':
|
||||
import weasyprint
|
||||
from weasyprint import HTML, CSS
|
||||
from weasyprint.fonts import FontConfiguration
|
||||
|
||||
body_style = 'body { {body_style} }'.format(body_style=self.body_style)
|
||||
body_style = 'body { ' + self.body_style + ' }'
|
||||
font_config = FontConfiguration()
|
||||
css = [weasyprint.CSS('https://fonts.googleapis.com/css?family=Merriweather'),
|
||||
weasyprint.CSS(string=body_style, font_config=font_config)]
|
||||
css = [CSS('https://fonts.googleapis.com/css?family=Merriweather'),
|
||||
CSS(string=body_style, font_config=font_config)]
|
||||
|
||||
weasyprint.HTML(string=content).write_pdf(digest_filename, stylesheets=css)
|
||||
HTML(string=content).write_pdf(digest_filename, stylesheets=css)
|
||||
else:
|
||||
raise RuntimeError('Unsupported format: {}. Supported formats: ' +
|
||||
'html or pdf'.format(self.digest_format))
|
||||
|
|
|
@ -50,8 +50,6 @@ class HttpUtils(object):
|
|||
for name, resource_path in resource_dirs.items():
|
||||
resource_path = os.path.abspath(os.path.expanduser(resource_path))
|
||||
if directory.startswith(resource_path):
|
||||
subdir = re.sub('^{}(.*)$'.format(resource_path),
|
||||
'\\1', directory)
|
||||
uri = '/resources/' + name
|
||||
break
|
||||
|
||||
|
@ -96,6 +94,7 @@ class HttpUtils(object):
|
|||
|
||||
@classmethod
|
||||
def find_templates_in_dir(cls, directory):
|
||||
# noinspection PyTypeChecker
|
||||
return [
|
||||
os.path.join(directory, file)
|
||||
for root, path, files in os.walk(os.path.abspath(os.path.join(template_folder, directory)))
|
||||
|
|
File diff suppressed because one or more lines are too long
32
platypush/backend/http/webapp/dist/static/css/app.0ae429cb.css
vendored
Normal file
32
platypush/backend/http/webapp/dist/static/css/app.0ae429cb.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-0127d4fc.0fc27ef1.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-0127d4fc.0fc27ef1.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-01c1b3b0.f38204e8.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-01c1b3b0.f38204e8.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-06539e5d.a1e5b8ad.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-06539e5d.a1e5b8ad.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-07773226.bf94c219.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-07773226.bf94c219.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-0827360a.0c9d5664.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-0827360a.0c9d5664.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-09eaa919.4da4af10.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-09eaa919.4da4af10.css
vendored
Normal file
File diff suppressed because one or more lines are too long
4
platypush/backend/http/webapp/dist/static/css/chunk-14965a61.20f8e49a.css
vendored
Normal file
4
platypush/backend/http/webapp/dist/static/css/chunk-14965a61.20f8e49a.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-1b24f8bf.10a4b841.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-1b24f8bf.10a4b841.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-31bc5041.65dab894.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-31bc5041.65dab894.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-35986630.92c3169f.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-35986630.92c3169f.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-36760726.4bea643c.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-36760726.4bea643c.css
vendored
Normal file
File diff suppressed because one or more lines are too long
3
platypush/backend/http/webapp/dist/static/css/chunk-37779247.d6d725a4.css
vendored
Normal file
3
platypush/backend/http/webapp/dist/static/css/chunk-37779247.d6d725a4.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-40ee55e4.97d23aa3.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-40ee55e4.97d23aa3.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-41adab28.c654bf51.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-41adab28.c654bf51.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
9
platypush/backend/http/webapp/dist/static/css/chunk-43a68b48.e9fd2674.css
vendored
Normal file
9
platypush/backend/http/webapp/dist/static/css/chunk-43a68b48.e9fd2674.css
vendored
Normal file
File diff suppressed because one or more lines are too long
2
platypush/backend/http/webapp/dist/static/css/chunk-44b22f6e.b4d19e30.css
vendored
Normal file
2
platypush/backend/http/webapp/dist/static/css/chunk-44b22f6e.b4d19e30.css
vendored
Normal file
File diff suppressed because one or more lines are too long
5
platypush/backend/http/webapp/dist/static/css/chunk-49f94906.6c547a0d.css
vendored
Normal file
5
platypush/backend/http/webapp/dist/static/css/chunk-49f94906.6c547a0d.css
vendored
Normal file
File diff suppressed because one or more lines are too long
8
platypush/backend/http/webapp/dist/static/css/chunk-571780de.f8c325e0.css
vendored
Normal file
8
platypush/backend/http/webapp/dist/static/css/chunk-571780de.f8c325e0.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-57f8147d.51339170.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-57f8147d.51339170.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-5c4852cd.869eba6f.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-5c4852cd.869eba6f.css
vendored
Normal file
File diff suppressed because one or more lines are too long
6
platypush/backend/http/webapp/dist/static/css/chunk-5d57b054.50a9876f.css
vendored
Normal file
6
platypush/backend/http/webapp/dist/static/css/chunk-5d57b054.50a9876f.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-5d632024.fbdf52ee.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-5d632024.fbdf52ee.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-5d73ace1.e3e66d31.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-5d73ace1.e3e66d31.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-60dbbc82.db52ed87.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-60dbbc82.db52ed87.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-6ee47cbe.8815eb35.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-6ee47cbe.8815eb35.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-6f3814a8.2452b37a.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-6f3814a8.2452b37a.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-74fb6755.421a61ed.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-74fb6755.421a61ed.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-75e68c24.24b54184.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-75e68c24.24b54184.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-9684cd10.3f972fa6.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-9684cd10.3f972fa6.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
platypush/backend/http/webapp/dist/static/css/chunk-972487d6.6cf97e59.css
vendored
Normal file
1
platypush/backend/http/webapp/dist/static/css/chunk-972487d6.6cf97e59.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
platypush/backend/http/webapp/dist/static/css/chunk-a018ff46.68963710.css
vendored
Normal file
2
platypush/backend/http/webapp/dist/static/css/chunk-a018ff46.68963710.css
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue