def REPEATINGWorkOnQueue(self, page_key): with self._lock: if ClientImporting.PageImporterShouldStopWorking(page_key): self._queue_repeating_job.Cancel() return queue_paused = self._queue_paused or HG.client_controller.new_options.GetBoolean( 'pause_all_gallery_searches') queue_good = not queue_paused page_shown = not HG.client_controller.PageClosedButNotDestroyed( page_key) network_engine_good = not HG.client_controller.network_engine.IsBusy( ) ok_to_work = queue_good and page_shown and network_engine_good while ok_to_work: try: did_work = self._WorkOnQueue(page_key) if did_work: time.sleep(ClientImporting. DID_SUBSTANTIAL_FILE_WORK_MINIMUM_SLEEP_TIME) else: return HG.client_controller.WaitUntilViewFree() except Exception as e: HydrusData.ShowException(e) with self._lock: if ClientImporting.PageImporterShouldStopWorking(page_key): self._queue_repeating_job.Cancel() return queue_paused = self._queue_paused or HG.client_controller.new_options.GetBoolean( 'pause_all_gallery_searches') queue_good = not queue_paused page_shown = not HG.client_controller.PageClosedButNotDestroyed( page_key) network_engine_good = not HG.client_controller.network_engine.IsBusy( ) ok_to_work = queue_good and page_shown and network_engine_good
def REPEATINGWorkOnFiles(self): with self._lock: if ClientImporting.PageImporterShouldStopWorking(self._page_key): self._files_repeating_job.Cancel() return files_paused = self._files_paused or HG.client_controller.new_options.GetBoolean( 'pause_all_file_queues') work_pending = self._file_seed_cache.WorkToDo( ) and not files_paused no_delays = HydrusData.TimeHasPassed(self._no_work_until) page_shown = not HG.client_controller.PageClosedButNotDestroyed( self._page_key) network_engine_good = not HG.client_controller.network_engine.IsBusy( ) ok_to_work = work_pending and no_delays and page_shown and network_engine_good while ok_to_work: try: self._WorkOnFiles() HG.client_controller.WaitUntilViewFree() except Exception as e: HydrusData.ShowException(e) with self._lock: if ClientImporting.PageImporterShouldStopWorking( self._page_key): self._files_repeating_job.Cancel() return files_paused = self._files_paused or HG.client_controller.new_options.GetBoolean( 'pause_all_file_queues') work_pending = self._file_seed_cache.WorkToDo( ) and not files_paused no_delays = HydrusData.TimeHasPassed(self._no_work_until) page_shown = not HG.client_controller.PageClosedButNotDestroyed( self._page_key) network_engine_good = not HG.client_controller.network_engine.IsBusy( ) ok_to_work = work_pending and no_delays and page_shown and network_engine_good
def REPEATINGWorkOnGallery(self, page_key): with self._lock: if ClientImporting.PageImporterShouldStopWorking(page_key): self._gallery_repeating_job.Cancel() return gallery_paused = self._paused or HG.client_controller.new_options.GetBoolean( 'pause_all_gallery_searches') work_to_do = self._gallery_seed_log.WorkToDo() and not ( gallery_paused or HG.client_controller.PageClosedButNotDestroyed(page_key)) network_engine_good = not HG.client_controller.network_engine.IsBusy( ) ok_to_work = work_to_do and network_engine_good while ok_to_work: try: self._WorkOnGallery(page_key) HG.client_controller.WaitUntilViewFree() except Exception as e: HydrusData.ShowException(e) with self._lock: if ClientImporting.PageImporterShouldStopWorking(page_key): self._gallery_repeating_job.Cancel() return gallery_paused = self._paused or HG.client_controller.new_options.GetBoolean( 'pause_all_gallery_searches') work_to_do = self._gallery_seed_log.WorkToDo() and not ( gallery_paused or HG.client_controller.PageClosedButNotDestroyed(page_key)) network_engine_good = not HG.client_controller.network_engine.IsBusy( ) ok_to_work = work_to_do and network_engine_good
def REPEATINGWorkOnWatchers(self): with self._lock: if ClientImporting.PageImporterShouldStopWorking(self._page_key): self._watchers_repeating_job.Cancel() return if not self._status_dirty: # if we think we are clean for watcher in self._watchers: file_seed_cache = watcher.GetFileSeedCache() if file_seed_cache.GetStatusGenerationTime( ) > self._status_cache_generation_time: # has there has been an update? self._SetDirty() break if HydrusData.TimeHasPassed(self._next_pub_value_check_time): self._next_pub_value_check_time = HydrusData.GetNow() + 5 current_value_range = self.GetValueRange() if current_value_range != self._last_pubbed_value_range: self._last_pubbed_value_range = current_value_range HG.client_controller.pub('refresh_page_name', self._page_key)
def REPEATINGWorkOnChecker(self): with self._lock: if ClientImporting.PageImporterShouldStopWorking(self._page_key): self._checker_repeating_job.Cancel() return checking_paused = self._checking_paused or HG.client_controller.new_options.GetBoolean( 'pause_all_watcher_checkers') able_to_check = self._checking_status == ClientImporting.CHECKER_STATUS_OK and self._HasURL( ) and not checking_paused check_due = HydrusData.TimeHasPassed(self._next_check_time) no_delays = HydrusData.TimeHasPassed(self._no_work_until) page_shown = not HG.client_controller.PageClosedButNotDestroyed( self._page_key) network_engine_good = not HG.client_controller.network_engine.IsBusy( ) time_to_check = able_to_check and check_due and no_delays and page_shown and network_engine_good if time_to_check: try: self._CheckWatchableURL() except Exception as e: HydrusData.ShowException(e)
def CanDoFileWork(self, page_key): with self._lock: if ClientImporting.PageImporterShouldStopWorking(page_key): self._files_repeating_job.Cancel() return False paused = self._paused or HG.client_controller.new_options.GetBoolean( 'pause_all_file_queues') if paused: return False work_to_do = self._file_seed_cache.WorkToDo() if not work_to_do: return False page_shown = not HG.client_controller.PageClosedButNotDestroyed( page_key) if not page_shown: return False return True
def REPEATINGWorkOnFiles(self, page_key): with self._lock: if ClientImporting.PageImporterShouldStopWorking(page_key): self._files_repeating_job.Cancel() return paused = self._paused or HG.client_controller.new_options.GetBoolean( 'pause_all_file_queues') work_to_do = self._file_seed_cache.WorkToDo() and not ( paused or HG.client_controller.PageClosedButNotDestroyed(page_key)) while work_to_do: try: self._WorkOnFiles(page_key) HG.client_controller.WaitUntilViewFree() except Exception as e: HydrusData.ShowException(e) with self._lock: if ClientImporting.PageImporterShouldStopWorking(page_key): self._files_repeating_job.Cancel() return paused = self._paused or HG.client_controller.new_options.GetBoolean( 'pause_all_file_queues') work_to_do = self._file_seed_cache.WorkToDo() and not ( paused or HG.client_controller.PageClosedButNotDestroyed(page_key))
def CanDoQueueWork(self, page_key): with self._lock: if ClientImporting.PageImporterShouldStopWorking(page_key): self._queue_repeating_job.Cancel() return False queue_paused = self._queue_paused or HG.client_controller.new_options.GetBoolean( 'pause_all_gallery_searches') if queue_paused: return False return self.CanDoNetworkWork(page_key)
def CanDoFileWork(self, page_key): with self._lock: if ClientImporting.PageImporterShouldStopWorking(page_key): self._files_repeating_job.Cancel() return False files_paused = self._files_paused or HG.client_controller.new_options.GetBoolean( 'pause_all_file_queues') if files_paused: return False work_to_do = self._file_seed_cache.WorkToDo() if not work_to_do: return False return self.CanDoNetworkWork(page_key)
def CanDoGalleryWork(self, page_key): with self._lock: if ClientImporting.PageImporterShouldStopWorking(page_key): self._gallery_repeating_job.Cancel() return False gallery_paused = self._paused or HG.client_controller.new_options.GetBoolean( 'pause_all_gallery_searches') if gallery_paused: return False work_to_do = self._gallery_seed_log.WorkToDo() if not work_to_do: return False return self.CanDoNetworkWork(page_key)