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


Python Watch.update方法代码示例

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


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

示例1: update

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import update [as 别名]
 def update(self, lock):
     """ See if a file was modified or created. """
     self.error = False
     self.updated = False
     self.specto.mark_watch_busy(True, self.id)
     self.specto.logger.log(_("Updating watch: \"%s\"") % self.name, "info", self.__class__)
     
     try:
         self.get_cache_file()
         self.old_values = self.read_cache_file()
         mode = os.stat(self.file)[ST_MODE]
         self.new_files = []
         if S_ISDIR(mode):
             self.get_dir(self.file)
             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.get_file(self.file)
             self.update_cache_file()
             
         #first time don't mark as updated
         if self.first_time == True:
             self.updated = False
             self.first_time = False            
     except:
         self.error = True
         self.specto.logger.log(_("Watch: \"%s\" has an error") % self.name, "error", self.__class__)
     
     self.specto.mark_watch_busy(False, self.id)
     self.actually_updated = self.updated
     Watch.update(self, lock)
开发者ID:nekohayo,项目名称:specto,代码行数:35,代码来源:watch_file.py

示例2: update

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import update [as 别名]
 def update(self, lock):
     """ Check for new mails on your gmail account. """
     self.error = False
     self.specto.mark_watch_busy(True, self.id)
     self.specto.logger.log(_("Updating watch: \"%s\"") % self.name, "info", self.__class__)
     
     try:
         self.oldMsg = self.newMsg
         self.newMsg = 0
         SID = self.get_SID()
         f = file(self.cache_file , "w")
         f.write(str(self.get_reading_list(SID)))
         f.close()
         doc = minidom.parse(self.cache_file)
         rootNode = doc.documentElement
         attributes =[] 
         self.walk(rootNode, False, attributes)
         
         if self.oldMsg == 0 and self.newMsg == 0:#no unread messages, we need to clear the watch
             self.actually_updated=False
             self.specto.notifier.clear_watch("", self.id)
         if self.newMsg > 0:
             self.actually_updated=True
             if self.oldMsg == 0:
                 self.oldMsg = self.newMsg
     except:
         self.error = True
         self.specto.logger.log(_("Watch: \"%s\" has error: Error in processing cache file") % self.name, "error", self.__class__)
         
     self.specto.mark_watch_busy(False, self.id)
     Watch.update(self, lock)
开发者ID:nekohayo,项目名称:specto,代码行数:33,代码来源:watch_web_greader.py

示例3: update

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import update [as 别名]
 def update(self, lock):
     """ Check for new mails on your gmail account. """
     self.error = False
     self.specto.mark_watch_busy(True, self.id)
     self.specto.logger.log(_("Updating watch: \"%s\"") % self.name, "info", self.__class__)
     
     try:
         s = GmailAtom(self.user, self.password)
         s.refreshInfo()
         self.oldMsg = s.getUnreadMsgCount()
         self.newMsg = 0
         if self.oldMsg == 0:#no unread messages, we need to clear the watch
             self.actually_updated=False
             self.specto.notifier.clear_watch("", self.id)
         else:
             i=0
             while i < self.oldMsg:
                 info = s.getMsgAuthorName(i) + s.getMsgTitle(i) + s.getMsgSummary(i) #create unique info
                 if info not in self.mail_info: #check if it is a new email or just unread
                     self.actually_updated=True
                     self.mail_info.append(info)
                     self.newMsg+=1
                 i+=1
     except:
         self.error = True
         self.specto.logger.log(_("Watch: \"%s\" has error: wrong username/password") % self.name, "error", self.__class__)
         
     self.specto.mark_watch_busy(False, self.id)
     Watch.update(self, lock)
开发者ID:nekohayo,项目名称:specto,代码行数:31,代码来源:watch_mail_gmail.py

示例4: update

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import update [as 别名]
 def update(self, lock):
     """ See if a socket was opened or closed. """
     self.error = False
     self.specto.mark_watch_busy(True, self.id)
     self.specto.logger.log(_("Updating watch: \"%s\"") % self.name, "info", self.__class__)
     
     try:
         established = self.check_port()
         if self.running and established == False:
             self.running = False
             self.actually_updated = True
         elif self.running == False and established == True:
             self.running = True 
             self.actually_updated = True
         else: self.actually_updated=False
     except:
         self.error = True
         self.specto.logger.log(_("Watch: \"%s\" has an error") % self.name, "error", self.__class__)
     
     self.specto.mark_watch_busy(False, self.id)
     Watch.update(self, lock)
开发者ID:nekohayo,项目名称:specto,代码行数:23,代码来源:watch_port.py

示例5: update

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import update [as 别名]
 def update(self, lock):
     """ See if a file was modified or created. """
     self.error = False
     self.specto.mark_watch_busy(True, self.id)
     self.specto.logger.log(_("Updating watch: \"%s\"") % self.name, "info", self.__class__)
     
     try:
         process = self.check_process()
         if self.running and process == False:
             self.running = False
             self.updated = True
             self.actually_updated = True
         elif self.running == False and process == True:
             self.running = True 
             self.actually_updated = True
         else: self.actually_updated=False
     except:
         self.error = True
         self.specto.logger.log(_("Watch: \"%s\" has an error") % self.name, "error", self.__class__)
     
     self.specto.mark_watch_busy(False, self.id)
     Watch.update(self, lock)
开发者ID:nekohayo,项目名称:specto,代码行数:24,代码来源:watch_process.py

示例6: content

# 需要导入模块: from spectlib.watch import Watch [as 别名]
# 或者: from spectlib.watch.Watch import update [as 别名]
                            #we want to stay close to the original, because replacing the filesize each time
                            #if the watch is not updated would create a lot of fluctuations
                            self.to_be_stored_filesize = self.old_filesize
                            #if self.specto.DEBUG: print "\tSaved filesize: ", self.to_be_stored_filesize
                            self.actually_updated = False
                else:
                #if there is NO previously stored filesize
                    self.to_be_stored_filesize = self.new_filesize
                    #if self.specto.DEBUG: print "\tSaved filesize: ", self.to_be_stored_filesize

            if (self.url2_ != self.url_) and self.specto.specto_gconf.get_entry("follow_website_redirects") == True:
                self.write_uri()#it's uri, not url.
            self.write_filesize()
            
        self.specto.mark_watch_busy(False, self.id)
        Watch.update(self, lock)

    def content(self):
        """Get the content as a single string."""
        return self.content_
        
    def info(self):
        """ Returns an HTTPMessage for manipulating headers.
    
        Note that you can use this to read headers but not
        to add or change headers. Use the 'add_headers()' for
        adding/changing header values permanently in the cache."""
        return self.info_
    
    def add_headers(self, headers):
        """Add/change header values in the cache.
开发者ID:nekohayo,项目名称:specto,代码行数:33,代码来源:watch_web_static.py


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