Commit 18583623 authored by Philipp Hörist's avatar Philipp Hörist

DBus: Fix various pylint errors

parent 9403eaba
Pipeline #4317 failed with stages
in 3 minutes and 21 seconds
......@@ -39,10 +39,12 @@ class LocationListener:
def __init__(self):
self._data = {}
self.location_info = {}
self.simple = None
# Note: do not remove third parameter `paramSpec`
# Note: do not remove third parameter `param`
# because notify signal expects three parameters
def _on_location_update(self, simple, paramSpec=None):
def _on_location_update(self, simple, _param=None):
location = simple.get_location()
timestamp = location.get_property("timestamp")[0]
lat = location.get_property("latitude")
......@@ -56,12 +58,12 @@ class LocationListener:
self._data['timestamp'] = self._timestamp_to_utc(timestamp)
self._send_location()
def _on_simple_ready(self, obj, result):
def _on_simple_ready(self, _obj, result):
try:
self.simple = Geoclue.Simple.new_finish(result)
except GLib.Error as e:
if e.domain == 'g-dbus-error-quark':
log.warning("Could not enable geolocation: %s", e.message)
except GLib.Error as error:
if error.domain == 'g-dbus-error-quark':
log.warning("Could not enable geolocation: %s", error.message)
else:
raise
else:
......@@ -98,7 +100,8 @@ class LocationListener:
LocationData(**self._data))
self.location_info = self._data.copy()
def _timestamp_to_utc(self, timestamp):
@staticmethod
def _timestamp_to_utc(timestamp):
time = datetime.utcfromtimestamp(timestamp)
return time.strftime('%Y-%m-%dT%H:%MZ')
......
......@@ -55,7 +55,8 @@ class LogindListener:
interface_name, signal_name, parameters,
*_user_data):
'''Signal handler for PrepareForSleep event'''
log.debug('Received signal %s.%s%s', interface_name, signal_name, parameters)
log.debug('Received signal %s.%s%s',
interface_name, signal_name, parameters)
before = parameters[0] # Signal is either before or after sleep occurs
if before:
......@@ -69,7 +70,8 @@ class LogindListener:
if app.account_is_connected(name):
conn.old_show = app.SHOW_LIST[conn.connected]
st = conn.status
conn.change_status('offline', _('Machine is going to sleep'))
conn.change_status('offline',
_('Machine is going to sleep'))
conn.status = st
conn.time_to_reconnect = 5
......
......@@ -50,6 +50,7 @@ class MusicTrackListener(GObject.GObject):
def __init__(self):
super().__init__()
self.players = {}
self.connection = None
def start(self):
proxy = Gio.DBusProxy.new_for_bus_sync(
......@@ -93,11 +94,17 @@ class MusicTrackListener(GObject.GObject):
if name.startswith(MPRIS_PLAYER_PREFIX):
self._remove_player(name)
def _signal_name_owner_changed(self, connection, sender_name, object_path,
interface_name, signal_name, parameters, *user_data):
name, oldOwner, newOwner = parameters
def _signal_name_owner_changed(self,
_connection,
_sender_name,
_object_path,
_interface_name,
_signal_name,
parameters,
*_user_data):
name, old_owner, new_owner = parameters
if name.startswith(MPRIS_PLAYER_PREFIX):
if newOwner and not oldOwner:
if new_owner and not old_owner:
self._add_player(name)
else:
self._remove_player(name)
......@@ -132,8 +139,14 @@ class MusicTrackListener(GObject.GObject):
self.emit('music-track-changed', None)
def _signal_received(self, connection, sender_name, object_path,
interface_name, signal_name, parameters, *user_data):
def _signal_received(self,
_connection,
_sender_name,
_object_path,
interface_name,
_signal_name,
parameters,
*user_data):
'''Signal handler for PropertiesChanged event'''
if 'PlaybackStatus' not in parameters[1]:
......@@ -145,7 +158,8 @@ class MusicTrackListener(GObject.GObject):
self.emit('music-track-changed', info)
def _properties_extract(self, properties):
@staticmethod
def _properties_extract(properties):
meta = properties.get('Metadata')
if meta is None or not meta:
return None
......
......@@ -64,7 +64,8 @@ class ScreensaverListener:
# Don't go auto away if user disabled the option
return
for account in app.connections:
if account not in app.sleeper_state or not app.sleeper_state[account]:
if (account not in app.sleeper_state or
not app.sleeper_state[account]):
continue
if app.sleeper_state[account] == 'online':
if not app.account_is_connected(account):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment