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: ...@@ -39,10 +39,12 @@ class LocationListener:
def __init__(self): def __init__(self):
self._data = {} 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 # 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() location = simple.get_location()
timestamp = location.get_property("timestamp")[0] timestamp = location.get_property("timestamp")[0]
lat = location.get_property("latitude") lat = location.get_property("latitude")
...@@ -56,12 +58,12 @@ class LocationListener: ...@@ -56,12 +58,12 @@ class LocationListener:
self._data['timestamp'] = self._timestamp_to_utc(timestamp) self._data['timestamp'] = self._timestamp_to_utc(timestamp)
self._send_location() self._send_location()
def _on_simple_ready(self, obj, result): def _on_simple_ready(self, _obj, result):
try: try:
self.simple = Geoclue.Simple.new_finish(result) self.simple = Geoclue.Simple.new_finish(result)
except GLib.Error as e: except GLib.Error as error:
if e.domain == 'g-dbus-error-quark': if error.domain == 'g-dbus-error-quark':
log.warning("Could not enable geolocation: %s", e.message) log.warning("Could not enable geolocation: %s", error.message)
else: else:
raise raise
else: else:
...@@ -98,7 +100,8 @@ class LocationListener: ...@@ -98,7 +100,8 @@ class LocationListener:
LocationData(**self._data)) LocationData(**self._data))
self.location_info = self._data.copy() self.location_info = self._data.copy()
def _timestamp_to_utc(self, timestamp): @staticmethod
def _timestamp_to_utc(timestamp):
time = datetime.utcfromtimestamp(timestamp) time = datetime.utcfromtimestamp(timestamp)
return time.strftime('%Y-%m-%dT%H:%MZ') return time.strftime('%Y-%m-%dT%H:%MZ')
......
...@@ -55,7 +55,8 @@ class LogindListener: ...@@ -55,7 +55,8 @@ class LogindListener:
interface_name, signal_name, parameters, interface_name, signal_name, parameters,
*_user_data): *_user_data):
'''Signal handler for PrepareForSleep event''' '''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 before = parameters[0] # Signal is either before or after sleep occurs
if before: if before:
...@@ -69,7 +70,8 @@ class LogindListener: ...@@ -69,7 +70,8 @@ class LogindListener:
if app.account_is_connected(name): if app.account_is_connected(name):
conn.old_show = app.SHOW_LIST[conn.connected] conn.old_show = app.SHOW_LIST[conn.connected]
st = conn.status 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.status = st
conn.time_to_reconnect = 5 conn.time_to_reconnect = 5
......
...@@ -50,6 +50,7 @@ class MusicTrackListener(GObject.GObject): ...@@ -50,6 +50,7 @@ class MusicTrackListener(GObject.GObject):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.players = {} self.players = {}
self.connection = None
def start(self): def start(self):
proxy = Gio.DBusProxy.new_for_bus_sync( proxy = Gio.DBusProxy.new_for_bus_sync(
...@@ -93,11 +94,17 @@ class MusicTrackListener(GObject.GObject): ...@@ -93,11 +94,17 @@ class MusicTrackListener(GObject.GObject):
if name.startswith(MPRIS_PLAYER_PREFIX): if name.startswith(MPRIS_PLAYER_PREFIX):
self._remove_player(name) self._remove_player(name)
def _signal_name_owner_changed(self, connection, sender_name, object_path, def _signal_name_owner_changed(self,
interface_name, signal_name, parameters, *user_data): _connection,
name, oldOwner, newOwner = parameters _sender_name,
_object_path,
_interface_name,
_signal_name,
parameters,
*_user_data):
name, old_owner, new_owner = parameters
if name.startswith(MPRIS_PLAYER_PREFIX): if name.startswith(MPRIS_PLAYER_PREFIX):
if newOwner and not oldOwner: if new_owner and not old_owner:
self._add_player(name) self._add_player(name)
else: else:
self._remove_player(name) self._remove_player(name)
...@@ -132,8 +139,14 @@ class MusicTrackListener(GObject.GObject): ...@@ -132,8 +139,14 @@ class MusicTrackListener(GObject.GObject):
self.emit('music-track-changed', None) self.emit('music-track-changed', None)
def _signal_received(self, connection, sender_name, object_path, def _signal_received(self,
interface_name, signal_name, parameters, *user_data): _connection,
_sender_name,
_object_path,
interface_name,
_signal_name,
parameters,
*user_data):
'''Signal handler for PropertiesChanged event''' '''Signal handler for PropertiesChanged event'''
if 'PlaybackStatus' not in parameters[1]: if 'PlaybackStatus' not in parameters[1]:
...@@ -145,7 +158,8 @@ class MusicTrackListener(GObject.GObject): ...@@ -145,7 +158,8 @@ class MusicTrackListener(GObject.GObject):
self.emit('music-track-changed', info) self.emit('music-track-changed', info)
def _properties_extract(self, properties): @staticmethod
def _properties_extract(properties):
meta = properties.get('Metadata') meta = properties.get('Metadata')
if meta is None or not meta: if meta is None or not meta:
return None return None
......
...@@ -64,7 +64,8 @@ class ScreensaverListener: ...@@ -64,7 +64,8 @@ class ScreensaverListener:
# Don't go auto away if user disabled the option # Don't go auto away if user disabled the option
return return
for account in app.connections: 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 continue
if app.sleeper_state[account] == 'online': if app.sleeper_state[account] == 'online':
if not app.account_is_connected(account): 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