How to use the hydrus.core.HydrusGlobals function in hydrus

To help you get started, we’ve selected a few hydrus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hydrusnetwork / hydrus / hydrus / core / HydrusThreading.py View on Github external
def do_test():
        
        if HG.model_shutdown:
            
            try:
                
                process.kill()
                
            except:
                
                pass
                
            
            raise HydrusExceptions.ShutdownException( 'Application is shutting down!' )
github hydrusnetwork / hydrus / hydrus / client / importing / ClientImportSimpleURLs.py View on Github external
def __init__( self ):
        
        HydrusSerialisable.SerialisableBase.__init__( self )
        
        self._gallery_seed_log = ClientImportGallerySeeds.GallerySeedLog()
        self._file_seed_cache = ClientImportFileSeeds.FileSeedCache()
        self._file_import_options = HG.client_controller.new_options.GetDefaultFileImportOptions( 'loud' )
        self._tag_import_options = ClientImportOptions.TagImportOptions( is_default = True )
        self._paused = False
        
        self._downloader_key = HydrusData.GenerateKey()
        
        self._lock = threading.Lock()
        
        self._files_network_job = None
        self._gallery_network_job = None
        
        self._files_repeating_job = None
        self._gallery_repeating_job = None
        
        HG.client_controller.sub( self, 'NotifyFileSeedsUpdated', 'file_seed_cache_file_seeds_updated' )
        HG.client_controller.sub( self, 'NotifyGallerySeedsUpdated', 'gallery_seed_log_gallery_seeds_updated' )
github hydrusnetwork / hydrus / hydrus / client / gui / ClientGUICanvasMedia.py View on Github external
def _DrawBackground( self, painter ):
        
        new_options = HG.client_controller.new_options
        
        painter.setBackground( QG.QBrush( new_options.GetColour( CC.COLOUR_MEDIA_BACKGROUND ) ) )
        
        painter.eraseRect( painter.viewport() )
        
        self._first_background_drawn = True
github hydrusnetwork / hydrus / hydrus / client / gui / ClientGUITime.py View on Github external
# this would be more useful to the user, to know 'right, on ok, it'll refresh in 30 mins'
        # this is actually more complicated--it also needs last check time to calc a fresh file velocity based on new death_file_velocity
        
        #
        
        min_unit_value = 0
        max_unit_value = 1000
        min_time_delta = 60
        
        self._death_file_velocity = VelocityCtrl( self, min_unit_value, max_unit_value, min_time_delta, days = True, hours = True, minutes = True, per_phrase = 'in', unit = 'files' )
        
        self._flat_check_period_checkbox = QW.QCheckBox( self )
        
        #
        
        if HG.client_controller.new_options.GetBoolean( 'advanced_mode' ):
            
            never_faster_than_min = 1
            never_slower_than_min = 1
            
            flat_check_period_min = 1
            
        else:
            
            never_faster_than_min = 30
            never_slower_than_min = 600
            
            flat_check_period_min = 180
            
        
        self._reactive_check_panel = ClientGUICommon.StaticBox( self, 'reactive checking' )
github hydrusnetwork / hydrus / hydrus / client / gui / ClientGUIACDropdown.py View on Github external
):
    
    file_service_key = file_search_context.GetFileServiceKey()
    tag_search_context = file_search_context.GetTagSearchContext()
    
    tag_service_key = tag_search_context.service_key
    
    if not parsed_autocomplete_text.IsAcceptableForTagSearches():
        
        if parsed_autocomplete_text.IsEmpty():
            
            cache_valid = isinstance( results_cache, ClientSearch.PredicateResultsCacheSystem )
            
            we_need_results = not cache_valid
            
            db_not_going_to_hang_if_we_hit_it = not HG.client_controller.DBCurrentlyDoingJob()
            
            if we_need_results or db_not_going_to_hang_if_we_hit_it:
                
                if file_service_key == CC.COMBINED_FILE_SERVICE_KEY:
                    
                    search_service_key = tag_service_key
                    
                else:
                    
                    search_service_key = file_service_key
                    
                
                predicates = HG.client_controller.Read( 'file_system_predicates', search_service_key, force_system_everything = force_system_everything )
                
                results_cache = ClientSearch.PredicateResultsCacheSystem( predicates )
