How to use the hydrus.core.HydrusExceptions 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 / client / networking / ClientNetworkingJobs.py View on Github external
( service_string_gumpf, network_version ) = server_header.split( '/' )
        
        network_version = int( network_version )
        
        if network_version != HC.NETWORK_VERSION:
            
            if network_version > HC.NETWORK_VERSION:
                
                message = 'Your client is out of date; please download the latest release.'
                
            else:
                
                message = 'The server is out of date; please ask its admin to update to the latest release.'
                
            
            raise HydrusExceptions.NetworkVersionException( 'Network version mismatch! The server\'s network version was ' + str( network_version ) + ', whereas your client\'s is ' + str( HC.NETWORK_VERSION ) + '! ' + message )
github hydrusnetwork / hydrus / hydrus / client / media / ClientMedia.py View on Github external
def index( self, item ):
        
        if self._indices_dirty:
            
            self._RecalcIndices()
            
        
        try:
            
            result = self._items_to_indices[ item ]
            
        except KeyError:
            
            raise HydrusExceptions.DataMissing()
            
        
        return result
github hydrusnetwork / hydrus / hydrus / client / importing / ClientImportOptions.py View on Github external
for tag in tags:
            
            sibling_tags.update( HG.client_controller.tag_siblings_manager.GetAllSiblings( CC.COMBINED_TAG_SERVICE_KEY, tag ) )
            
        
        for test_tags in ( tags, sibling_tags ):
            
            ok_tags = self._tag_blacklist.Filter( test_tags, apply_unnamespaced_rules_to_namespaced_tags = True )
            
            if len( ok_tags ) < len( test_tags ):
                
                bad_tags = test_tags.difference( ok_tags )
                
                bad_tags = HydrusTags.SortNumericTags( bad_tags )
                
                raise HydrusExceptions.VetoException( ', '.join( bad_tags ) + ' is blacklisted!' )
                
            
        
        if len( self._tag_whitelist ) > 0:
            
            all_tags = tags.union( sibling_tags )
            
            intersecting_tags = all_tags.intersection( self._tag_whitelist )
            
            if len( intersecting_tags ) == 0:
                
                raise HydrusExceptions.VetoException( 'did not pass the whitelist!' )
github hydrusnetwork / hydrus / hydrus / client / gui / ClientGUIPages.py View on Github external
def _GetIndex( self, page_key ):
        
        for ( page, index ) in ( ( self.widget( index ), index ) for index in range( self.count() ) ):
            
            if page.GetPageKey() == page_key:
                
                return index
                
            
        
        raise HydrusExceptions.DataMissing()
github hydrusnetwork / hydrus / hydrus / client / importing / ClientImportFileSeeds.py View on Github external
self.Import( temp_path, file_import_options, status_hook = status_hook )
                
            finally:
                
                HydrusPaths.CleanUpTempPath( os_file_handle, temp_path )
                
            
            self.WriteContentUpdates()
            
        except HydrusExceptions.UnsupportedFileException as e:
            
            self.SetStatus( CC.STATUS_ERROR, exception = e )
            
        except HydrusExceptions.VetoException as e:
            
            self.SetStatus( CC.STATUS_VETOED, note = str( e ) )
            
        except Exception as e:
            
            self.SetStatus( CC.STATUS_ERROR, exception = e )
            
        
        file_seed_cache.NotifyFileSeedsUpdated( ( self, ) )
github hydrusnetwork / hydrus / hydrus / client / importing / ClientImportSubscriptionLegacy.py View on Github external
if file_seed.ShouldPresent( self._file_import_options ):
                            
                            hash = file_seed.GetHash()
                            
                            if hash not in presentation_hashes_fast:
                                
                                presentation_hashes.append( hash )
                                
                                presentation_hashes_fast.add( hash )
                                
                            
                        
                    except HydrusExceptions.CancelledException as e:
                        
                        self._DelayWork( 300, str( e ) )
                        
                        break
                        
                    except HydrusExceptions.VetoException as e:
                        
                        status = CC.STATUS_VETOED
                        
                        note = str( e )
                        
                        file_seed.SetStatus( status, note = note )
                        
                    except HydrusExceptions.NotFoundException:
                        
                        status = CC.STATUS_VETOED
