當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。