コード例 #1
0
 def _AddWatcher( self, watcher ):
     
     watcher.PublishToPage( False )
     watcher.Repage( self._page_key )
     
     self._watchers.append( watcher )
     
     self._last_time_watchers_changed = HydrusData.GetNowPrecise()
     
     watcher_key = watcher.GetWatcherKey()
     
     self._watcher_keys_to_watchers[ watcher_key ] = watcher
     self._watcher_keys_to_added_timestamps[ watcher_key ] = HydrusData.GetNow()
コード例 #2
0
    def Delay(self, seconds):

        if not self._window:

            return

        if self._next_call is None:

            self._next_call = HydrusData.GetNowPrecise()

        while HydrusData.TimeHasPassedPrecise(self._next_call):

            self._next_call += seconds

        self._StartIfNeeded()
コード例 #3
0
    def __init__(self, window, callable):

        self._window = window
        self._callable = callable

        self._running = False

        self._event = threading.Event()

        self._last_call = HydrusData.GetNowPrecise()
        self._seconds = 0.100
        self._next_call = None

        self._repeating = True

        HG.client_controller.sub(self, 'wake', 'wake_daemons')
コード例 #4
0
    def _RemoveWatcher(self, watcher_key):

        if watcher_key not in self._watcher_keys_to_watchers:

            return

        watcher = self._watcher_keys_to_watchers[watcher_key]

        watcher.PublishToPage(False)
        watcher.Repage('dead page key')

        self._watchers.remove(watcher)

        self._last_time_watchers_changed = HydrusData.GetNowPrecise()

        del self._watcher_keys_to_watchers[watcher_key]
コード例 #5
0
    def CallLater(self, seconds, repeating=False):

        if not self._window:

            return

        if seconds == 0.0:

            raise HydrusExceptions.SizeException('Cannot set a 0 timer!')

        self._seconds = seconds

        self._next_call = HydrusData.GetNowPrecise() + self._seconds

        self._repeating = repeating

        self._StartIfNeeded()
コード例 #6
0
    def _RemoveGalleryImport(self, gallery_import_key):

        if gallery_import_key not in self._gallery_import_keys_to_gallery_imports:

            return

        gallery_import = self._gallery_import_keys_to_gallery_imports[
            gallery_import_key]

        gallery_import.PublishToPage(False)
        gallery_import.Repage('dead page key')

        self._gallery_imports.remove(gallery_import)

        self._last_time_imports_changed = HydrusData.GetNowPrecise()

        del self._gallery_import_keys_to_gallery_imports[gallery_import_key]
コード例 #7
0
    def _AddGalleryImport(self, gallery_import):

        gallery_import.PublishToPage(False)
        gallery_import.Repage(self._page_key)

        self._gallery_imports.append(gallery_import)

        self._last_time_imports_changed = HydrusData.GetNowPrecise()

        gallery_import_key = gallery_import.GetGalleryImportKey()

        self._gallery_import_keys_to_gallery_imports[
            gallery_import_key] = gallery_import

        if len(self._gallery_imports
               ) == 1:  # maybe turn this off as a option for advanced users

            self._highlighted_gallery_import_key = gallery_import_key
コード例 #8
0
    def __init__(self, url=None):

        HydrusSerialisable.SerialisableBase.__init__(self)

        self._lock = threading.Lock()

        self._page_key = 'initialising page key'

        self._watchers = HydrusSerialisable.SerialisableList()

        self._highlighted_watcher_url = None

        self._checker_options = HG.client_controller.new_options.GetDefaultWatcherCheckerOptions(
        )
        self._file_import_options = HG.client_controller.new_options.GetDefaultFileImportOptions(
            'loud')
        self._tag_import_options = ClientImportOptions.TagImportOptions(
            is_default=True)

        self._watcher_keys_to_watchers = {}

        self._watcher_keys_to_added_timestamps = {}
        self._watcher_keys_to_already_in_timestamps = {}

        self._watchers_repeating_job = None

        self._status_dirty = True
        self._status_cache = None
        self._status_cache_generation_time = 0

        #

        if url is not None:

            watcher = WatcherImport()

            watcher.SetURL(url)

            self._AddWatcher(watcher)

        self._last_time_watchers_changed = HydrusData.GetNowPrecise()

        self._last_pubbed_value_range = (0, 0)
        self._next_pub_value_check_time = 0
