115 lines
4.2 KiB
Diff
115 lines
4.2 KiB
Diff
From 8be2054b1cb299b16995040c0c3297b3cf504c67 Mon Sep 17 00:00:00 2001
|
|
From: Jiri Popelka <jpopelka@redhat.com>
|
|
Date: Wed, 17 Apr 2013 14:59:05 +0200
|
|
Subject: [PATCH] client: do not pass the dbus exception name to handler
|
|
|
|
this way we see just the problem in error dialog in firewall-config
|
|
diff --git a/src/firewall-applet b/src/firewall-applet
|
|
index 589af7a..b5e7e89 100755
|
|
--- a/src/firewall-applet
|
|
+++ b/src/firewall-applet
|
|
@@ -378,8 +378,8 @@ class TrayApplet(object):
|
|
if self.fw.connected and self.fw.getDefaultZone() != zone:
|
|
try:
|
|
self.fw.setDefaultZone(zone)
|
|
- except dbus.DBusException as e:
|
|
- print("Error: %s" % e.message)
|
|
+ except dbus.exceptions.DBusException as e:
|
|
+ print("Error: %s" % e.get_dbus_message())
|
|
|
|
def notification_check_toggled(self, button, settings, key):
|
|
settings.set_boolean(key, button.get_active())
|
|
diff --git a/src/firewall-config b/src/firewall-config
|
|
index 28ea025..4166d2d 100755
|
|
--- a/src/firewall-config
|
|
+++ b/src/firewall-config
|
|
@@ -38,6 +38,7 @@ if os.getenv("FIREWALLD_DEVEL_ENV") != None:
|
|
datadir = os.getenv("FIREWALLD_DEVEL_ENV")
|
|
sys.path.insert(0, datadir)
|
|
import dbus
|
|
+from dbus.exceptions import DBusException
|
|
|
|
from firewall.config import *
|
|
from firewall.config.dbus import *
|
|
@@ -1157,7 +1158,7 @@ class FirewallConfig(object):
|
|
try:
|
|
self.fw.config().addZone(name, settings)
|
|
except DBusException as e:
|
|
- self._check_name_exception(str(e), name)
|
|
+ self._check_name_exception(e.get_dbus_message(), name)
|
|
return
|
|
|
|
self.load_zones()
|
|
@@ -1784,7 +1785,7 @@ class FirewallConfig(object):
|
|
try:
|
|
self.fw.config().addService(name, settings)
|
|
except DBusException as e:
|
|
- self._check_name_exception(str(e), name)
|
|
+ self._check_name_exception(e.get_dbus_message(), name)
|
|
return
|
|
|
|
|
|
@@ -2133,7 +2134,7 @@ class FirewallConfig(object):
|
|
try:
|
|
self.fw.config().addIcmpType(name, settings)
|
|
except DBusException as e:
|
|
- self._check_name_exception(str(e), name)
|
|
+ self._check_name_exception(e.get_dbus_message(), name)
|
|
return
|
|
|
|
self.load_icmps()
|
|
diff --git a/src/firewall/client.py b/src/firewall/client.py
|
|
index 4b497d0..9d9dd4a 100644
|
|
--- a/src/firewall/client.py
|
|
+++ b/src/firewall/client.py
|
|
@@ -27,7 +27,6 @@ sys.modules['gobject'] = GObject
|
|
|
|
import dbus.mainloop.glib
|
|
import slip.dbus
|
|
-from dbus.exceptions import DBusException
|
|
|
|
from firewall.config import *
|
|
from firewall.config.dbus import *
|
|
@@ -44,13 +43,18 @@ def handle_exceptions(func, *args, **kwargs):
|
|
while 1:
|
|
try:
|
|
return func(*args, **kwargs)
|
|
- except DBusException as e:
|
|
+ except dbus.exceptions.DBusException as e:
|
|
+ dbus_message = e.get_dbus_message()
|
|
+ dbus_name = e.get_dbus_name()
|
|
if not exception_handler:
|
|
raise
|
|
- if "NotAuthorizedException" in str(e):
|
|
+ if "NotAuthorizedException" in dbus_name:
|
|
exception_handler(_("Authorization failed."))
|
|
else:
|
|
- exception_handler(str(e))
|
|
+ if dbus_message:
|
|
+ exception_handler(dbus_message)
|
|
+ else:
|
|
+ exception_handler(str(e))
|
|
except Exception as e:
|
|
if not exception_handler:
|
|
raise
|
|
@@ -698,14 +702,13 @@ class FirewallClient(object):
|
|
self.dbus_obj, dbus_interface=DBUS_INTERFACE_DIRECT)
|
|
self.fw_properties = dbus.Interface(
|
|
self.dbus_obj, dbus_interface='org.freedesktop.DBus.Properties')
|
|
- except DBusException as e:
|
|
+ except dbus.exceptions.DBusException as e:
|
|
# ignore dbus errors
|
|
print "DBusException", e
|
|
return
|
|
except Exception as e:
|
|
- print "Exception", e
|
|
+ print "Exception", e.get_dbus_message()
|
|
return
|
|
-
|
|
self._config = FirewallClientConfig(self.bus)
|
|
self.connected = True
|
|
self._signal_receiver(member="connection-established",
|
|
--
|
|
1.8.2.1
|
|
|