mirror of https://github.com/tuhiproject/tuhi.git
Fix flake8 errors - f-string without placeholders
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>pull/271/head
parent
9d36e3bad0
commit
27164aba52
|
@ -208,7 +208,7 @@ class Searcher(Worker):
|
|||
logger.error('Another client is already searching')
|
||||
return
|
||||
|
||||
logger.debug(f'Starting searching')
|
||||
logger.debug('Starting searching')
|
||||
self.manager.start_search()
|
||||
|
||||
def stop(self):
|
||||
|
|
10
tuhi/base.py
10
tuhi/base.py
|
@ -21,11 +21,11 @@ from pathlib import Path
|
|||
try:
|
||||
from gi.repository import GObject, GLib
|
||||
except Exception as e:
|
||||
print(f'************ Importing gi.repository failed **********')
|
||||
print(f'* This is an issue with the gi module, not with tuhi *')
|
||||
print(f'******************************************************')
|
||||
print(f'The full exception is below:')
|
||||
print(f'')
|
||||
print('************ Importing gi.repository failed **********')
|
||||
print('* This is an issue with the gi module, not with tuhi *')
|
||||
print('******************************************************')
|
||||
print('The full exception is below:')
|
||||
print('')
|
||||
raise e
|
||||
|
||||
from tuhi.dbusserver import TuhiDBusServer
|
||||
|
|
10
tuhi/ble.py
10
tuhi/ble.py
|
@ -206,11 +206,11 @@ class BlueZDevice(GObject.Object):
|
|||
'''
|
||||
i = self.obj.get_interface(ORG_BLUEZ_DEVICE1)
|
||||
if self.connected:
|
||||
self.logger.info(f'Device is already connected')
|
||||
self.logger.info('Device is already connected')
|
||||
self.emit('connected')
|
||||
return
|
||||
|
||||
self.logger.debug(f'Connecting')
|
||||
self.logger.debug('Connecting')
|
||||
i.Connect(result_handler=self._on_connect_result)
|
||||
|
||||
def _on_connect_result(self, obj, result, user_data):
|
||||
|
@ -219,7 +219,7 @@ class BlueZDevice(GObject.Object):
|
|||
result.code == Gio.IOErrorEnum.DBUS_ERROR and
|
||||
Gio.dbus_error_get_remote_error(result) == 'org.bluez.Error.Failed' and
|
||||
'Operation already in progress' in result.message):
|
||||
self.logger.debug(f'Already connecting')
|
||||
self.logger.debug('Already connecting')
|
||||
elif isinstance(result, Exception):
|
||||
self.logger.error(f'Connection failed: {result}')
|
||||
|
||||
|
@ -230,11 +230,11 @@ class BlueZDevice(GObject.Object):
|
|||
'''
|
||||
i = self.obj.get_interface(ORG_BLUEZ_DEVICE1)
|
||||
if not i.get_cached_property('Connected').get_boolean():
|
||||
self.logger.info(f'Device is already disconnected')
|
||||
self.logger.info('Device is already disconnected')
|
||||
self.emit('disconnected')
|
||||
return
|
||||
|
||||
self.logger.debug(f'Disconnecting')
|
||||
self.logger.debug('Disconnecting')
|
||||
i.Disconnect(result_handler=self._on_disconnect_result)
|
||||
|
||||
def _on_disconnect_result(self, obj, result, user_data):
|
||||
|
|
|
@ -426,7 +426,7 @@ class TuhiDBusDevice(_TuhiDBus):
|
|||
fds_list = message.get_unix_fd_list()
|
||||
|
||||
if fds_list is None or fds_list.get_length() != 1:
|
||||
logger.error(f'uhid fds not provided')
|
||||
logger.error('uhid fds not provided')
|
||||
result = GLib.Variant.new_int32(-errno.EINVAL)
|
||||
invocation.return_value(GLib.Variant.new_tuple(result))
|
||||
return
|
||||
|
|
|
@ -46,7 +46,7 @@ class Config(GObject.Object):
|
|||
if not self.path.exists():
|
||||
return
|
||||
|
||||
logger.debug(f'configuration found')
|
||||
logger.debug('configuration found')
|
||||
self.config.read(self.path)
|
||||
|
||||
def _load_cached_drawings(self):
|
||||
|
|
|
@ -137,7 +137,7 @@ class MainWindow(Gtk.ApplicationWindow):
|
|||
|
||||
dp = DrawingPerspective()
|
||||
self._add_perspective(dp)
|
||||
self.headerbar.set_title(f'Tuhi')
|
||||
self.headerbar.set_title('Tuhi')
|
||||
self.stack_perspectives.set_visible_child_name(dp.name)
|
||||
|
||||
if not self._tuhi.devices:
|
||||
|
|
|
@ -1616,7 +1616,7 @@ class StrokeFile(object):
|
|||
points.append(last_point)
|
||||
else:
|
||||
# should never get here
|
||||
raise StrokeParsingError(f'Failed to parse', data[:16])
|
||||
raise StrokeParsingError('Failed to parse', data[:16])
|
||||
|
||||
logger.debug(f'Offset {consumed}: {packet}')
|
||||
consumed += packet.size
|
||||
|
@ -1677,7 +1677,7 @@ class StrokeFileHeader(StrokePacket):
|
|||
func = file_formats[key]
|
||||
func(data)
|
||||
except KeyError:
|
||||
raise StrokeParsingError(f'Unknown file format:', data[:4])
|
||||
raise StrokeParsingError('Unknown file format:', data[:4])
|
||||
|
||||
def __str__(self):
|
||||
t = time.strftime("%y%m%d%H%M%S", time.gmtime(self.timestamp))
|
||||
|
@ -1726,7 +1726,7 @@ class StrokeHeader(StrokePacket):
|
|||
elif payload[0:3] == [0xff, 0xee, 0xee]:
|
||||
self._parse_slate(data, header, payload)
|
||||
else:
|
||||
raise StrokeParsingError(f'Invalid StrokeHeader, expected ff fa or ff ee.', data[:8])
|
||||
raise StrokeParsingError('Invalid StrokeHeader, expected ff fa or ff ee.', data[:8])
|
||||
|
||||
def _parse_slate(self, data, header, payload):
|
||||
self.pen_id = 0
|
||||
|
@ -1768,7 +1768,7 @@ class StrokeHeader(StrokePacket):
|
|||
|
||||
def __str__(self):
|
||||
if self.timestamp is not None:
|
||||
t = time.strftime(f'%y%m%d%H%M%S', time.gmtime(self.timestamp))
|
||||
t = time.strftime('%y%m%d%H%M%S', time.gmtime(self.timestamp))
|
||||
else:
|
||||
t = time.strftime(f'boot+{self.time_offset/1000}s')
|
||||
return f'StrokeHeader: time: {t} new layer: {self.is_new_layer}, pen type: {self.pen_type}, pen id: {self.pen_id:#x}'
|
||||
|
@ -1822,7 +1822,7 @@ class StrokeDelta(object):
|
|||
# 8 bit delta
|
||||
delta = int.from_bytes(bytes([databytes[0]]), byteorder='little', signed=True)
|
||||
if delta == 0:
|
||||
raise StrokeParsingError(f'StrokeDelta: invalid delta of zero', data)
|
||||
raise StrokeParsingError('StrokeDelta: invalid delta of zero', data)
|
||||
assert delta != 0
|
||||
size = 1
|
||||
elif mask == 3:
|
||||
|
@ -1832,7 +1832,7 @@ class StrokeDelta(object):
|
|||
return value, delta, size
|
||||
|
||||
if (data[0] & 0b11) != 0:
|
||||
raise NotImplementedError(f'LSB two bits set in mask - this is not supposed to happen')
|
||||
raise NotImplementedError('LSB two bits set in mask - this is not supposed to happen')
|
||||
|
||||
xmask = (data[0] & 0b00001100) >> 2
|
||||
ymask = (data[0] & 0b00110000) >> 4
|
||||
|
@ -1877,7 +1877,7 @@ class StrokePoint(StrokeDelta):
|
|||
header = data[0]
|
||||
payload = data[1:]
|
||||
if payload[:2] != [0xff, 0xff]:
|
||||
raise StrokeParsingError(f'Invalid StrokePoint, expected ff ff ff', data[:9])
|
||||
raise StrokeParsingError('Invalid StrokePoint, expected ff ff ff', data[:9])
|
||||
|
||||
# This is a wrapper around StrokeDelta which does the mask parsing.
|
||||
# In theory the StrokePoint would be a separate packet but it
|
||||
|
@ -1905,7 +1905,7 @@ class StrokeEOF(StrokePacket):
|
|||
payload = data[1:]
|
||||
nbytes = bin(header).count('1')
|
||||
if payload[:nbytes] != [0xff] * nbytes:
|
||||
raise StrokeParsingError(f'Invalid EOF, expected 0xff only', data[:9])
|
||||
raise StrokeParsingError('Invalid EOF, expected 0xff only', data[:9])
|
||||
self.size = nbytes + 1
|
||||
|
||||
|
||||
|
@ -1915,7 +1915,7 @@ class StrokeEndOfStroke(StrokePacket):
|
|||
payload = data[1:]
|
||||
nbytes = bin(header).count('1')
|
||||
if payload[:nbytes] != [0xff] * nbytes:
|
||||
raise StrokeParsingError(f'Invalid EndOfStroke, expected 0xff only', data[:9])
|
||||
raise StrokeParsingError('Invalid EndOfStroke, expected 0xff only', data[:9])
|
||||
self.size = nbytes + 1
|
||||
self.data = data[:self.size]
|
||||
|
||||
|
@ -1936,6 +1936,6 @@ class StrokeLostPoint(StrokePacket):
|
|||
header = data[0]
|
||||
payload = data[1:]
|
||||
if payload[:2] != [0xdd, 0xdd]:
|
||||
raise StrokeParsingError(f'Invalid StrokeLostPoint, expected ff dd dd', data[:9])
|
||||
raise StrokeParsingError('Invalid StrokeLostPoint, expected ff dd dd', data[:9])
|
||||
self.nlost = little_u16(payload[2:4])
|
||||
self.size = bin(header).count('1') + 1
|
||||
|
|
|
@ -204,7 +204,7 @@ class DataLogger(object):
|
|||
self.logfile.write(f'name: {self.device.name}\n')
|
||||
self.logfile.write(f'bluetooth: {self.btaddr}\n')
|
||||
self.logfile.write(f'time: {timestamp} # host time: {time.strftime("%Y-%m-%d %H:%M:%S")}\n')
|
||||
self.logfile.write(f'data:\n')
|
||||
self.logfile.write('data:\n')
|
||||
|
||||
def _close_file(self):
|
||||
if self.logfile is None:
|
||||
|
@ -441,7 +441,7 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
|||
data = value[2:]
|
||||
while data:
|
||||
if bytes(data) == b'\xff\xff\xff\xff\xff\xff':
|
||||
logger.debug(f'Pen left proximity')
|
||||
logger.debug('Pen left proximity')
|
||||
|
||||
if self._uhid_device is not None:
|
||||
self._uhid_device.call_input_event([1, 0, 0, 0, 0, 0, 0, 0])
|
||||
|
@ -485,7 +485,7 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
|||
|
||||
tdelta = time.mktime(time.gmtime()) - time.mktime(t)
|
||||
if abs(tdelta) > 300:
|
||||
logger.error(f'device time is out by more than 5 minutes')
|
||||
logger.error('device time is out by more than 5 minutes')
|
||||
|
||||
def get_battery_info(self):
|
||||
msg = self.p.execute(Interactions.GET_BATTERY)
|
||||
|
@ -652,7 +652,7 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
|||
self.emit('drawing', drawing)
|
||||
file_count -= 1
|
||||
if TuhiConfig().peek_at_drawing:
|
||||
logger.info(f'Not deleting drawing from device')
|
||||
logger.info('Not deleting drawing from device')
|
||||
if file_count > 0:
|
||||
logger.info(f'{file_count} more files on device but I can only download the oldest one')
|
||||
break
|
||||
|
@ -886,7 +886,7 @@ class WacomDevice(GObject.Object):
|
|||
protocol = ProtocolVersion.from_string(self._config['Protocol'])
|
||||
self._init_protocol(protocol)
|
||||
except (KeyError, ValueError):
|
||||
logger.error(f'Missing or invalid Protocol entry in config file. Treating this device as unregistered')
|
||||
logger.error('Missing or invalid Protocol entry in config file. Treating this device as unregistered')
|
||||
self._uuid = None
|
||||
|
||||
def _init_protocol(self, protocol):
|
||||
|
@ -980,7 +980,7 @@ class WacomDevice(GObject.Object):
|
|||
logger.error(f'**** Exception: {e} ****')
|
||||
exception = e
|
||||
except AuthorizationError as e:
|
||||
logger.error(f'Authorization failed, device needs to be re-registered')
|
||||
logger.error('Authorization failed, device needs to be re-registered')
|
||||
exception = e
|
||||
finally:
|
||||
self.sync_state = 0
|
||||
|
|
Loading…
Reference in New Issue