def DBUS_Notifier_factory(): try: return DBUS_Notifier() except Exception as e: log.error("failed to instantiate the dbus notification handler: %s", e) log.warn("disable notifications to avoid this error") return None
def DBUS_Notifier_factory(): try: return DBUS_Notifier() except Exception, e: log.error("failed to instantiate the dbus notification handler: %s", e) log.warn("disable notifications to avoid this error") return None
def show_notify(self, dbus_id, tray, nid, app_name, replaces_nid, app_icon, summary, body, expire_timeout): if tray is None: log.error("no tray - cannot show notification!") return if not hasattr(tray, "getHWND"): log.error("tray class %s does not support getHWND!", type(tray)) return hwnd = tray.getHWND() notify(hwnd, summary, body, expire_timeout)
def show_notify(self, dbus_id, tray, nid, app_name, replaces_nid, app_icon, summary, body, expire_timeout): if not self.dbus_check(dbus_id): return self.may_retry = True try: self.last_notification = (dbus_id, tray, nid, app_name, replaces_nid, app_icon, summary, body, expire_timeout) self.dbusnotify.Notify("Xpra", 0, app_icon, summary, body, [], [], expire_timeout, reply_handler = self.cbReply, error_handler = self.cbError) except: log.error("dbus notify failed", exc_info=True)
def show_notify(self, dbus_id, tray, nid, app_name, replaces_nid, app_icon, summary, body, expire_timeout): if not self.dbus_check(dbus_id): return self.may_retry = True try: self.last_notification = (dbus_id, tray, nid, app_name, replaces_nid, app_icon, summary, body, expire_timeout) self.dbusnotify.Notify("Xpra", 0, app_icon, summary, body, [], [], expire_timeout, reply_handler=self.cbReply, error_handler=self.cbError) except: log.error("dbus notify failed", exc_info=True)
def cbError(self, dbus_error, *args): try: if type(dbus_error) == dbus.exceptions.DBusException: message = dbus_error.get_dbus_message() dbus_error_name = dbus_error.get_dbus_name() if dbus_error_name != "org.freedesktop.DBus.Error.ServiceUnknown": log.error("unhandled dbus exception: %s, %s", message, dbus_error_name) return False if not self.may_retry: log.error( "cannot send notification via dbus, please check that you notification service is operating properly" ) return False self.may_retry = False log.info("trying to re-connect to the notification service") #try to connect to the notification again (just once): self.setup_dbusnotify() #and retry: self.show_notify(*self.last_notification) except: pass log.error("notification error: %s", dbus_error) return False
def cbError(self, dbus_error, *args): try: if type(dbus_error)==dbus.exceptions.DBusException: message = dbus_error.get_dbus_message() dbus_error_name = dbus_error.get_dbus_name() if dbus_error_name!="org.freedesktop.DBus.Error.ServiceUnknown": log.error("unhandled dbus exception: %s, %s", message, dbus_error_name) return False if not self.may_retry: log.error("cannot send notification via dbus, please check that you notification service is operating properly") return False self.may_retry = False log.info("trying to re-connect to the notification service") #try to connect to the notification again (just once): self.setup_dbusnotify() #and retry: self.show_notify(*self.last_notification) except: pass log.error("notification error: %s", dbus_error) return False