Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions python_transport/tests/test_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# FALSE, means that we don't set it
env_vars["WM_SERVICES_MQTT_PERSIST_SESSION"] = True
env_vars["WM_SERVICES_MQTT_FORCE_UNSECURE"] = True
env_vars["WM_SERVICES_MQTT_ALLOW_UNTRUSTED"] = True

env_vars["WM_GW_BUFFERING_MAX_BUFFERED_PACKETS"] = 1000
env_vars["WM_GW_BUFFERING_MAX_DELAY_WITHOUT_PUBLISH"] = 128
Expand Down Expand Up @@ -45,7 +44,6 @@
file_vars["mqtt_ciphers"] = env_vars["WM_SERVICES_MQTT_CIPHERS"]
file_vars["mqtt_persist_session"] = env_vars["WM_SERVICES_MQTT_PERSIST_SESSION"]
file_vars["mqtt_force_unsecure"] = env_vars["WM_SERVICES_MQTT_FORCE_UNSECURE"]
file_vars["mqtt_allow_untrusted"] = env_vars["WM_SERVICES_MQTT_ALLOW_UNTRUSTED"]
file_vars["mqtt_reconnect_delay"] = env_vars["WM_SERVICES_MQTT_RECONNECT_DELAY"]
file_vars["buffering_max_buffered_packets"] = env_vars[
"WM_GW_BUFFERING_MAX_BUFFERED_PACKETS"
Expand All @@ -64,7 +62,6 @@
booleans = [
"WM_SERVICES_MQTT_PERSIST_SESSION",
"WM_SERVICES_MQTT_FORCE_UNSECURE",
"WM_SERVICES_MQTT_ALLOW_UNTRUSTED",
]


Expand Down Expand Up @@ -132,13 +129,6 @@ def content_tests(settings, vcopy):
else:
assert vcopy["WM_SERVICES_MQTT_FORCE_UNSECURE"] == settings.mqtt_force_unsecure

if "WM_SERVICES_MQTT_ALLOW_UNTRUSTED" not in vcopy:
assert settings.mqtt_allow_untrusted is False
else:
assert (
vcopy["WM_SERVICES_MQTT_ALLOW_UNTRUSTED"] == settings.mqtt_allow_untrusted
)

assert vcopy["WM_SERVICES_MQTT_RECONNECT_DELAY"] == settings.mqtt_reconnect_delay
assert (
vcopy["WM_GW_BUFFERING_MAX_BUFFERED_PACKETS"]
Expand Down Expand Up @@ -198,7 +188,6 @@ def test_defaults():
assert settings.mqtt_ciphers is None
assert settings.mqtt_persist_session is False
assert settings.mqtt_force_unsecure is False
assert settings.mqtt_allow_untrusted is False
assert settings.mqtt_reconnect_delay == 0
assert settings.buffering_max_buffered_packets == 0
assert settings.buffering_max_delay_without_publish == 0
Expand Down
11 changes: 7 additions & 4 deletions python_transport/wirepas_gateway/dbus/dbus_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import logging
from threading import Thread
from pydbus import SystemBus
import dbusCExtension
from gi.repository import GLib, GObject
from .sink_manager import SinkManager

Expand All @@ -24,8 +23,12 @@ def __init__(self, cb):
"""
Thread.__init__(self)


dbusCExtension.setCallback(cb)
# Imported here instead of module level because importing the C
# extension requires a running system bus. This allows running "--help"
# without connecting to a dbus daemon.
import dbusCExtension
self._dbus_c_extension = dbusCExtension

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Black would make changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this one; it's not nice to do an import here but this is the easiest way to get help text to print without a dbus connection.

self._dbus_c_extension.setCallback(cb)
self.daemon = True # Daemonize thread

def run(self) -> None:
Expand All @@ -34,7 +37,7 @@ def run(self) -> None:
:return: None, as it is an infinite loop in C
"""
while True:
dbusCExtension.infiniteEventLoop()
self._dbus_c_extension.infiniteEventLoop()
logging.error("C extension loop has exited")


Expand Down
20 changes: 12 additions & 8 deletions python_transport/wirepas_gateway/transport_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from uuid import getnode
from threading import Thread, Event
from copy import deepcopy
import textwrap

from wirepas_gateway.dbus.dbus_client import BusClient
from wirepas_gateway.protocol.topic_helper import TopicGenerator, TopicParser
Expand Down Expand Up @@ -1245,6 +1246,9 @@ def _update_parameters(settings):
logging.error("Wrong format for whitened_endpoints_filter EP list (%s)", e)
exit()

if settings.mqtt_allow_untrusted:
logging.warning("Param mqtt_allow_untrusted is deprecated and is not in use.")

if settings.buffering_stop_stack is not None:
logging.warning("Param buffering_stop_stack is deprecated, please use buffering_action instead")
if settings.buffering_action is not None:
Expand Down Expand Up @@ -1290,8 +1294,14 @@ def main():

"""
parse = ParserHelper(
description="Wirepas Gateway Transport service arguments",
version=transport_version,
description=textwrap.dedent("""\
Wirepas Gateway Transport Service

Each parameter below can also be set with the environment variable
shown next to it (i.e. $WM_GW_ID). A parameter given on the command
line overrides the environment variable.
""")
)

parse.add_file_settings()
Expand All @@ -1304,8 +1314,7 @@ def main():

settings = parse.settings()

# Set default debug level
debug_level = "info"
debug_level = settings.log_level
try:
debug_level = os.environ["DEBUG_LEVEL"]
print(
Expand All @@ -1316,11 +1325,6 @@ def main():
except KeyError:
pass

try:
debug_level = os.environ["WM_DEBUG_LEVEL"]
except KeyError:
pass

debug_level = "{0}".format(debug_level.upper())

# enable its logger
Expand Down
Loading