ble: fix flake8 warnings

./tuhi/ble.py:14:1: F401 'sys' imported but unused
./tuhi/ble.py:15:1: F401 'enum.Enum' imported but unused
./tuhi/ble.py:16:1: F401 'gi.repository.GLib' imported but unused
./tuhi/ble.py:26:1: E302 expected 2 blank lines, found 1
./tuhi/ble.py:81:1: W293 blank line contains whitespace
./tuhi/ble.py:84:13: E126 continuation line over-indented for hanging indent
./tuhi/ble.py:85:17: E131 continuation line unaligned for hanging indent
./tuhi/ble.py:203:39: F821 undefined name 'WACOM_CHRC_LIVE_PEN_DATA_UUID'
./tuhi/ble.py:204:38: E128 continuation line under-indented for visual indent
./tuhi/ble.py:205:39: F821 undefined name 'WACOM_OFFLINE_CHRC_PEN_DATA_UUID'
./tuhi/ble.py:206:38: E128 continuation line under-indented for visual indent
./tuhi/ble.py:207:39: F821 undefined name 'NORDIC_UART_CHRC_RX_UUID'
./tuhi/ble.py:208:38: E128 continuation line under-indented for visual indent
./tuhi/ble.py:232:1: E302 expected 2 blank lines, found 1
./tuhi/ble.py:240:13: E126 continuation line over-indented for hanging indent
./tuhi/ble.py:241:17: E131 continuation line unaligned for hanging indent
./tuhi/ble.py:250:21: E126 continuation line over-indented for hanging indent
./tuhi/ble.py:263:43: W291 trailing whitespace
./tuhi/ble.py:272:72: W291 trailing whitespace
./tuhi/ble.py:310:1: W391 blank line at end of file

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
Benjamin Tissoires 2018-01-12 20:21:05 +01:00
parent af42bc1b27
commit 0d88d9d0e7
1 changed files with 23 additions and 23 deletions

View File

@ -11,9 +11,8 @@
# GNU General Public License for more details.
import logging
import sys
from enum import Enum
from gi.repository import GObject, GLib, Gio
from gi.repository import GObject, Gio
from .wacom import WACOM_CHRC_LIVE_PEN_DATA_UUID, WACOM_OFFLINE_CHRC_PEN_DATA_UUID, NORDIC_UART_CHRC_RX_UUID
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('ble')
@ -23,6 +22,7 @@ ORG_BLUEZ_GATTSERVICE1 = 'org.bluez.GattService1'
ORG_BLUEZ_DEVICE1 = 'org.bluez.Device1'
ORG_BLUEZ_ADAPTER1 = 'org.bluez.Adapter1'
class BlueZCharacteristic(GObject.Object):
"""
Abstraction for a org.bluez.GattCharacteristic1 object
@ -78,13 +78,13 @@ class BlueZDevice(GObject.Object):
:param om: The ObjectManager for name org.bluez path /
:param obj: The org.bluez.Device1 DBus proxy object
"""
__gsignals__ = {
"connected":
(GObject.SIGNAL_RUN_FIRST, None, ()),
"disconnected":
(GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
"connected":
(GObject.SIGNAL_RUN_FIRST, None, ()),
"disconnected":
(GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
}
def __init__(self, om, obj):
@ -201,11 +201,11 @@ class BlueZDevice(GObject.Object):
# out somehow
def _start_notifications(self):
self._start_gatt_notification(WACOM_CHRC_LIVE_PEN_DATA_UUID,
self._pen_data_changed_cb)
self._pen_data_changed_cb)
self._start_gatt_notification(WACOM_OFFLINE_CHRC_PEN_DATA_UUID,
self._pen_data_received_cb)
self._pen_data_received_cb)
self._start_gatt_notification(NORDIC_UART_CHRC_RX_UUID,
self._receive_nordic_data_cb)
self._receive_nordic_data_cb)
def _start_gatt_notification(self, uuid, callback):
try:
@ -229,6 +229,7 @@ class BlueZDevice(GObject.Object):
def __repr__(self):
return 'Device {}:{}'.format(self.name, self.objpath)
class BlueZDeviceManager(GObject.Object):
"""
Manager object that connects to org.bluez's root object and handles the
@ -237,8 +238,8 @@ class BlueZDeviceManager(GObject.Object):
device should be ignored.
"""
__gsignals__ = {
"device-added":
(GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
"device-added":
(GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
}
def __init__(self, **kwargs):
@ -247,20 +248,20 @@ class BlueZDeviceManager(GObject.Object):
def connect_to_bluez(self):
self._om = Gio.DBusObjectManagerClient.new_for_bus_sync(
Gio.BusType.SYSTEM,
Gio.DBusObjectManagerClientFlags.NONE,
'org.bluez',
'/',
None,
None,
None)
Gio.BusType.SYSTEM,
Gio.DBusObjectManagerClientFlags.NONE,
'org.bluez',
'/',
None,
None,
None)
self._om.connect('object-added', self._on_om_object_added)
self._om.connect('object-removed', self._on_om_object_removed)
# We rely on nested object paths, so let's sort the objects by
# object path length and process them in order, this way we're
# guaranteed that the objects we need already exist.
for obj in self._om.get_objects():
for obj in self._om.get_objects():
self._process_object(obj)
def _on_om_object_added(self, om, obj):
@ -269,7 +270,7 @@ class BlueZDeviceManager(GObject.Object):
logger.debug('Object added: {}'.format(objpath))
needs_resolve = self._process_object(obj)
# we had at least one characteristic added, need to resolve the
# we had at least one characteristic added, need to resolve the
# devices.
# FIXME: this isn't the most efficient way...
if needs_resolve:
@ -307,4 +308,3 @@ class BlueZDeviceManager(GObject.Object):
def _process_characteristic(self, obj):
objpath = obj.get_object_path()
logger.debug('Characteristic {}'.format(objpath))