コード例 #9
0
    def __init__(self, gug_key_and_name=None):

        if gug_key_and_name is None:

            gug_key_and_name = (HydrusData.GenerateKey(), 'unknown source')

        HydrusSerialisable.SerialisableBase.__init__(self)

        self._lock = threading.Lock()

        self._page_key = 'initialising page key'

        self._gug_key_and_name = gug_key_and_name

        self._highlighted_gallery_import_key = None

        new_options = HG.client_controller.new_options

        self._file_limit = HC.options['gallery_file_limit']

        self._start_file_queues_paused = False
        self._start_gallery_queues_paused = False

        self._file_import_options = HG.client_controller.new_options.GetDefaultFileImportOptions(
            'loud')
        self._tag_import_options = ClientImportOptions.TagImportOptions(
            is_default=True)

        self._gallery_imports = HydrusSerialisable.SerialisableList()

        self._gallery_import_keys_to_gallery_imports = {}

        self._status_dirty = True
        self._status_cache = None
        self._status_cache_generation_time = 0

        self._last_time_imports_changed = HydrusData.GetNowPrecise()

        self._last_pubbed_value_range = (0, 0)
        self._next_pub_value_check_time = 0

        self._importers_repeating_job = None
コード例 #10
0
    def MainLoop(self):

        while not HG.view_shutdown:

            next_call = self._next_call

            if next_call is None:

                self._running = False

                return

            if HydrusData.TimeHasPassedPrecise(next_call):

                self._Call()

            else:

                ttw = min(30, abs(next_call - HydrusData.GetNowPrecise()))

                self._event.wait(ttw)

                self._event.clear()
コード例 #11
0
        def do_it():

            job_key = ClientThreading.JobKey(pausable=True, cancellable=True)

            job_key.SetVariable('popup_title',
                                self._service.GetName() + ': immediate sync')
            job_key.SetVariable('popup_text_1', 'downloading')

            self._controller.pub('message', job_key)

            content_update_package = self._service.Request(
                HC.GET, 'immediate_content_update_package')

            c_u_p_num_rows = content_update_package.GetNumRows()
            c_u_p_total_weight_processed = 0

            update_speed_string = ''

            content_update_index_string = 'content row ' + HydrusData.ConvertValueRangeToPrettyString(
                c_u_p_total_weight_processed, c_u_p_num_rows) + ': '

            job_key.SetVariable(
                'popup_text_1', content_update_index_string + 'committing' +
                update_speed_string)

            job_key.SetVariable('popup_gauge_1',
                                (c_u_p_total_weight_processed, c_u_p_num_rows))

            for (content_updates, weight
                 ) in content_update_package.IterateContentUpdateChunks():

                (i_paused, should_quit) = job_key.WaitIfNeeded()

                if should_quit:

                    job_key.Delete()

                    return

                content_update_index_string = 'content row ' + HydrusData.ConvertValueRangeToPrettyString(
                    c_u_p_total_weight_processed, c_u_p_num_rows) + ': '

                job_key.SetVariable(
                    'popup_text_1', content_update_index_string +
                    'committing' + update_speed_string)

                job_key.SetVariable(
                    'popup_gauge_1',
                    (c_u_p_total_weight_processed, c_u_p_num_rows))

                precise_timestamp = HydrusData.GetNowPrecise()

                self._controller.WriteSynchronous(
                    'content_updates', {self._service_key: content_updates})

                it_took = HydrusData.GetNowPrecise() - precise_timestamp

                rows_s = weight / it_took

                update_speed_string = ' at ' + HydrusData.ConvertIntToPrettyString(
                    rows_s) + ' rows/s'

                c_u_p_total_weight_processed += weight

            job_key.DeleteVariable('popup_gauge_1')

            self._service.SyncThumbnails(job_key)

            job_key.SetVariable(
                'popup_text_1', 'done! ' +
                HydrusData.ConvertIntToPrettyString(c_u_p_num_rows) +
                ' rows added.')

            job_key.Finish()