github hydrusnetwork / hydrus / hydrus / client / ClientParsing.py View on Github external
else:
                    
                    raise
                    
                
            
            linked_text = network_job.GetContentText()
            
            children_content = GetChildrenContent( job_key, self._children, linked_text, search_url )
            
            content.extend( children_content )
            
            if job_key.IsCancelled():
                
                raise HydrusExceptions.CancelledException( 'Job was cancelled.' )
                
            
        
        return content
github hydrusnetwork / hydrus / hydrus / client / gui / ClientGUIStringPanels.py View on Github external
def _Add( self ):
        
        choice_tuples = [
            ( 'String Match', ClientParsing.StringMatch, 'An object that filters strings.' ),
            ( 'String Converter', ClientParsing.StringConverter, 'An object that converts strings from one thing to another.' ),
            ( 'String Splitter', ClientParsing.StringSplitter, 'An object that breaks strings into smaller strings.' )
        ]
        
        try:
            
            string_processing_step_type = ClientGUIDialogsQuick.SelectFromListButtons( self, 'Which type of processing step?', choice_tuples )
            
        except HydrusExceptions.CancelledException:
            
            raise HydrusExceptions.VetoException()
            
        
        if string_processing_step_type == ClientParsing.StringMatch:
            
            string_processing_step = ClientParsing.StringMatch( example_string = self._example_string.text() )
            
            example_text = self._GetExampleTextForStringProcessingStep( string_processing_step )
            
            string_processing_step = ClientParsing.StringMatch( example_string = example_text )
            
        else:
            
            string_processing_step = string_processing_step_type()
github hydrusnetwork / hydrus / hydrus / client / networking / ClientNetworkingDomain.py View on Github external
if self._send_referral_url == SEND_REFERRAL_URL_ONLY_IF_PROVIDED:
            
            return referral_url
            
        elif self._send_referral_url == SEND_REFERRAL_URL_NEVER:
            
            return None
            
        elif self._send_referral_url in ( SEND_REFERRAL_URL_CONVERTER_IF_NONE_PROVIDED, SEND_REFERRAL_URL_ONLY_CONVERTER ):
            
            try:
                
                converted_referral_url = self._referral_url_converter.Convert( url )
                
            except HydrusExceptions.StringConvertException:
                
                return referral_url
                
            
            p1 = self._send_referral_url == SEND_REFERRAL_URL_ONLY_CONVERTER
            p2 = self._send_referral_url == SEND_REFERRAL_URL_CONVERTER_IF_NONE_PROVIDED and referral_url is None
            
            if p1 or p2:
                
                return converted_referral_url
                
            else:
                
                return referral_url
github hydrusnetwork / hydrus / hydrus / client / networking / ClientNetworkingLogin.py View on Github external
last_url_used = login_step.Start( engine, login_domain, given_credentials, temp_variables, referral_url = last_url_used, network_job_presentation_context_factory = network_job_presentation_context_factory, test_result_callable = test_result_callable )
                
            except HydrusExceptions.ValidationException as e:
                
                if test_result_callable is not None:
                    
                    HydrusData.ShowException( e )
                    
                
                message = str( e )
                
                engine.login_manager.InvalidateLoginScript( login_domain, self._login_script_key, message )
                
                return 'Verification error: ' + message
                
            except HydrusExceptions.NetworkException as e:
                
                if test_result_callable is not None:
                    
                    HydrusData.ShowException( e )
                    
                
                message = str( e )
                
                engine.login_manager.DelayLoginScript( login_domain, self._login_script_key, message )
                
                return 'Network error: ' + message
                
            except Exception as e:
                
                if test_result_callable is not None: