Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Format fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zewelor committed Apr 25, 2020
1 parent 4241bfc commit 4ec57ae
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 21 deletions.
1 change: 0 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import yaml
import os
import sys

with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.yaml"), "r") as f:
settings = yaml.safe_load(f)
3 changes: 1 addition & 2 deletions gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from workers_queue import _WORKERS_QUEUE
from mqtt import MqttClient
from workers_manager import WorkersManager
from config import settings


parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -61,8 +62,6 @@
print(' '.join(requirements))
exit(0)

from config import settings

_LOGGER = logger.get()
if parsed.quiet:
_LOGGER.setLevel(logging.WARNING)
Expand Down
1 change: 1 addition & 0 deletions mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def availability_topic(self):
def mqttc(self):
return self._mqttc

# noinspection PyUnusedLocal
def on_connect(self, client, userdata, flags, rc):
if self.availability_topic:
self.publish(
Expand Down
3 changes: 1 addition & 2 deletions workers/lywsd03mmc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import json
import logger

Expand Down Expand Up @@ -105,7 +104,7 @@ def subscribe(self, device):
def handleNotification(self, handle, data):
temperature = int.from_bytes(data[0:2], byteorder='little', signed=True) / 100
humidity = int.from_bytes(data[2:3], byteorder='little')
battery = int.from_bytes(data[3:5], byteorder='little') / 1000
battery = int.from_bytes(data[3:5], byteorder='little') / 1000

self._temperature = round(temperature, 1)
self._humidity = round(humidity)
Expand Down
4 changes: 1 addition & 3 deletions workers/miflora.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ def config_device(self, name, mac):
def status_update(self):
_LOGGER.info("Updating %d %s devices", len(self.devices), repr(self))

ret = None

for name, data in self.devices.items():
_LOGGER.debug("Updating %s device '%s' (%s)", repr(self), name, data["mac"])
from btlewrap import BluetoothBackendException
Expand All @@ -121,7 +119,7 @@ def status_update(self):
type(e).__name__,
suppress=True,
)
except DeviceTimeoutError as e:
except DeviceTimeoutError:
logger.log_exception(
_LOGGER,
"Time out during update of %s device '%s' (%s)",
Expand Down
4 changes: 2 additions & 2 deletions workers/mithermometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def config_device(self, name, mac):

def status_update(self):
_LOGGER.info("Updating %d %s devices", len(self.devices), repr(self))
ret = []

for name, data in self.devices.items():
_LOGGER.debug("Updating %s device '%s' (%s)", repr(self), name, data["mac"])
from btlewrap import BluetoothBackendException
Expand All @@ -84,7 +84,7 @@ def status_update(self):
type(e).__name__,
suppress=True,
)
except DeviceTimeoutError as e:
except DeviceTimeoutError:
logger.log_exception(
_LOGGER,
"Time out during update of %s device '%s' (%s)",
Expand Down
3 changes: 0 additions & 3 deletions workers/thermostat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from builtins import staticmethod
import logging

from mqtt import MqttMessage, MqttConfigMessage

from workers.base import BaseWorker
Expand Down
17 changes: 9 additions & 8 deletions workers_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import logger

from pip import __version__ as pip_version

if LooseVersion(pip_version) >= LooseVersion("10"):
if LooseVersion(pip_version) >= LooseVersion("19.3.1"):
from pip._internal.main import main as pip_main
Expand Down Expand Up @@ -44,12 +45,12 @@ def execute(self):

try:
with timeout(
self._timeout,
exception=WorkerTimeoutError(
"Execution of command {} timed out after {} seconds".format(
self._source, self._timeout
)
),
self._timeout,
exception=WorkerTimeoutError(
"Execution of command {} timed out after {} seconds".format(
self._source, self._timeout
)
),
):
if inspect.isgeneratorfunction(self._callback):
for message in self._callback(*self._args):
Expand Down Expand Up @@ -112,7 +113,7 @@ def register_workers(self, global_topic_prefix):

if "update_interval" in worker_config:
job_id = "{}_interval_job".format(worker_name)
interval_job = self._scheduler.add_job(
self._scheduler.add_job(
partial(self._queue_command, command),
"interval",
seconds=worker_config["update_interval"],
Expand Down Expand Up @@ -205,7 +206,7 @@ def _on_command_wrapper(self, worker_obj, client, userdata, c):
)
global_topic_prefix = userdata["global_topic_prefix"]
topic = (
c.topic[len(global_topic_prefix + "/") :]
c.topic[len(global_topic_prefix + "/"):]
if global_topic_prefix is not None
else c.topic
)
Expand Down

0 comments on commit 4ec57ae

Please sign in to comment.