forked from platypush/platypush
Merge branch 'master' into 311/auto-generate-deps-docs
This commit is contained in:
commit
0a3ec4b9f1
7 changed files with 28 additions and 14 deletions
|
@ -5,7 +5,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
from typing import Final, Optional, Sequence
|
from typing import Optional, Sequence
|
||||||
|
|
||||||
from platypush.config import Config
|
from platypush.config import Config
|
||||||
from platypush.utils.manifest import (
|
from platypush.utils.manifest import (
|
||||||
|
@ -29,7 +29,7 @@ class BaseBuilder(ABC):
|
||||||
and :module:`platypush.platydock` modules/scripts.
|
and :module:`platypush.platydock` modules/scripts.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
REPO_URL: Final[str] = 'https://github.com/BlackLight/platypush.git'
|
REPO_URL: str = 'https://github.com/BlackLight/platypush.git'
|
||||||
"""
|
"""
|
||||||
We use the Github URL here rather than the self-hosted Gitea URL to prevent
|
We use the Github URL here rather than the self-hosted Gitea URL to prevent
|
||||||
too many requests to the Gitea server.
|
too many requests to the Gitea server.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
from typing import Final, Optional
|
from typing import Optional
|
||||||
|
|
||||||
from platypush.bus import Bus
|
from platypush.bus import Bus
|
||||||
from platypush.message import Message
|
from platypush.message import Message
|
||||||
|
@ -13,7 +13,7 @@ class RedisBus(Bus):
|
||||||
Overrides the in-process in-memory local bus with a Redis bus
|
Overrides the in-process in-memory local bus with a Redis bus
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DEFAULT_REDIS_QUEUE: Final[str] = 'platypush/bus'
|
DEFAULT_REDIS_QUEUE: str = 'platypush/bus'
|
||||||
|
|
||||||
def __init__(self, *args, on_message=None, redis_queue=None, **kwargs):
|
def __init__(self, *args, on_message=None, redis_queue=None, **kwargs):
|
||||||
from platypush.utils import get_redis
|
from platypush.utils import get_redis
|
||||||
|
|
|
@ -7,7 +7,7 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Callable, Dict, Final, List, Optional, Set, Type, Tuple, Any
|
from typing import Callable, Dict, List, Optional, Set, Type, Tuple, Any
|
||||||
|
|
||||||
import pkgutil
|
import pkgutil
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ EntityKey = Tuple[str, str]
|
||||||
EntityMapping = Dict[EntityKey, 'Entity']
|
EntityMapping = Dict[EntityKey, 'Entity']
|
||||||
""" Internal mapping for entities used for deduplication/merge/upsert. """
|
""" Internal mapping for entities used for deduplication/merge/upsert. """
|
||||||
|
|
||||||
_import_error_ignored_modules: Final[Set[str]] = {'bluetooth'}
|
_import_error_ignored_modules: Set[str] = {'bluetooth'}
|
||||||
"""
|
"""
|
||||||
ImportError exceptions will be ignored for these entity submodules when
|
ImportError exceptions will be ignored for these entity submodules when
|
||||||
imported dynamically. An ImportError for these modules means that some optional
|
imported dynamically. An ImportError for these modules means that some optional
|
||||||
|
|
|
@ -469,8 +469,9 @@ class MqttPlugin(RunnablePlugin):
|
||||||
client.stop()
|
client.stop()
|
||||||
del client
|
del client
|
||||||
|
|
||||||
@staticmethod
|
def _response_callback(
|
||||||
def _response_callback(reply_topic: str, event: threading.Event, buffer: IO[bytes]):
|
self, reply_topic: str, event: threading.Event, buffer: IO[bytes]
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
A response callback that writes the response to an IOBuffer and stops
|
A response callback that writes the response to an IOBuffer and stops
|
||||||
the client loop.
|
the client loop.
|
||||||
|
@ -480,9 +481,15 @@ class MqttPlugin(RunnablePlugin):
|
||||||
if msg.topic != reply_topic:
|
if msg.topic != reply_topic:
|
||||||
return
|
return
|
||||||
|
|
||||||
buffer.write(msg.payload)
|
try:
|
||||||
client.loop_stop()
|
buffer.write(msg.payload)
|
||||||
event.set()
|
client.loop_stop()
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.warning(
|
||||||
|
'Could not write the response back to the MQTT client: %s', e
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
event.set()
|
||||||
|
|
||||||
return on_message
|
return on_message
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ from enum import IntEnum
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
from typing import Any, Callable, Dict, Final, Iterable, Optional, Union
|
from typing import Any, Callable, Dict, Iterable, Optional, Union
|
||||||
|
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
from platypush.config import Config
|
from platypush.config import Config
|
||||||
|
|
||||||
MqttCallback = Callable[["MqttClient", Any, mqtt.MQTTMessage], Any]
|
MqttCallback = Callable[["MqttClient", Any, mqtt.MQTTMessage], Any]
|
||||||
DEFAULT_TIMEOUT: Final[int] = 30
|
DEFAULT_TIMEOUT: int = 30
|
||||||
|
|
||||||
|
|
||||||
class MqttClient(mqtt.Client, threading.Thread):
|
class MqttClient(mqtt.Client, threading.Thread):
|
||||||
|
|
|
@ -72,7 +72,9 @@ class RssPlugin(RunnablePlugin):
|
||||||
t = var.get(varname)
|
t = var.get(varname)
|
||||||
|
|
||||||
if t:
|
if t:
|
||||||
return dateutil.parser.isoparse(t)
|
if not isinstance(t, datetime.datetime):
|
||||||
|
t = dateutil.parser.isoparse(t)
|
||||||
|
return t
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
5
setup.py
5
setup.py
|
@ -43,6 +43,11 @@ setup(
|
||||||
'migrations/alembic.ini',
|
'migrations/alembic.ini',
|
||||||
'migrations/alembic/*',
|
'migrations/alembic/*',
|
||||||
'migrations/alembic/**/*',
|
'migrations/alembic/**/*',
|
||||||
|
'install/**',
|
||||||
|
'install/scripts/*',
|
||||||
|
'install/scripts/**/*',
|
||||||
|
'install/requirements/*',
|
||||||
|
'install/docker/*',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
entry_points={
|
entry_points={
|
||||||
|
|
Loading…
Reference in a new issue