Exemple #1
0
def display(title, msg):
    logging.debug("NOTIFY DISPLAY")
    if sys.platform == "linux":
        import notify2
        import dbus
        if not notify2.is_initted():
            logging.debug("Initialising notify2")
            notify2.init("cutecoin")
        n = notify2.Notification(title,
                         msg)

# fixme: https://bugs.python.org/issue11587
        # # Not working... Empty icon at the moment.
        # icon = QPixmap(":/icons/cutecoin_logo/").toImage()
        # if icon.isNull():
        #     logging.debug("Error converting logo")
        # else:
        #     icon.convertToFormat(QImage.Format_ARGB32)
        #     icon_bytes = icon.bits().asstring(icon.byteCount())
        #     icon_struct = (
        #         icon.width(),
        #         icon.height(),
        #         icon.bytesPerLine(),
        #         icon.hasAlphaChannel(),
        #         32,
        #         4,
        #         dbus.ByteArray(icon_bytes)
        #         )
        #     n.set_hint('icon_data', icon_struct)
        #     n.set_timeout(5000)
        n.show()
    else:
        _Toast(title, msg)
Exemple #2
0
def display(title, msg):
    logging.debug("NOTIFY DISPLAY")
    if sys.platform == "linux":
        try:
            import notify2
            if not notify2.is_initted():
                logging.debug("Initialising notify2")
                notify2.init("sakia")
            n = notify2.Notification(title, msg)
            n.show()
        except ImportError:
            _Toast(title, msg)


# fixme: https://bugs.python.org/issue11587
# # Not working... Empty icon at the moment.
# icon = QPixmap(":/icons/sakia_logo/").toImage()
# if icon.isNull():
#     logging.debug("Error converting logo")
# else:
#     icon.convertToFormat(QImage.Format_ARGB32)
#     icon_bytes = icon.bits().asstring(icon.byteCount())
#     icon_struct = (
#         icon.width(),
#         icon.height(),
#         icon.bytesPerLine(),
#         icon.hasAlphaChannel(),
#         32,
#         4,
#         dbus.ByteArray(icon_bytes)
#         )
#     n.set_hint('icon_data', icon_struct)
#     n.set_timeout(5000)
    else:
        _Toast(title, msg)
 def notify(title, message):
     """Show a notification message if notify2 is available"""
     try:
         if not notify2.is_initted():
             notify2.init("moya")
         n = notify2.Notification(title, message, "dialog-information")
         n.show()
     except:
         # Notifications are low priority, don't want to risk breaking the server
         pass
    def show(self, timeout=5000):
        if timeout:
            self.notification.set_timeout(timeout)

        if Notify.is_initted():
            self.notification.show()
            if self.action_count > 0:
                gobject.timeout_add(timeout, lambda: os.sys.exit())
                gobject.MainLoop().run()
        else:
            os.sys.exit(2)
Exemple #5
0
def notify_desktop(message):
    """
    Thin Shim to notify when the simulations are complete, and not cry under no xsession
    :param message:
    :return:
    """
    try:
        import notify2
        if not notify2.is_initted():
            notify2.init("AIETES Simulation")
        notify2.Notification.new("AIETES Simulation", message, "dialog-information").show()
    except ImportError:
        pass
Exemple #6
0
def notify(title, message):
    """Show a notification message if notify2 is available"""
    try:
        import notify2
    except ImportError:
        return
    try:
        if not notify2.is_initted():
            notify2.init("moya")
        n = notify2.Notification(title, message, "dialog-information")
        n.show()
    except:
        # Notifications are low priority, don't want to risk breaking the server
        pass
Exemple #7
0
 def show_notify(self, dbus_id, tray, nid,
                 app_name, replaces_nid, app_icon,
                 summary, body, actions, hints, timeout, icon):
     if not self.dbus_check(dbus_id):
         return
     icon_string = self.get_icon_string(nid, app_icon, icon)
     if not notify2.is_initted():
         notify2.init(app_name or "Xpra", "glib")
     n = notify2.Notification(summary, body, icon_string)
     n.set_urgency(notify2.URGENCY_LOW)
     n.set_timeout(timeout)
     if actions and False:
         while len(actions)>=2:
             action_id, action_label = actions[:2]
             self.add_action(n, action_id, action_label)
             actions = actions[2:]
     n.show()
     if icon_string:
         def notification_closed(*_args):
             self.clean_notification(nid)
         n.connect("closed", notification_closed)
 def test_init_uninit(self):
     assert notify2.is_initted()
     self.assertEqual(notify2.get_app_name(), "notify2 test suite")
     
     notify2.uninit()
     assert not notify2.is_initted()
Exemple #9
0
    def test_init_uninit(self):
        assert notify2.is_initted()
        self.assertEqual(notify2.get_app_name(), "notify2 test suite")

        notify2.uninit()
        assert not notify2.is_initted()