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


Python Watch.timer_update方法代码示例

本文整理汇总了Python中spectlib.watch.Watch.timer_update方法的典型用法代码示例。如果您正苦于以下问题:Python Watch.timer_update方法的具体用法?Python Watch.timer_update怎么用?Python Watch.timer_update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在spectlib.watch.Watch的用法示例。


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

示例1: check

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import timer_update [as 别名]
    def check(self):
        """ Check for new news on your greader account. """
        try:
            self.newMsg = 0
            self.unreadMsg = 0
            greader = Greader(self.username, self.password, "specto")
            auth = greader.login()
            feed_db = greader.get_unread_items(auth)
            for feed in feed_db:
                self.unreadMsg += feed.messages
                if feed.messages > 0 and self.news_info.add(feed):
                    self.actually_changed = True
                    self.newMsg += feed.messages
            if self.unreadMsg == 0:#no unread items, we need to clear the watch
                self.mark_as_read()
                self.news_info = Feed_collection()
            else:
                if self.unreadMsg == 1000:
                    self.or_more = _(" or more")
                
            self.write_cache_file()

        except:
            self.set_error()

        Watch.timer_update(self)
开发者ID:Pi03k,项目名称:py3specto,代码行数:28,代码来源:watch_web_greader.py

示例2: check

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import timer_update [as 别名]
 def check(self):
     """ Check if a new song is played on last.fm. """
     try:
         self.lastfm_ = LastFM(self.username)
         song = self.lastfm_.updateData()
         if song != self.previous_song:
             self.previous_song = song
             self.actually_changed = True
     except:
         self.set_error()
     Watch.timer_update(self)
开发者ID:Pi03k,项目名称:py3specto,代码行数:13,代码来源:watch_music_lastfm.py

示例3: check

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import timer_update [as 别名]
 def check(self):
     """ Check for new mails on your pop3 account. """
     try:
         if self.ssl == True:
             if self.port != -1:
                 try:
                     s = poplib.POP3_SSL(self.host, self.port)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
             else:
                 try:
                     s = poplib.POP3_SSL(self.host)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
         else:
             if self.port != -1:
                 try:
                     s = poplib.POP3(self.host, self.port)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
             else:
                 try:
                     s = poplib.POP3(self.host)
                 except:
                     self.set_error()
                     Watch.timer_update(self)
                     return ""
     except poplib.error_protoerror, e:
         self.set_error(str(e))
开发者ID:Pi03k,项目名称:py3specto,代码行数:37,代码来源:watch_mail_pop3.py

示例4: check

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import timer_update [as 别名]
    def check(self):
        """ See if a there are new facebook items. """
        try:
            self.updates = {'message': [], 'notification': [], 'request': [], 'wall': []}
            #message
            facebook = Facebook(self.email, self.password)
            if facebook.connect():
                self.messages = facebook.get_messages()
                for message in self.messages:
                    if message.sender + ": " + message.message not in self.previous_messages:
                        self.updates['message'].append(message.sender + ": " + message.message)
                        self.actually_changed = True
                        self.previous_messages.append(message.sender + ": " + message.message)

                # Facebook notifications
                self.notifications = facebook.get_notifications()
                for notification in self.notifications:
                    if notification.notification not in self.previous_notifications:
                        self.updates['notification'].append(notification.notification)
                        self.actually_changed = True
                        self.previous_notifications.append(notification.notification)

                # Requests
                self.requests = facebook.get_requests()
                for request in self.requests:
                    if request.request not in self.previous_requests:
                        self.updates['request'].append(request.request)
                        self.actually_changed = True
                        self.previous_requests.append(request.request)

                # Wall posts
                self.wall = facebook.get_wall()
                for w in self.wall:
                    if w.poster + ": " + w.post not in self.previous_wall:
                        self.updates['wall'].append(w.poster + ": " + w.post)
                        self.actually_changed = True
                        self.previous_wall.append(w.poster + ": " + w.post)

                self.write_cache_file()
                if len(self.messages) == 0 and len(self.notifications) == 0 and len(self.requests) == 0 and len(self.wall) == 0:
                    self.mark_as_read()
            else:
                self.set_error((_("Wrong username/password")))
        except:
            self.set_error()

        Watch.timer_update(self)
开发者ID:Pi03k,项目名称:py3specto,代码行数:49,代码来源:watch_sn_facebook.py

示例5: check

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import timer_update [as 别名]
    def check(self):
        """ See if a socket was opened or closed. """
        try:
            established = self.check_port()
            if self.running and established == False:
                self.running = False
                self.actually_changed = True
                self.status = _("Closed")
            elif self.running == False and established == True:
                self.running = True
                self.actually_changed = True
                self.status = _("Open")
            else:
                self.actually_changed = False
                self.status = _("Unknown")
        except:
            self.set_error()

        Watch.timer_update(self)
