Merge branch 'master' into 29-generic-entities-support
This commit is contained in:
commit
5a47308516
7 changed files with 47 additions and 21 deletions
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -4,7 +4,24 @@ All notable changes to this project will be documented in this file.
|
||||||
Given the high speed of development in the first phase, changes are being
|
Given the high speed of development in the first phase, changes are being
|
||||||
reported only starting from v0.20.2.
|
reported only starting from v0.20.2.
|
||||||
|
|
||||||
## [0.24.0]
|
## [0.24.2] - 2022-12-10
|
||||||
|
|
||||||
|
## Fixed
|
||||||
|
|
||||||
|
- The `main.db` configuration should use the configured `workdir` when no
|
||||||
|
values are specified.
|
||||||
|
|
||||||
|
- The `zwave.mqtt` is now compatible both with older (i.e. `zwavejs2mqtt`) and
|
||||||
|
newer (i.e. `ZwaveJS`) versions of the backend.
|
||||||
|
|
||||||
|
## [0.24.1] - 2022-12-08
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Removed a parenthesized context manager that broke compatibility with
|
||||||
|
Python < 3.10.
|
||||||
|
|
||||||
|
## [0.24.0] - 2022-11-22
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ from .message.response import Response
|
||||||
from .utils import set_thread_name, get_enabled_plugins
|
from .utils import set_thread_name, get_enabled_plugins
|
||||||
|
|
||||||
__author__ = 'Fabio Manganiello <info@fabiomanganiello.com>'
|
__author__ = 'Fabio Manganiello <info@fabiomanganiello.com>'
|
||||||
__version__ = '0.24.0'
|
__version__ = '0.24.2'
|
||||||
|
|
||||||
log = logging.getLogger('platypush')
|
log = logging.getLogger('platypush')
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,9 @@ class ZwaveMqttBackend(MqttBackend):
|
||||||
if not msg.topic.startswith(self.events_topic):
|
if not msg.topic.startswith(self.events_topic):
|
||||||
return
|
return
|
||||||
|
|
||||||
topic = msg.topic[len(self.events_topic) + 1 :].split('/').pop()
|
topic = (
|
||||||
|
msg.topic[(len(self.events_topic) + 1) :].split('/').pop() # noqa: E203
|
||||||
|
)
|
||||||
data = msg.payload.decode()
|
data = msg.payload.decode()
|
||||||
if not data:
|
if not data:
|
||||||
return
|
return
|
||||||
|
|
|
@ -10,6 +10,7 @@ import re
|
||||||
import shutil
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
from urllib.parse import quote
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
@ -72,7 +73,7 @@ class Config:
|
||||||
if cfgfile is None:
|
if cfgfile is None:
|
||||||
cfgfile = self._create_default_config()
|
cfgfile = self._create_default_config()
|
||||||
|
|
||||||
self._cfgfile = os.path.abspath(os.path.expanduser(cfgfile))
|
cfgfile = self._cfgfile = os.path.abspath(os.path.expanduser(cfgfile))
|
||||||
self._config = self._read_config_file(self._cfgfile)
|
self._config = self._read_config_file(self._cfgfile)
|
||||||
|
|
||||||
if 'token' in self._config:
|
if 'token' in self._config:
|
||||||
|
@ -80,6 +81,7 @@ class Config:
|
||||||
|
|
||||||
if 'workdir' not in self._config:
|
if 'workdir' not in self._config:
|
||||||
self._config['workdir'] = self._workdir_location
|
self._config['workdir'] = self._workdir_location
|
||||||
|
self._config['workdir'] = os.path.expanduser(self._config['workdir'])
|
||||||
os.makedirs(self._config['workdir'], exist_ok=True)
|
os.makedirs(self._config['workdir'], exist_ok=True)
|
||||||
|
|
||||||
if 'scripts_dir' not in self._config:
|
if 'scripts_dir' not in self._config:
|
||||||
|
@ -94,6 +96,7 @@ class Config:
|
||||||
)
|
)
|
||||||
os.makedirs(self._config['dashboards_dir'], mode=0o755, exist_ok=True)
|
os.makedirs(self._config['dashboards_dir'], mode=0o755, exist_ok=True)
|
||||||
|
|
||||||
|
# Create a default (empty) __init__.py in the scripts folder
|
||||||
init_py = os.path.join(self._config['scripts_dir'], '__init__.py')
|
init_py = os.path.join(self._config['scripts_dir'], '__init__.py')
|
||||||
if not os.path.isfile(init_py):
|
if not os.path.isfile(init_py):
|
||||||
with open(init_py, 'w') as f:
|
with open(init_py, 'w') as f:
|
||||||
|
@ -106,15 +109,21 @@ class Config:
|
||||||
)
|
)
|
||||||
sys.path = [scripts_parent_dir] + sys.path
|
sys.path = [scripts_parent_dir] + sys.path
|
||||||
|
|
||||||
self._config['db'] = self._config.get(
|
# Initialize the default db connection string
|
||||||
'main.db',
|
db_engine = self._config.get('main.db', '')
|
||||||
{
|
if db_engine:
|
||||||
'engine': 'sqlite:///'
|
if isinstance(db_engine, str):
|
||||||
+ os.path.join(
|
db_engine = {
|
||||||
os.path.expanduser('~'), '.local', 'share', 'platypush', 'main.db'
|
'engine': db_engine,
|
||||||
)
|
}
|
||||||
},
|
else:
|
||||||
|
db_engine = {
|
||||||
|
'engine': 'sqlite:///' + os.path.join(
|
||||||
|
quote(self._config['workdir']), 'main.db'
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
self._config['db'] = db_engine
|
||||||
|
|
||||||
logging_config = {
|
logging_config = {
|
||||||
'level': logging.INFO,
|
'level': logging.INFO,
|
||||||
|
|
|
@ -357,7 +357,7 @@ def grouper(n, iterable, fillvalue=None):
|
||||||
args = [iter(iterable)] * n
|
args = [iter(iterable)] * n
|
||||||
|
|
||||||
if fillvalue:
|
if fillvalue:
|
||||||
return zip_longest(fillvalue=fillvalue, *args)
|
return zip_longest(*args, fillvalue=fillvalue)
|
||||||
|
|
||||||
for chunk in zip_longest(*args):
|
for chunk in zip_longest(*args):
|
||||||
yield filter(None, chunk)
|
yield filter(None, chunk)
|
||||||
|
@ -389,8 +389,9 @@ def run(action, *args, **kwargs):
|
||||||
return response.output
|
return response.output
|
||||||
|
|
||||||
|
|
||||||
def generate_rsa_key_pair(key_file: Optional[str] = None, size: int = 2048) \
|
def generate_rsa_key_pair(
|
||||||
-> Tuple[PublicKey, PrivateKey]:
|
key_file: Optional[str] = None, size: int = 2048
|
||||||
|
) -> Tuple[PublicKey, PrivateKey]:
|
||||||
"""
|
"""
|
||||||
Generate an RSA key pair.
|
Generate an RSA key pair.
|
||||||
|
|
||||||
|
@ -434,10 +435,7 @@ def get_or_generate_jwt_rsa_key_pair():
|
||||||
pub_key_file = priv_key_file + '.pub'
|
pub_key_file = priv_key_file + '.pub'
|
||||||
|
|
||||||
if os.path.isfile(priv_key_file) and os.path.isfile(pub_key_file):
|
if os.path.isfile(priv_key_file) and os.path.isfile(pub_key_file):
|
||||||
with (
|
with open(pub_key_file, 'r') as f1, open(priv_key_file, 'r') as f2:
|
||||||
open(pub_key_file, 'r') as f1,
|
|
||||||
open(priv_key_file, 'r') as f2
|
|
||||||
):
|
|
||||||
return (
|
return (
|
||||||
rsa.PublicKey.load_pkcs1(f1.read().encode()),
|
rsa.PublicKey.load_pkcs1(f1.read().encode()),
|
||||||
rsa.PrivateKey.load_pkcs1(f2.read().encode()),
|
rsa.PrivateKey.load_pkcs1(f2.read().encode()),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.24.0
|
current_version = 0.24.2
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -28,7 +28,7 @@ backend = pkg_files('platypush/backend')
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="platypush",
|
name="platypush",
|
||||||
version="0.24.0",
|
version="0.24.2",
|
||||||
author="Fabio Manganiello",
|
author="Fabio Manganiello",
|
||||||
author_email="info@fabiomanganiello.com",
|
author_email="info@fabiomanganiello.com",
|
||||||
description="Platypush service",
|
description="Platypush service",
|
||||||
|
|
Loading…
Reference in a new issue