当前位置: 首页>>代码示例>>Python>>正文


Python pynotify.init函数代码示例

本文整理汇总了Python中pynotify.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: activate

 def activate(self, text=None):
     self.user = GconfStore.get_instance().get_client().get_string(GCONF_TWITTER_USER)
     self.password = GconfStore.get_instance().get_client().get_string(GCONF_TWITTER_PASSWORD)
     api = twitter.Api()
     pynotify.init("Deskbar Twitter Plugin")
     message = "Your post to Twitter might have had a problem"
     try:
         results = api.PostUpdate(self.user, self.password, self._name)
         if self._name == results.text:
             message = "Your post to Twitter was successful"
         n = pynotify.Notification("Twitter Results", message)
         n.set_icon_from_pixbuf(ICON)
         n.show()
     except URLError, e:
         if e.code == 401:
             message = "Incorrect Twitter Username and/or Password"
         if e.code == 403:
             message = "Your request Twitter was forbidden"
         if e.code == 404:
             message = "The URL for Twitter was not found"
         if e.code == 408:
             message = "The request to Twitter timed out.  Try again later."
         n = pynotify.Notification("Twitter Results", message)
         n.set_icon_from_pixbuf(ICON)
         n.show()
开发者ID:mcg,项目名称:deskbar-plugins,代码行数:25,代码来源:twit.py

示例2: show_command_results

    def show_command_results(self, status, output):
        """
        Shows the output to the users.

        For now, it will write the output to stdout,
        change the icon depending on the status (green
        if the tests are passing, red otherwise) and,
        if pynotify is installed, show a notification.

        If you use this in Ubuntu, I'm sorry for you.
        Canonical just decided to break libnotify in so
        many ways that it is *impossible* to use it sanely.

        """

        sys.stdout.write(output)

        self.current_status = status

        if self.timer.running:
            self._set_icon()

        if pynotify is not None:
            pynotify.init('dojotools')
            message = pynotify.Notification('Dojotools', self.html_escape(output))
            message.attach_to_status_icon(self.status_icon)
            message.set_urgency(
                pynotify.URGENCY_NORMAL if status == 0
                else pynotify.URGENCY_CRITICAL
            )
            message.show()
开发者ID:andrewsmedina,项目名称:dojotools,代码行数:31,代码来源:ui.py

示例3: _setup_notification

  def _setup_notification (self):
    """Creates the pynotify object"""

    pynotify.init ("Brightness Notifications")

    self._notification = pynotify.Notification ("Brightness")
    self._notification.set_timeout (self._config.show_for)
开发者ID:mmawdsley,项目名称:awesome-config,代码行数:7,代码来源:brightness.py

示例4: menuitem_response

def menuitem_response(w, buf):
    if buf == "_about" :
        md = gtk.MessageDialog(None,0, gtk.MESSAGE_INFO,
             gtk.BUTTONS_OK)
        md.set_markup("<b>sshlist v%s</b>" % ver)
        md.format_secondary_markup("""A simple sshmenu like replacement for appindicator menu.

To add items to menu, simply edit the file <i>.sshlist</i> in your home directory (one host per line).

Author: [email protected]
http://www.gulecha.org""")
        md.run()
        md.destroy()
    elif buf == "_refresh":
        newmenu = build_menu()
        ind.set_menu(newmenu)
        # Initialize pynotify, without this it crashes on "Refresh"
        pynotify.init("SSHList Notification")
        pynotify.Notification("sshlist refreshed","Menu list was refreshed from ~/.sshlist").show()
    elif buf == "_quit":
        newmenu = build_menu()
        ind.set_menu(newmenu)
        gtk.mainquit()
    else:
        print "gnome-terminal -x ssh " + buf + " &"
        run_program("gnome-terminal -x ssh " + buf + " &")
开发者ID:blutgens,项目名称:misc-python,代码行数:26,代码来源:sshlist.py

示例5: sendmessage

def sendmessage(title, message):
    pynotify.init("Steam players notification")
    n = pynotify.Notification(title, message)
    n.set_urgency(pynotify.URGENCY_NORMAL)

    n.show()
    return
开发者ID:lionaneesh,项目名称:FollowSteamUsers,代码行数:7,代码来源:steamtify.py

