# HG changeset patch # User Goffi # Date 1281360991 -28800 # Node ID 8a2053de6f8c4f702e8879b2bf5a5c1425bdb735 # Parent 5d7a011d78ba0cf397759b7ff39cea04c8bda7fb Frontends: management of unlaunched SàT Backend (information message and exit) DBus Bridge Frontend: added an exception to manage unlaunched SàT Backend (BridgeExceptionNoService) Quick App, jp: a message is print when the previous exception is launched diff -r 5d7a011d78ba -r 8a2053de6f8c frontends/jp/jp --- a/frontends/jp/jp Mon Aug 09 19:09:43 2010 +0800 +++ b/frontends/jp/jp Mon Aug 09 21:36:31 2010 +0800 @@ -55,7 +55,7 @@ import pdb from tools.jid import JID import gobject -from sat_bridge_frontend.DBus import DBusBridgeFrontend +from sat_bridge_frontend.DBus import DBusBridgeFrontend,BridgeExceptionNoService import tarfile try: from progressbar import ProgressBar, Percentage, Bar, ETA, FileTransferSpeed @@ -69,7 +69,12 @@ class JP(): def __init__(self): - self.bridge=DBusBridgeFrontend() + try: + self.bridge=DBusBridgeFrontend() + except BridgeExceptionNoService: + print(_(u"Can't connect to SàT backend, are you sure it's launched ?")) + import sys + sys.exit(1) self.transfert_id = None def check_options(self): diff -r 5d7a011d78ba -r 8a2053de6f8c frontends/quick_frontend/quick_app.py --- a/frontends/quick_frontend/quick_app.py Mon Aug 09 19:09:43 2010 +0800 +++ b/frontends/quick_frontend/quick_app.py Mon Aug 09 21:36:31 2010 +0800 @@ -21,7 +21,7 @@ from logging import debug, info, error from tools.jid import JID -from sat_bridge_frontend.DBus import DBusBridgeFrontend +from sat_bridge_frontend.DBus import DBusBridgeFrontend,BridgeExceptionNoService from optparse import OptionParser import pdb @@ -38,7 +38,12 @@ self.check_options() ## bridge ## - self.bridge=DBusBridgeFrontend() + try: + self.bridge=DBusBridgeFrontend() + except BridgeExceptionNoService: + print(_(u"Can't connect to SàT backend, are you sure it's launched ?")) + import sys + sys.exit(1) self.bridge.register("connected", self.connected) self.bridge.register("disconnected", self.disconnected) self.bridge.register("newContact", self.newContact) diff -r 5d7a011d78ba -r 8a2053de6f8c frontends/sat_bridge_frontend/DBus.py --- a/frontends/sat_bridge_frontend/DBus.py Mon Aug 09 19:09:43 2010 +0800 +++ b/frontends/sat_bridge_frontend/DBus.py Mon Aug 09 21:36:31 2010 +0800 @@ -22,16 +22,24 @@ from bridge_frontend import BridgeFrontend import dbus, dbus.glib +class BridgeExceptionNoService(Exception): + pass class DBusBridgeFrontend(BridgeFrontend): def __init__(self): - self.sessions_bus = dbus.SessionBus() - self.db_object = self.sessions_bus.get_object('org.goffi.SAT', - '/org/goffi/SAT/bridge') - self.db_comm_iface = dbus.Interface(self.db_object, - dbus_interface='org.goffi.SAT.communication') - self.db_req_iface = dbus.Interface(self.db_object, - dbus_interface='org.goffi.SAT.request') + try: + self.sessions_bus = dbus.SessionBus() + self.db_object = self.sessions_bus.get_object('org.goffi.SAT', + '/org/goffi/SAT/bridge') + self.db_comm_iface = dbus.Interface(self.db_object, + dbus_interface='org.goffi.SAT.communication') + self.db_req_iface = dbus.Interface(self.db_object, + dbus_interface='org.goffi.SAT.request') + except dbus.exceptions.DBusException,e: + if e._dbus_error_name=='org.freedesktop.DBus.Error.ServiceUnknown': + raise BridgeExceptionNoService + else: + raise e #props = self.db_comm_iface.getProperties() def register(self, functionName, handler, iface="communication"):