github hydrusnetwork / hydrus / hydrus / core / HydrusPubSub.py View on Github external
try:
                    
                    # do all this _outside_ the lock, lol
                    
                    callable_tuples = self._GetCallableTuples( topic )
                    
                    # don't want to report the showtext we just send here!
                    not_a_report = topic != 'message'
                    
                    if HG.pubsub_report_mode and not_a_report:
                        
                        HydrusData.ShowText( ( topic, args, kwargs, callable_tuples ) )
                        
                    
                    if HG.pubsub_profile_mode and not_a_report:
                        
                        summary = 'Profiling ' + HydrusData.ToHumanInt( len( callable_tuples ) ) + ' x ' + topic
                        
                        HydrusData.ShowText( summary )
                        
                        per_summary = 'Profiling ' + topic
                        
                        for ( obj, callable ) in callable_tuples:
                            
                            try:
                                
                                HydrusData.Profile( per_summary, 'callable( *args, **kwargs )', globals(), locals() )
                                
                            except HydrusExceptions.ShutdownException:
                                
                                return False
github hydrusnetwork / hydrus / hydrus / core / HydrusDB.py View on Github external
def _InitDBCursor( self ):
        
        self._CloseDBCursor()
        
        db_path = os.path.join( self._db_dir, self._db_filenames[ 'main' ] )
        
        db_just_created = not os.path.exists( db_path )
        
        self._db = sqlite3.connect( db_path, isolation_level = None, detect_types = sqlite3.PARSE_DECLTYPES )
        
        self._connection_timestamp = HydrusData.GetNow()
        
        self._c = self._db.cursor()
        
        if HG.no_db_temp_files:
            
            self._c.execute( 'PRAGMA temp_store = 2;' ) # use memory for temp store exclusively
            
        
        self._c.execute( 'ATTACH ":memory:" AS mem;' )
        
        self._AttachExternalDatabases()
        
        # if this is set to 1, transactions are not immediately synced to the journal so multiple can be undone following a power-loss
        # if set to 2, all transactions are synced, so once a new one starts you know the last one is on disk
        # corruption cannot occur either way, but since we have multiple ATTACH dbs with diff journals, let's not mess around when power-cut during heavy file import or w/e
        synchronous = 2
        
        if HG.db_synchronous_override is not None:
            
            synchronous = HG.db_synchronous_override
github hydrusnetwork / hydrus / hydrus / core / HydrusNetwork.py View on Github external
try:
                
                while update_due:
                    
                    with self._lock:
                        
                        service_key = self._service_key
                        
                        begin = self._metadata.GetNextUpdateBegin()
                        
                    
                    end = begin + HC.UPDATE_DURATION
                    
                    update_hashes = HG.server_controller.WriteSynchronous( 'create_update', service_key, begin, end )
                    
                    next_update_due = end + HC.UPDATE_DURATION + 1
                    
                    with self._lock:
                        
                        self._metadata.AppendUpdate( update_hashes, begin, end, next_update_due )
                        
                        update_due = self._metadata.UpdateDue()
                        
                    
                
            finally:
                
                HG.server_busy.release()
github hydrusnetwork / hydrus / hydrus / client / gui / ClientGUIDialogs.py View on Github external
account_type = self._account_types.GetValue()
        
        account_type_key = account_type.GetAccountTypeKey()
        
        lifetime = self._lifetime.GetValue()
        
        if lifetime is None:
            
            expires = None
            
        else:
            
            expires = HydrusData.GetNow() + lifetime
            
        
        service = HG.client_controller.services_manager.GetService( self._service_key )
        
        try:
            
            request_args = { 'num' : num, 'account_type_key' : account_type_key }
            
            if expires is not None:
                
                request_args[ 'expires' ] = expires
                
            
            response = service.Request( HC.GET, 'registration_keys', request_args )
            
            registration_keys = response[ 'registration_keys' ]
            
            ClientGUIFrames.ShowKeys( 'registration', registration_keys )
github hydrusnetwork / hydrus / hydrus / client / ClientFiles.py View on Github external
def GetAllFilePaths( raw_paths, do_human_sort = True ):
    
    file_paths = []
    
    paths_to_process = list( raw_paths )
    
    while len( paths_to_process ) > 0:
        
        next_paths_to_process = []
        
        for path in paths_to_process:
            
            if HG.view_shutdown:
                
                raise HydrusExceptions.ShutdownException()
                
            
            if os.path.isdir( path ):
                
                subpaths = [ os.path.join( path, filename ) for filename in os.listdir( path ) ]
                
                next_paths_to_process.extend( subpaths )
                
            else:
                
                file_paths.append( path )