示例6: pownce

    def pownce(self):
        print "Trying Pownce update"
        pownce_account = Account ("pownce.com", "Pownce API")
        user, password, key = pownce_account.get_credentials()
        url = "http://%s:%[email protected]/2.0/send/message.json" % (user, password)
        pynotify.init("Deskbar Wayd Plugin - Pownce")
        message = "Your post to Pownce might have had a problem"
        data = urlencode({"app_key" : "4d7p84417z5u1871edn578j300t14c4s", 
                          "note_body" : self.text,
                          "note_to" : "public"})

        try:
            result = simplejson.load(urlopen(url,data))
            if result.has_key("error"):
                message = result['error']['message']
            else:
               if result['body'] == self.text:
                    message = "Your post to Pownce was successful"
            n = pynotify.Notification("Pownce Results", message, "stock_internet")
            n.show()
        except urllib.URLError, e:
            if e.code == 401:
                message = "Incorrect Pownce Username and/or Password"
            if e.code == 403:
                message = "Your Pownce request was forbidden"
            if e.code == 404:
                message = "The URL for Pownce was not found"
            if e.code == 408:
                message = "The request to Pownce timed out.  Try again later."
            n = pynotify.Notification("Pownce Results", message, "stock_internet")
            n.show()
开发者ID:mcg,项目名称:deskbar-plugins,代码行数:31,代码来源:wayd.py

示例7: __init__

    def __init__(self):
        wx.Frame.__init__(self, id=-1, parent=None, name=u'RCWatchFrame',
                          size=wx.Size(WIDTH, HEIGHT), title=u'RC Status')
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.rc_statusText = wx.StaticText(self, -1, "UNKWN")

        pygame.mixer.init()
        self.alertSound = pygame.mixer.Sound("crossing.wav")
        self.alertChannel = pygame.mixer.Channel(False)

        self.setFont(self.rc_statusText)

        self.notification = pynotify.Notification("RC Link Warning!",
                                                  "RC Link status not OK!",
                                                  "dialog-warning")

        self.rc_status = -1

        pynotify.init("RC Status")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.rc_statusText, 1, wx.EXPAND)
        self.SetSizer(sizer)
        sizer.Layout()
        self.interface = IvyMessagesInterface("radiowatchframe")
        self.interface.subscribe(self.message_recv)
        self.update_timer = wx.CallLater(UPDATE_INTERVAL, self.gui_update)
开发者ID:2seasuav,项目名称:paparuzzi,代码行数:28,代码来源:radiowatchframe.py

示例8: __init__

	def __init__(self):
		self._statusicon = gtk.StatusIcon()
		pynotify.init('Snappy screen capture')
		self._statusicon.connect('activate', self._emit_proxy, 'activate')
		self._statusicon.connect('popup_menu', self._emit_proxy, 'popup_menu')
		self._statusicon.set_visible(True)
		super(SimpleGTKStatusIcon, self).__init__()
开发者ID:BZZYTGTD,项目名称:snappy,代码行数:7,代码来源:statusicon.py

示例9: display_notification

    def display_notification(self, return_code=None):
        if return_code is None and settings.aborted.show:
            description = settings.aborted.description % self.string_duration()
            timeout = settings.aborted.timeout

        elif return_code == 0 and settings.success.show:
            description = settings.success.description % self.string_duration()
            timeout = settings.success.timeout

        elif return_code is not None and settings.failed.show:
            description = settings.failed.description % (return_code, self.string_duration())
            timeout = settings.failed.timeout

        else:
            return

        if hasattr(notify, "GrowlNotifier"):
            g = notify.GrowlNotifier(u"naf", notifications=["command_finished"])
            g.register()
            g.notify("command_finished", self.command, description)
        elif hasattr(notify, "Notification"):
            if return_code == 0:
                icon = gtk.STOCK_DIALOG_INFO
            else:
                icon = gtk.STOCK_DIALOG_ERROR
            notify.init("Notify At Finish")
            notification = notify.Notification(self.command, description, icon)
            notification.set_timeout(timeout)
            notification.show()
开发者ID:knutz3n,项目名称:naf,代码行数:29,代码来源:__main__.py

示例10: __init__

	def __init__(self, config, verbose=False):
		"""
		initialized the logging and notification
		"""
		self.statusIcon = None
		self.indicator = None
		self.status_button = None
		self.status_text = None
		self.config = config
		#init logging 
		self.log = logging.getLogger("")
		os.popen("touch %s"%self.config.getAttribute('LOGFILE'))
		hdlr = logging.handlers.RotatingFileHandler(self.config.getAttribute('LOGFILE'), "a", 1000000, 3)
		fmt = logging.Formatter("%(asctime)s %(levelname)-5s %(message)s", "%x %X")
		hdlr.setFormatter(fmt)
		self.log.addHandler(hdlr)
		self.verbose = verbose

		#init notify
		self.notifyid = "Persy"
		try:
			pynotify.init(self.notifyid)
		except Exception as e:
			self.log.warn(str(e))

		self.resetError()
开发者ID:bwegh,项目名称:persy,代码行数:26,代码来源:persy_talker.py

