def notify(msg, status): """Send notification status messages through libnotify. Paramaters: (str) msg -- The message to display into notification (str) status -- Type of notification status (ok|info|error|warm|ask|sync) """ if NOT_NOTIFY: return if not pynotify.is_initted(): pynotify.init('lftp_mirror') note = pynotify.Notification("LFTP Mirror", msg) helper = gtk.Button() icons = { 'ok': gtk.STOCK_YES, 'info': gtk.STOCK_DIALOG_INFO, 'error': gtk.STOCK_DIALOG_ERROR, 'warm': gtk.STOCK_DIALOG_WARNING, 'ask': gtk.STOCK_DIALOG_QUESTION, 'sync': gtk.STOCK_JUMP_TO } icon = helper.render_icon(icons[status], gtk.ICON_SIZE_BUTTON) note.set_icon_from_pixbuf(icon) try: note.show() except Exception, e: NOTIFY_ERRORS.append(e)
def notify(title, msg, icon=None, wrap=None): """Send notification icon messages through libnotify. Parameters: (str) title -- The notification title (str) msg -- The message to display into notification (str / uri) icon -- Type of icon (ok|info|error|warm|ask|sync) or icon file """ if NOT_NOTIFY: return if not pynotify.is_initted(): pynotify.init(title) gtk_icon = {'ok': gtk.STOCK_YES, 'info': gtk.STOCK_DIALOG_INFO, 'error': gtk.STOCK_DIALOG_ERROR, 'warm': gtk.STOCK_DIALOG_WARNING, 'ask': gtk.STOCK_DIALOG_QUESTION, 'sync': gtk.STOCK_JUMP_TO} if wrap: msg = os.linesep.join(textwrap.wrap(msg, wrap)) try: note = pynotify.Notification(title, msg) helper = gtk.Button() gtk_icon = helper.render_icon(gtk_icon[icon], gtk.ICON_SIZE_BUTTON) note.set_icon_from_pixbuf(gtk_icon) except KeyError: note = pynotify.Notification(title, msg, icon) note.show()
def show_notification(text): if config["use_pynotify"]: import pynotify if not pynotify.is_initted(): pynotify.init("avahi-tray") n = pynotify.Notification(text) n.show()
def send(self): if not pynotify.is_initted(): print (" msg: " + self.message) return n = pynotify.Notification(self.message) n.set_urgency(self.urgency) n.set_timeout(6000) n.show()
def __init__(self, app_name, icon, attach): self._icon = icon self._attach = attach self._notify = None self._handler_id = None self._timeout_id = None if not pynotify.is_initted(): pynotify.init(app_name)
def notificationWindow_gtknotify(mw, name, text, buddy, color=""): import pynotify import cgi if not pynotify.is_initted(): if not pynotify.init('torchat'): raise Exception('gtknotify not supported') pynotify.Notification( cgi.escape(name).encode('ascii', 'xmlcharrefreplace'), cgi.escape(text).encode('ascii', 'xmlcharrefreplace')).show()
def notificationWindow_gtknotify(mw, name, text, buddy): import pynotify import cgi if not pynotify.is_initted(): if not pynotify.init('torchat'): raise Exception('gtknotify not supported') pynotify.Notification( cgi.escape(name).encode('ascii', 'xmlcharrefreplace'), cgi.escape(text).encode('ascii', 'xmlcharrefreplace') ).show()
def __init__(self): print("{}::{}".format('notify_linux', '__init__')) if not pynotify.is_initted(): print("{}::{}::{}".format('notify_linux', '__init__', 'Initiating pynotify')) if not pynotify.init('PythonTaskbar'): print("{}::{}::{}".format('notify_linux', '__init__', 'Initiating pynotify Failed')) exit(1) self.open_notify_obj = []
def notify(self, msg): """ Creates notification to display to the user """ import pynotify if not pynotify.is_initted(): if not pynotify.init("campfire-notifications"): sys.exit(1) # Error self.push_notification("%s in %s" % (msg['person'], self._room.name), msg['message'])
def popup_init(name): # Notification daemon support global notify_init global notify_daemon_support if notify_daemon_support: if not pynotify.is_initted(): if not pynotify.init(name): notify_daemon_support = False notify_init = False else: notify_init = True
def rssTimer_cb(self, isInitial=False): Log.info("Hitting up RSS Feeds.") entries = list() for rssfeed in self.rssfeeds: entries.extend(filter(lambda entry: entry.caplink not in self.seen, parse.feedParser(rssfeed))) for newEntry in entries: self.seen.add(newEntry.caplink) if newEntry.checkFips(FIPSCODE) or newEntry.checkCoords(LATLONG_COORDS) or True: Log.info("New alert from feed {0}: {1}".format(newEntry.fromFeed, newEntry.summary)) alert = parse.ReadCAP(newEntry.caplink) if alert is None: continue if alert.checkUGC(STATECODE, FIPSCODE, UGCCODE) or alert.checkCoords(LATLONG_COORDS) or alert.checkArea('FIPS6', '000000') or True: if not alert.isExpired(): heapq.heappush(self.caps,alert) for window in self.windows: window.acceptCap(alert) if not isInitial: if len(alert.infos) is 0: Log.debug("Alert %s had no info." % alert.id) continue if alert.infos[0].description is None: alert.infos[0].description = "NO DESCRIPTION" if not pynotify.is_initted(): pynotify.init("GNOME Common Alerting Protocol Viewer") n = pynotify.Notification(alert.getTitle(), "<a href='{0}'>Link</a>\n{1}".format(alert.url, alert.infos[0].description[0:120])) n.set_urgency(pynotify.URGENCY_NORMAL) n.set_category("device") if alert.infos[0].severity is cap.Info.SEVERITY_MODERATE: i = gtk.STOCK_DIALOG_WARNING elif alert.infos[0].severity is cap.Info.SEVERITY_MINOR: i = gtk.STOCK_DIALOG_INFO elif alert.infos[0].severity is cap.Info.SEVERITY_SEVERE or alert.infos[0].severity is cap.Info.SEVERITY_EXTREME: i = gtk.STOCK_DIALOG_ERROR else: i = gtk.STOCK_DIALOG_QUESTION helper = gtk.Button() icon = helper.render_icon(i, gtk.ICON_SIZE_DIALOG) n.set_icon_from_pixbuf(icon) n.show() else: Log.info("... but it is already expired.") Log.info("Done checking RSS feeds.") self.ejectExpired() # self.caps['Testing 1'] = parse.ReadCAP('../alert.cap') # self.caps['Testing 2'] = parse.ReadCAP('../alert2.cap') # self.caps['Testing 3'] = parse.ReadCAP('../alert3.cap') # self.caps['Testing 4'] = parse.ReadCAP('../alert4.cap') return True
def do_notify(self, base, descr, icon, urgency=None): """Displays a notify. This will do nothing if pynotify is not present and/or root is running the listener.""" if pynotify and os.getuid() != 0: if not pynotify.is_initted(): pynotify.init(APP) n = pynotify.Notification(base, descr, icon) if urgency is not None and urgency != "": n.set_urgency(int(urgency)) n.show()
def do_notify(self, base, descr, icon, urgency = None): """Displays a notify. This will do nothing if pynotify is not present and/or root is running the listener.""" if pynotify and os.getuid() != 0: if not pynotify.is_initted(): pynotify.init(APP) n = pynotify.Notification(base, descr, icon) if urgency is not None and urgency != "": n.set_urgency(int(urgency)) n.show()
def notify(title, msg, icon=None): if not pynotify.is_initted(): pynotify.init(title) try: note = pynotify.Notification(repr(title), msg, icon) except (ValueError, TypeError) as e: print(e) try: note.show() except (ValueError, TypeError) as e: print(e)
def __init__(self, config, lang): self.notifier = notifier self.lang = lang # create image pixmap = gtk.Image() pixmap.set_from_file(self.POPUP_IMAGE) self.icon_pixbuf = pixmap.get_pixbuf() if not pynotify.is_initted(): pynotify.init('gmail-notify') self.notify = pynotify.Notification('No new mail', '') self.notify.set_icon_from_pixbuf(self.icon_pixbuf)
def notify(title, msg, icon=None): if not pynotify.is_initted(): pynotify.init(title) gtk_icon = {'ok':gtk.STOCK_YES, 'info':gtk.STOCK_DIALOG_INFO, 'error':gtk.STOCK_DIALOG_ERROR, 'warm':gtk.STOCK_DIALOG_WARNING, 'ask':gtk.STOCK_DIALOG_QUESTION, 'sync':gtk.STOCK_JUMP_TO} try: note = pynotify.Notification(title, msg) helper = gtk.Button() gtk_icon = helper.render_icon(gtk_icon[icon], gtk.ICON_SIZE_BUTTON) note.set_icon_from_pixbuf(gtk_icon) except KeyError: note = pynotify.Notification(title, msg, icon) note.show()
def notify(self, title, message, urgent=False, image=None): if not pynotify.is_initted(): pynotify.init('sniffer') if image: image = 'file://%s' % image notification = pynotify.Notification(title, message, image) else: notification = pynotify.Notification(title, message) helper = gtk.Label() if urgent: #notification.set_urgency(pynotify.URGENCY_CRITICAL) icon = helper.render_icon(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_DIALOG) else: #notification.set_urgency(pynotify.URGENCY_LOW) icon = helper.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG) notification.set_icon_from_pixbuf(icon) if not notification.show(): print "Failed showing python libnotify notification"
def show_notice(message, retry=True, notice=notice): try: if not pynotify.is_initted(): pynotify.init(sys.argv[0]) if not notice: notice = pynotify.Notification(title, message) else: notice.update(title, message) notice.show() except GError: # libnotify's documentation is… awful. This song and dance is required # because at some point in the process lifecycle pynotify loses its # connection and raises. Disconnecting and reestablishing the # connection gets things back on track. notice = None pynotify.uninit() if retry: show_notice(message, False)
def notify(title, msg, icon=None): """Send notification icon messages through libnotify. Parameters: (str) title -- The notification title (str) msg -- The message to display into notification (str / uri) icon -- Type of icon (ok|info|error|warm|ask|sync) or icon file """ if not pynotify.is_initted(): pynotify.init(title) gtk_icon = {'ok':gtk.STOCK_YES, 'info':gtk.STOCK_DIALOG_INFO, 'error':gtk.STOCK_DIALOG_ERROR, 'warm':gtk.STOCK_DIALOG_WARNING, 'ask':gtk.STOCK_DIALOG_QUESTION, 'sync':gtk.STOCK_JUMP_TO} try: note = pynotify.Notification(title, msg) helper = gtk.Button() gtk_icon = helper.render_icon(gtk_icon[icon], gtk.ICON_SIZE_BUTTON) note.set_icon_from_pixbuf(gtk_icon) except KeyError: note = pynotify.Notification(title, msg, icon) note.show()
def notify(msg, status): """Send notification status messages through libnotify. Paramaters: (str) msg -- The message to display into notification (str) status -- Type of notification status (ok|info|error|warm|ask|sync) """ if NOT_NOTIFY: return if not pynotify.is_initted(): pynotify.init('lftp_mirror') note = pynotify.Notification("LFTP Mirror", msg) helper = gtk.Button() icons = {'ok': gtk.STOCK_YES, 'info': gtk.STOCK_DIALOG_INFO, 'error': gtk.STOCK_DIALOG_ERROR, 'warm': gtk.STOCK_DIALOG_WARNING, 'ask': gtk.STOCK_DIALOG_QUESTION, 'sync': gtk.STOCK_JUMP_TO} icon = helper.render_icon(icons[status], gtk.ICON_SIZE_BUTTON) note.set_icon_from_pixbuf(icon) try: note.show() except Exception, e: NOTIFY_ERRORS.append(e)
def show_notification(text): if use_pynotify: if not pynotify.is_initted(): pynotify.init("avahi-tray") n = pynotify.Notification(text) n.show()
def __init__(self, appname, frameobj): if not pynotify.is_initted(): pynotify.init(appname) NotifierBase.__init__(self, appname, frameobj)
def __sn__const(self, applicationname, title, message): if not pynotify.is_initted(): pynotify.init(applicationname) self.__title = title self.__message = message self.__n = pynotify.Notification(self.__title, self.__message)
def check_if_initted(): """Initializes pynotify in case it wasn't initted""" if not pynotify.is_initted(): pynotify.init(consts.APP_SHORT_NAME)
def rssTimer_cb(self, isInitial=False): Log.info("Hitting up RSS Feeds.") entries = list() for rssfeed in self.rssfeeds: entries.extend( filter(lambda entry: entry.caplink not in self.seen, parse.feedParser(rssfeed))) for newEntry in entries: self.seen.add(newEntry.caplink) if newEntry.checkFips(FIPSCODE) or newEntry.checkCoords( LATLONG_COORDS) or True: Log.info("New alert from feed {0}: {1}".format( newEntry.fromFeed, newEntry.summary)) alert = parse.ReadCAP(newEntry.caplink) if alert is None: continue if alert.checkUGC(STATECODE, FIPSCODE, UGCCODE) or alert.checkCoords( LATLONG_COORDS) or alert.checkArea( 'FIPS6', '000000') or True: if not alert.isExpired(): heapq.heappush(self.caps, alert) for window in self.windows: window.acceptCap(alert) if not isInitial: if len(alert.infos) is 0: Log.debug("Alert %s had no info." % alert.id) continue if alert.infos[0].description is None: alert.infos[0].description = "NO DESCRIPTION" if not pynotify.is_initted(): pynotify.init( "GNOME Common Alerting Protocol Viewer") n = pynotify.Notification( alert.getTitle(), "<a href='{0}'>Link</a>\n{1}".format( alert.url, alert.infos[0].description[0:120])) n.set_urgency(pynotify.URGENCY_NORMAL) n.set_category("device") if alert.infos[ 0].severity is cap.Info.SEVERITY_MODERATE: i = gtk.STOCK_DIALOG_WARNING elif alert.infos[ 0].severity is cap.Info.SEVERITY_MINOR: i = gtk.STOCK_DIALOG_INFO elif alert.infos[ 0].severity is cap.Info.SEVERITY_SEVERE or alert.infos[ 0].severity is cap.Info.SEVERITY_EXTREME: i = gtk.STOCK_DIALOG_ERROR else: i = gtk.STOCK_DIALOG_QUESTION helper = gtk.Button() icon = helper.render_icon(i, gtk.ICON_SIZE_DIALOG) n.set_icon_from_pixbuf(icon) n.show() else: Log.info("... but it is already expired.") Log.info("Done checking RSS feeds.") self.ejectExpired() # self.caps['Testing 1'] = parse.ReadCAP('../alert.cap') # self.caps['Testing 2'] = parse.ReadCAP('../alert2.cap') # self.caps['Testing 3'] = parse.ReadCAP('../alert3.cap') # self.caps['Testing 4'] = parse.ReadCAP('../alert4.cap') return True
def __init__(self): self.logger = logging.getLogger('client.main') self.conf_client = get_default_client() self.dbus_manager = DbusManager(self) self.script_manager = ScriptManager() self.proxy_setter = ProxySetter() if pynotify and not pynotify.is_initted(): pynotify.init('telecentros') # Get operating system version o = get_os() if o[0]: self.os_name = o[0] if o[1]: self.os_version = o[1] self.mac_id = get_route_mac_address() self.server = self.conf_client.get_string('server') self.port = self.conf_client.get_int('port') if not self.port: self.port = 80 self.json_requester = JSONRequester(self.server, self.port) self.json_requester.run() self.json_requester.request('POST', {'cmd': 'identify', 'mac': self.mac_id, 'os_name': self.os_name, 'os_version': self.os_version}, self.on_identify_response, None) #icons self.icons = icons.Icons() self.logo = self.icons.get_icon(CLIENT_ICON_NAME) #MainWindow self.xml = get_gtk_builder('main') self.main_window = self.xml.get_object('window') self.time_str = self.xml.get_object('time_str') self.elapsed_pb = self.xml.get_object('elapsed_pb') self.remaining_pb = self.xml.get_object('remaining_pb') self.full_name = self.xml.get_object('full_name') self.tray_menu = self.xml.get_object('tray_menu') self.show_window_menu = self.xml.get_object('show_window_menu') self.main_window.set_icon_name('telecentros') self.main_window.show() self.visible = True self.show_window_menu.set_active(True) self.xml.connect_signals(self) #Tray self.tray_icon = gtk.status_icon_new_from_icon_name("telecentros") self.tray_icon.set_tooltip(_("TeleCentros")) self.tray_icon.connect('popup-menu', self.on_tray_popup_menu) self.tray_icon.connect('activate', self.on_show_hide) #Login Window self.login_window = login.Login(self) self.login_window.run()