def process_IN_CLOSE(self, event): "Process IN_CLOSE_(WRITE|NO_WRITE) inotify events." if not self._locked: self._locked = True lintFile = open(event.path) title = '' body = '' icon = '' for line in [line.rstrip() for line in lintFile if line != "\n" and not line.startswith('Errors parsing')]: ok = self._okRegex.search(line) if ok: [message, file] = ok.groups() if file in self._effedFiles: self._effedFiles.remove(file) title = basename(file) body = "%s\n(%s)" % (message, file) icon = STOCK_DIALOG_INFO else: [error, file, line] = self._errorRegex.search(line).groups() if not file in self._effedFiles: self._effedFiles.append(file) title = "%s, line %s" % (basename(file), line) body = "%s\n(%s)" % (error, file) icon = STOCK_DIALOG_ERROR if body != '': notification = Notification(title, body, icon) notification.show() lintFile.close() self._locked = False
def _notify(link): if link and link != 'Unauthorized': try: cmd = 'echo ' + link.strip() + ' | xclip -selection c.' check_call(cmd, shell=True) # The error for 'command not found' is subprocess.CalledProcessError except Exception as e: clip = gtk.clipboard_get('CLIPBOARD') clip.set_text(link, -1) clip.store() if init('puush'): if not link: n = Notification('Puush failed', 'You should check your Internet connection', 'file://' + dirname(__file__) + '/error.png') else: if link == 'Unauthorized': n = Notification('Puush failed', 'Your API key has been rejected', 'file://' + dirname(__file__) + '/warning.png') else: n = Notification('Puush completed', link, 'file://' + dirname(__file__) + '/success.png') n.show() sleep(NOTIFY_TIMEOUT) n.close() else: print 'Error starting PyNotify'
def notify(message="", output=False): if output: prefix = "Fabric says: " else: prefix = "Fabric requires input: " n = Notification(prefix, message) n.show()
def display_changesets(changesets, count): for changeset in changesets: modified = len(changeset.files) count -= 1 count = count if count > 0 else u'ждем' suffix, = filter(lambda e: modified in plura[e], plura.iterkeys()) count_suf = filter(lambda e: count in plura[e], plura.iterkeys()) count_suf = count_suf.pop() if count_suf else '' message = (u'Изменения от {0} <{1}>\n{2}\n Изменения: {3} файл{4}\n' u'Описание: {5}\nЕще {6} бабл{7}.').format( changeset.user.name, changeset.user.email, changeset.date, modified, suffix, changeset.description, count, count_suf ) note = Notification(changeset.user.name, message, changeset.user.pic) note.show() sleep(11)
def initial_pull(cls): n = Notification("Version Control Notifier started", "Version Control Notifier will now notify you of any changes via libnotify") n.show() config = cls.read_config() for pair in config.items('providers'): if pair[0] == 'bitbucket': cls.parse_bitbucket(parse(pair[1]), display=False) elif pair[0] == 'github': cls.parse_github(parse(pair[1]), display=False) return True
def create_notification(self, title, updates, urgency, icon, updates_available): ''' Create a notification message. @title: Title of the notification @updates: Update message (packages) @urgency: Used to set the notification urgency (notice, important and so on) @icon: Set the notification's icon @updates_available: Used to decide which button should be add to the notification ''' # Setting notification_delay timeout = int(ConfPacupdate().readConf().get('global', 'notification_delay')) * 1000 if not init( "pacupdate"): print _('Failed to init pynotify. Please, verify if python-notify is installed.') else: self.notification = Notification(title, updates.strip() + '\n') self.notification.set_urgency(urgency) self.notification.set_timeout(timeout) self.notification.set_icon_from_pixbuf(icon) self.notification.attach_to_status_icon(self) # Just show a "check for updates button" in the notification if # there are updates available if updates_available: self.notification.add_action('show_updates', 'Show full updates list',self.show_updates) if not self.notification.show(): print _('Failed to show notification.')
def CreateAll(saveddir): savepath = os.path.join(saveddir, filename) savename = "%s.png" % savepath savenumb = 1 while os.path.exists(savename): savename = ("%s-%s.png" % (savepath, savenumb)) savenumb += 1 Shot = MakeShot() Shot.Make(savename) if RUNPROGRM: call("%s '%s' &" % (RUNPROGRM, savename), shell=True) if SHOWNOTYF: mess = Noti('Screenlist saved in', savename, 'dialog-information') mess.show()
def parse_bitbucket(cls, raw, display=True): count = 0 for inst in raw['entries']: soup = BeautifulSoup(inst['summary']) try: if(soup.find('p')): n = Notification(inst['title'], soup.find('p').text) if(not cls.displayed_messages.__contains__(inst['id'])): cls.displayed_messages.append(inst['id']) if n and display: n.show() count += 1 if count > 3: return True except Exception, e: print "ERROR" print e
def fetched_schedule_cb(self, updater, schedule, exc): updater.destroy() if schedule is not None: self.schedule = schedule # Hooray! We can now let the user interact with the application, if # they weren't already. for b in self.buttons: b.set_sensitive(True) else: print repr(exc) # Should I use a fake try: raise; except: maybe? if isinstance(exc, MalformedSchedule): Notification("Schedule file was malformed").show() elif not isinstance(exc, gio.Error) or \ exc.code != gio.ERROR_CANCELLED: Notification("Couldn't fetch latest schedule").show()
class PyflakesPlugin: message = None def __init__(self, window): self._window = window def deactivate(self): self._window = None self._plugin = None def update_ui(self): self.notify_erros() @property def doc(self): return self._window.get_active_document() def notify_erros(self): if self.is_python(): filename = self.doc.get_uri_for_display() message = self.check() if message: self.notify(filename, message) def check(self): bounds = self.doc.get_bounds() text = self.doc.get_text(*bounds) with redirect_out() as out: pyflakes.check(text, 'line') return out.getvalue() def is_python(self): if self.doc is None:return False lang = self.doc.get_language() return lang and lang.get_name() == 'Python' def notify(self, title, message): if init("geditpyflakes") and self.message != message: self.message = message self.notification = Notification(title, message) self.notification.set_timeout(1) self.notification.show()
def notify(title, msg='', msgtype="info", timeout=10000): print title + ': ' + msg if sys.platform.startswith('linux'): n = Notification(title, msg) n.set_timeout(timeout) return n.show() elif sys.platform.startswith('darwin'): args = ['growlnotify'] args.append('-t') args.append(title) args.append('-m') args.append(msg) # TODO change icon of growl notify message! # args.append('--iconpath') # args.append('icon.png') process = Popen(args, stdout=PIPE, stderr=PIPE) process.wait() return process.returncode == 0 else: print title + ': ' + msg return False
def notify(opts): if CANCELLED.is_set(): return if CHILD.returncode != 0 and OPTS.show_errors: OUTPUT.show() if not OPTS.notify: return pynotify.init('indicate-task') notification = Notification(OPTS.description or 'task', "Finished %s" % ('successfully' if CHILD.returncode == 0 else ('with error code %s' % (CHILD.returncode,))), OPTS.style) notification.set_hint_double('transient', 1) notification.set_timeout(200) notification.show()
def Notify(title, message=""): # Trick = you need to set the display so notify can find it. os.environ["DISPLAY"] = ":0.0" n = Notification(title, message) n.show()
def on_window_updated(self, widget, title): msg = Notification( _('There is a new strip of %s!') % widget.feed_name, None, applet_icon) msg.show()
def pynotify(title, body, icon='notification-audio-play'): n = Notification(title, body, icon) n.set_hint_string("x-canonical-append", "true") n.set_hint_int32("transient", 1) n.show()
def __init__(self, song): Notification.__init__(self, song) self.show()
def on_window_updated(self, widget, title): msg = Notification(_('There is a new strip of %s!') % widget.feed_name, None, applet_icon) msg.show()
class PacupdateTrayIcon(gtk.StatusIcon): ''' Create a trayicon of pacupdate ''' data_dir = '/usr/share/pacupdate' pacupdate_tray_icon = data_dir + '/img/pacupdate-pack.png' pacupdate_tray_icon_alert = data_dir + '/img/pacupdate-alert.png' def check_data_dir(self): ''' Check if pacupdate data directory exists. It is used to see if pacupdate is already installed or not. ''' if path.exists('/usr/share/pacupdate'): return True def create_tray(self): gtk.StatusIcon.__init__(self) if not self.check_data_dir(): print _('pacupdate did not found images directory (perhaps pacupdate is not installed?).') print _('Using current directory.') self.data_dir = '.' self.pacupdate_tray_icon = self.data_dir + '/img/pacupdate-pack.png' self.pacupdate_tray_icon_alert = self.data_dir + '/img/pacupdate-alert.png' menu = ''' <ui> <menubar name="Menubar"> <menu action="Menu"> <menuitem action="Check for updates"/> <menuitem action="Preferences"/> <menuitem action="About"/> <separator/> <menuitem action="Quit"/> </menu> </menubar> </ui> ''' actions = [ ('Menu', None, 'Menu'), ('Check for updates', gtk.STOCK_FIND, _('Check for updates'), None, 'Check updates for your system', self.on_updates), ('Preferences', gtk.STOCK_PREFERENCES, _('Preferences'), None, 'Change pacupdate preferences', self.on_preferences), ('About', gtk.STOCK_ABOUT, _('About'), None, 'About pacupdate', self.on_about), ('Quit', gtk.STOCK_QUIT, _('Quit'), None, 'Exit pacupdate', self.on_quit)] action_groups = gtk.ActionGroup('Actions') action_groups.add_actions(actions) self.manager = gtk.UIManager() self.manager.insert_action_group(action_groups, 0) self.manager.add_ui_from_string(menu) self.menu = self.manager.get_widget('/Menubar/Menu/About').props.parent try: self.set_from_file(self.pacupdate_tray_icon) self.set_tooltip(_('Pacupdate - Managing your Arch Linux Updates')) self.set_visible(True) self.connect('popup-menu', self.on_popup_menu) self.connect('activate', self.on_updates, False) except: print _('Your system is not able to show pacupdate tray icon.') self.on_quit() def on_popup_menu(self, status, button, time): self.menu.popup(None, None, None, button, time) def check_updates(self, sync): ''' Get (and return) all updates available @sync: used to sync pacman's DB or not ''' # Syncing data bases and getting updates try: self.set_blinking(True) self.set_tooltip(_('Syncing databases...')) if sync: if UpdateChecker().sync_db() == False: self.set_blinking(False) return False updates = UpdateChecker().get_updates() self.set_blinking(False) self.set_tooltip(_('Pacupdate - Managing your Arch Linux Updates')) return updates except KeyboardInterrupt: print _('Bye Bye ... :)') pass def show_updates(self, notification, action): assert action == 'show_updates' notification.close() self.on_updates(False,True) def create_notification(self, title, updates, urgency, icon, updates_available): ''' Create a notification message. @title: Title of the notification @updates: Update message (packages) @urgency: Used to set the notification urgency (notice, important and so on) @icon: Set the notification's icon @updates_available: Used to decide which button should be add to the notification ''' # Setting notification_delay timeout = int(ConfPacupdate().readConf().get('global', 'notification_delay')) * 1000 if not init( "pacupdate"): print _('Failed to init pynotify. Please, verify if python-notify is installed.') else: self.notification = Notification(title, updates.strip() + '\n') self.notification.set_urgency(urgency) self.notification.set_timeout(timeout) self.notification.set_icon_from_pixbuf(icon) self.notification.attach_to_status_icon(self) # Just show a "check for updates button" in the notification if # there are updates available if updates_available: self.notification.add_action('show_updates', 'Show full updates list',self.show_updates) if not self.notification.show(): print _('Failed to show notification.') def on_updates(self, sync=True,showFull=False): ''' Setup messages, icon, urgency and title for the notification. They can different depending if there is a update available or not @sync: set True to sync pacupdate's DB @showFull: Used to show full update list or not. By default shows just 10 packages ''' packages_list = self.check_updates(sync) if packages_list == False: return None if packages_list == None: title = _('Your system is up to date') message = _('There are no updates available for your system or you did not run "Check for updates" yet.') urgency = URGENCY_NORMAL icon = gtk.Button().render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG) self.set_from_file(self.pacupdate_tray_icon) updates_available = False else: message = '' if showFull == False: for package in packages_list[1:11]: message = message + ' ' + package else: for package in packages_list[1:]: message = message + ' ' + package title = 'pacupdate :: ' + _('%s Update(s) available') % packages_list[0] icon = gtk.Button().render_icon(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) urgency = URGENCY_CRITICAL self.set_from_file(self.pacupdate_tray_icon_alert) updates_available = True # Creates the notification self.create_notification(title, message.strip(), urgency, icon, updates_available) def on_preferences(self, data): ''' Method to call the preferences window. ''' PreferencesWindows() def on_about(self, data): ''' Method to create about window. ''' dialog = gtk.AboutDialog() dialog.set_name('pacupdate') dialog.set_version('0.1.1') dialog.set_comments(_('Arch linux (pacman) updates notification')) dialog.set_copyright('Copyright - 2008 \n Hugo Doria \n Kessia Pinheiro') dialog.set_website('http://code.google.com/p/pacupdate/') dialog.set_website_label(_('pacupdate Homepage')) dialog.set_authors(["Hugo Doria <*****@*****.**>", 'Kessia Pinheiro <*****@*****.**>']) dialog.set_license("""pacupdate version 0.1 Copyright (C) 2008 Hugo Doria, [email protected] Copyright (C) 2008 Kessia Pinheiro, [email protected] This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation; 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, Fifth Floor, Boston, MA 02110-1301, USA. """) dialog.set_logo(gtk.gdk.pixbuf_new_from_file(self.pacupdate_tray_icon)) dialog.run() dialog.destroy() def on_quit(self, data): gtk.main_quit()
def notify(self, title, message): if init("geditpyflakes") and self.message != message: self.message = message self.notification = Notification(title, message) self.notification.set_timeout(1) self.notification.show()