示例11: __init__

    def __init__(self, event, tray_icon, config):
        AlertDisplay.__init__(self, event, config)

        import pynotify
        pynotify.init('wuja')

        title = event.entry.title + " - Wuja"
        start_time = event.time.strftime("%a %b %d %Y - %I:%M%P")
        duration = str(timedelta(seconds=event.entry.duration))
        calendar = str(event.entry.calendar.title)
        where = str(event.entry.location)
        description = event.entry.description

        body = start_time + "\n" + \
            "Duration - " + duration + "\n"  + \
            "Calendar - " + calendar + "\n" + \
            "Location - " + where
        if description != None:
            body += "\n" + description

        pynotify.init(title)
        notif = pynotify.Notification(title, body)
        notif.attach_to_widget(tray_icon)
        notif.set_timeout(0)
        notif.add_action('accept', 'Accept', self.accept_event)
        notif.add_action('snooze', 'Snooze', self.snooze_event)

        notif.show()
开发者ID:dgoodwin,项目名称:wuja,代码行数:28,代码来源:application.py

示例12: sendmessage

def sendmessage(title, message):
    pynotify.init("image")
    notice = pynotify.Notification(
        title,
        message,
        "/usr/share/icons/gnome/48x48/status/appointment-missed.png").show()
    return notice
开发者ID:WhiteIsClosing,项目名称:plib,代码行数:7,代码来源:pan_notify.py

示例13: __init__

 def __init__(self):
     self.logger = logging.getLogger(__name__)
     self.logger.debug('Initializing notify object')
     if sys.platform == 'linux2':
         self.user = ''
         who = Popen(['/usr/bin/who'], stdout=PIPE).stdout.read()
         for line in who.splitlines():
             if 'tty7' in line:
                 self.user = line.split()[0]  
                 if '(' in line.split()[-1]:
                     self.display = line.split()[-1].replace('(','').replace(')','')
                 else:
                     self.display = ':0'
                 break
         if not self.user:
             self.logger.error('User not found in tty7. Probably no one logged in or in other terminal') 
             raise Exception('No user found.')              
         self.logger.debug('Set user : {0}'.format(self.user))
         self.logger.debug('Set display : {0}'.format(self.display))
         self.logger.debug('Initializing pynotify')
         pynotify.init('Summary')
         self.__notifier = pynotify.Notification
         self.message = self.__message
                    
     if sys.platform == 'win32':
         self.logger.debug('Initializing WindowsBalloonTip')
         self.__notifier = WindowsBalloonTip()
         self.message = self.__message
开发者ID:costastf,项目名称:blind-Pyrsync,代码行数:28,代码来源:notify.py

示例14: run_command

def run_command(directory, test_cmd):
    """
    As the name says, runs a command and wait for it to finish
    """
    process = subprocess.Popen(
        test_cmd,
        shell = True,
        cwd = directory,
        stdout = subprocess.PIPE,
        stderr = subprocess.PIPE,
    )

    output = process.stdout.read()
    output += process.stderr.read()
    status = process.wait()

    sys.stdout.write(output)

    if pynotify:
        pynotify.init('dojotools')
        message = pynotify.Notification('Dojotools', output)

        message.set_urgency(pynotify.URGENCY_NORMAL if status == 0 else pynotify.URGENCY_CRITICAL)

        message.show()
开发者ID:curtocircuito,项目名称:dojo-centro,代码行数:25,代码来源:dojotools.py

示例15: twitter

    def twitter(self):
        print "Trying Twitter update"
        twit_account = Account ("twitter.com", "Twitter API")
        user, password, key = twit_account.get_credentials()
        api = twitter.Api(user, password)
        pynotify.init("Deskbar Wayd Plugin - Twitter")
        message = "Your post to Twitter might have had a problem"

        if len(self.text) > 140:
            message="Your post is too long for Twitter."
            n = pynotify.Notification("Twitter Results", message, "stock_internet")
            n.show()
            return

        try:
            results = api.PostUpdate(self.text)
            if self.text == results.text:
                message = "Your post to Twitter was successful"
            n = pynotify.Notification("Twitter Results", message, "stock_internet")
            n.show()
        except urllib2.URLError, e:
            if e.code == 401:
                message = "Incorrect Twitter Username and/or Password"
            if e.code == 403:
                message = "Your request Twitter was forbidden"
            if e.code == 404:
                message = "The URL for Twitter was not found"
            if e.code == 408:
                message = "The request to Twitter timed out.  Try again later."
            n = pynotify.Notification("Twitter Results", message, "stock_internet")
            n.show()
开发者ID:mcg,项目名称:deskbar-plugins,代码行数:31,代码来源:wayd.py


注:本文中的pynotify.init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。