- closes rhbz#926011

Signed-off-by: Jakub Filak <jfi...@redhat.com>
---
 src/gnome-abrt             | 22 ++++++++++++++--------
 test/fake_app_dbus_service | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 8 deletions(-)
 create mode 100755 test/fake_app_dbus_service

diff --git a/src/gnome-abrt b/src/gnome-abrt
index 56a2623..a277d36 100755
--- a/src/gnome-abrt
+++ b/src/gnome-abrt
@@ -119,14 +119,20 @@ class GtkAppDBUSImpl(object):
             raise RuntimeError("Can't send command-line message because "
                                "instance is not a remote application")
 
-        if not self._primary_iface:
-            self._primary_iface = dbus.Interface(self._primary_obj,
-                    GNOME_ABRT_INTERFACE)
+        try:
+            if not self._primary_iface:
+                self._primary_iface = dbus.Interface(self._primary_obj,
+                        GNOME_ABRT_INTERFACE)
 
-        if len(argv) == 0:
-            argv = dbus.Array([], signature='s')
+            if len(argv) == 0:
+                argv = dbus.Array([], signature='s')
 
-        self._primary_iface.command_line(argv)
+            self._primary_iface.command_line(argv)
+            return True
+        except dbus.exceptions.DBusException as ex:
+            logging.debug("Can't send command line over DBus: {0}"
+                    .format(ex.message))
+            return False
 
 
 class OopsApplication(Gtk.Application):
@@ -145,8 +151,8 @@ class OopsApplication(Gtk.Application):
         argv = gcmdargs.get_arguments()
 
         if self._dbus_srv.is_remote():
-            self._dbus_srv.send_command_line(argv)
-            return 0
+            if self._dbus_srv.send_command_line(argv):
+                return 0
 
         if len(argv) > 0:
             conf = get_configuration()
diff --git a/test/fake_app_dbus_service b/test/fake_app_dbus_service
new file mode 100755
index 0000000..890dc68
--- /dev/null
+++ b/test/fake_app_dbus_service
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+
+## Copyright (C) 2012 ABRT team <abrt-devel-l...@redhat.com>
+## Copyright (C) 2001-2005 Red Hat, Inc.
+
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335  USA
+
+import dbus
+import dbus.service
+
+GNOME_ABRT_APPLICATION_ID = 'org.freedesktop.GnomeAbrt'
+GNOME_ABRT_INTERFACE = 'org.freedesktop.GnomeAbrt'
+GNOME_ABRT_OBJECT_PATH = '/org/freedesktop/GnomeAbrt'
+
+class FakeService(dbus.service.Object):
+
+    def __init__(self):
+        bus_name = dbus.service.BusName(GNOME_ABRT_APPLICATION_ID, 
dbus.SessionBus())
+        dbus.service.Object.__init__(self, bus_name, GNOME_ABRT_OBJECT_PATH)
+
+    @dbus.service.method(dbus_interface=GNOME_ABRT_INTERFACE,
+                         in_signature='as', out_signature='')
+    def command_line(self, argv):
+        raise dbus.exceptions.DBusException("Fake Service. HA! HA!")
+
+
+if __name__ == "__main__":
+    import gobject
+    from dbus.mainloop.glib import DBusGMainLoop
+
+    DBusGMainLoop(set_as_default=True)
+    service = FakeService()
+    loop = gobject.MainLoop()
+    loop.run()
-- 
1.8.1.4

Reply via email to