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)
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)
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)
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)
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)
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)
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)
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)
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)
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.
#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.