开发者ID:Pi03k,项目名称:py3specto,代码行数:21,代码来源:watch_system_port.py

示例6: check

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import timer_update [as 别名]
    def check(self):
        """ See if a process was started or stopped. """
        try:
            running_now = self.check_process()
            if self.running_initially and running_now == False:
                self.running_initially = False
                self.changed = True
                self.actually_changed = True
                self.status = _("Not running")
            elif self.running_initially == False and running_now == True:
                self.running_initially = True
                self.actually_changed = True
                self.status = _("Running")
            else:
                self.actually_changed = False
                self.status = _("Unknown")
        except:
            self.set_error()

        Watch.timer_update(self)
开发者ID:Pi03k,项目名称:py3specto,代码行数:22,代码来源:watch_system_process.py

示例7: check

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import timer_update [as 别名]
    def check(self):
        """ See if a folder's contents were modified or created. """
        try:
            self.old_values = self.read_cache_file()
            mode = os.stat(self.folder)[ST_MODE]
            self.new_files = []
            if S_ISDIR(mode):
                self.get_dir(self.folder)
                self.update_cache_file()#write the new values to the cache file
                self.old_values = self.read_cache_file() #read the new valeus
                self.get_removed_files() #remove the files that were removed
                self.update_cache_file()#write the values (with the removed lines) to the cache file
            else:
                self.set_error(_('The watch is not set to a folder'))

            #first time don't mark as changed
            if self.first_time == True:
                self.actually_changed = False
                self.first_time = False
        except:
            self.set_error()

        Watch.timer_update(self)
开发者ID:Pi03k,项目名称:py3specto,代码行数:25,代码来源:watch_system_folder.py

示例8: int

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import timer_update [as 别名]
            data = wave.get_unread_waves()
            self.newMsg = 0
            
            for wave in data:
                if "unread" in wave and "title" in wave:
                    self.newMsg += int(wave['unread'])
                    wave_ = Gwave_(wave['title'], int(wave['unread']))
                    if self.waves.add(wave_):
                        self.actually_changed = True
                
            self.write_cache_file()
        except urllib2.URLError, e:
            self.set_error(str(e))  # This '%s' string here has nothing to translate
        except:
            self.set_error()
        Watch.timer_update(self)

    def get_gui_info(self):
        return [(_("Name"), self.name),
                (_("Last changed"), self.last_changed),
                (_("Username"), self.username),
                (_("Unread waves"), self.newMsg)]

    def get_balloon_text(self):
        """ create the text for the balloon """
        if self.newMsg == 1:
            text = _("Unread wave in %s") % self.waves[0].title
        else:
            i = 0 #show max 4 mails
            author_info = ""
            while i < self.newMsg and i < 4:
开发者ID:cappert,项目名称:specto,代码行数:33,代码来源:watch_mail_gwave.py

示例9: check

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import timer_update [as 别名]
    def check(self):
        """ See if a file was modified or created. """
        try:
            self.info = []
            self.file_info = []
            self.old_info = ""
            self.read_cache_file()
            try:
                info = tuple(os.stat(self.file)) #mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime = info
            except OSError:
                self.actually_changed = True
                self.file_info.append(_("The file was removed"))
            else:
                self.old_info = self.old_info.replace("L", "").replace("[", "").replace("]", "").replace("'", "").split(",")

                i = 0
                while i < len(info):
                    self.info.append(str(info[i]).strip())
                    if not self.first_time:
                        self.old_info[i] = str(self.old_info[i]).strip()
                    i += 1

                if self.old_info != self.info and not self.first_time:
                    self.actually_changed = True

                    #if str(self.info[0]) != self.old_info[0].strip():
                    #    self.file_info.append("Inode protection mode changed")

                    #if str(self.info[1]) != self.old_info[1].strip():
                    #    self.file_info.append("Inode number changed")

                    #if str(self.info[2]) != self.old_info[2]:
                    #    self.file_info.append("Device inode resides on changed")

                    #if self.info[3] != self.old_info[3]:
                    #    self.file_info.append("Number of links to the inode changed")

                    if self.info[4] != self.old_info[4]:
                        self.file_info.append(_("User id of the owner changed"))

                    if self.info[5] != self.old_info[5]:
                        self.file_info.append(_("Group id of the owner changed"))

                    if self.info[6] != self.old_info[6]:
                        self.file_info.append(_("File size changed"))

                    if self.info[7] != self.old_info[7]:
                        self.file_info.append(_("Time of last access changed"))

                    if self.info[8] != self.old_info[8]:
                        self.file_info.append(_("Time of last modification changed"))

                    #if self.info[9] != self.old_info[9]:
                    #    self.file_info.append("Metadata changed")

                self.update_cache_file()
                self.first_time = False
        except:
            self.set_error()

        Watch.timer_update(self)
开发者ID:Pi03k,项目名称:py3specto,代码行数:63,代码来源:watch_system_file.py


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