Merge pull request #21 from jnphilipp/dbus

Fix dbus.glib deprecation warning.
This commit is contained in:
Jonathan Lestrelin 2019-11-15 14:15:02 +00:00 committed by GitHub
commit 2ffc11ce05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,17 +26,16 @@
# Author: Luke Macken <lmacken@redhat.com> # Author: Luke Macken <lmacken@redhat.com>
import dbus import dbus
import dbus.glib
import dbus.service import dbus.service
import re import re
import subprocess import subprocess
from dbus.mainloop.glib import DBusGMainLoop
from fuzzywuzzy import process, fuzz
from gi.repository import GLib
from os import getenv, walk from os import getenv, walk
from os.path import expanduser, join as path_join from os.path import expanduser, join as path_join
from gi.repository import GLib
from fuzzywuzzy import process, fuzz
# Convenience shorthand for declaring dbus interface methods. # Convenience shorthand for declaring dbus interface methods.
# s.b.n. -> search_bus_name # s.b.n. -> search_bus_name
search_bus_name = 'org.gnome.Shell.SearchProvider2' search_bus_name = 'org.gnome.Shell.SearchProvider2'
@ -122,7 +121,7 @@ class SearchPassService(dbus.service.Object):
universal_newlines=True) universal_newlines=True)
if field is not None: if field is not None:
match = re.search(fr'^{field}:\s*(?P<value>.+?)$', output, match = re.search(fr'^{field}:\s*(?P<value>.+?)$', output,
flags=re.I|re.M) flags=re.I | re.M)
if match: if match:
password = match.group('value') password = match.group('value')
else: else:
@ -198,14 +197,10 @@ class SearchPassService(dbus.service.Object):
dbus_interface='org.freedesktop.Notifications' dbus_interface='org.freedesktop.Notifications'
) )
except dbus.DBusException as err: except dbus.DBusException as err:
print('Got error {} while trying to display message {}.'.format( print(f'Error {err} while trying to display {message}.')
err, message))
def main():
SearchPassService()
GLib.MainLoop().run()
if __name__ == '__main__': if __name__ == '__main__':
main() DBusGMainLoop(set_as_default=True)
SearchPassService()
GLib.MainLoop().run()