[gnome-keysign: 6/16] gpgmeh: use try-except-else for Seahorse DBus
- From: Tobias Mueller <tobiasmue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keysign: 6/16] gpgmeh: use try-except-else for Seahorse DBus
- Date: Wed, 7 Aug 2019 09:49:28 +0000 (UTC)
commit cac57d292f23a7d0ad237cc70836680b916c7dc9
Author: RyuzakiKK <aasonykk gmail com>
Date: Tue Mar 12 14:03:21 2019 +0100
gpgmeh: use try-except-else for Seahorse DBus
In this way if a DBus exception gets raised we will not catch it in the
"Seahorse DBus is not available".
keysign/gpgmeh.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/keysign/gpgmeh.py b/keysign/gpgmeh.py
index 5aa2af8..5165c26 100755
--- a/keysign/gpgmeh.py
+++ b/keysign/gpgmeh.py
@@ -489,14 +489,15 @@ def import_signature(encrypted_sig, homedir=None):
try:
proxy = bus.get_object(name, path)
+ except dbus.exceptions.DBusException:
+ log.debug("Seahorse DBus is not available")
+ else:
iface = "org.gnome.seahorse.KeyService"
gpg_iface = dbus.Interface(proxy, iface)
payload = base64.b64encode(signature[0]).decode('latin-1')
payload = '\n'.join(payload[i:(i + 64)] for i in range(0, len(payload), 64))
payload = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\n" + payload + "\n-----END PGP PUBLIC KEY
BLOCK-----"
result = gpg_iface.ImportKeys("openpgp", payload)
- except dbus.exceptions.DBusException:
- log.debug("Seahorse DBus is not available")
# If Seahorse failed we try op_import
if len(result) < 1:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]