How to use the fcp.node.FCPNameLookupFailure function in fcp

To help you get started, we’ve selected a few fcp 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 freenet / pyFreenet / fcp / node.py View on Github external
#    if uri.startswith("freenet:CHK@") or uri.startswith("CHK@"):
    #        uri = os.path.splitext(uri)[0]
    
        # process uri, including possible namesite lookups
        uri = uri.split("freenet:")[-1]
        if len(uri) < 5 or (uri[:4] not in ('SSK@', 'KSK@', 'CHK@', 'USK@', 'SVK@')):
            # we seem to have a 'domain name' uri
            try:
                domain, rest = uri.split("/", 1)
            except:
                domain = uri
                rest = ''
            
            tgtUri = self.namesiteLookup(domain)
            if not tgtUri:
                raise FCPNameLookupFailure(
                        "Failed to resolve freenet domain '%s'" % domain)
            if rest:
                uri = (tgtUri + "/" + rest).replace("//", "/")
            else:
                uri = tgtUri
            
        opts['URI'] = uri
    
        opts['MaxRetries'] = kw.get("maxretries", -1)
        opts['MaxSize'] = kw.get("maxsize", "1000000000000")
        opts['PriorityClass'] = int(kw.get("priority", 1))
    
        opts['timeout'] = int(kw.pop("timeout", ONE_YEAR))
    
        #print "get: opts=%s" % opts
github freenet / pyFreenet / fcp / node.py View on Github external
if opts['Global'] == 'true' and opts['Persistence'] == 'connection':
            raise Exception("Global requests must be persistent")
    
        # process uri, including possible namesite lookups
        uri = uri.split("freenet:")[-1]
        if len(uri) < 4 or (uri[:4] not in ('SSK@', 'KSK@', 'CHK@', 'USK@', 'SVK@')):
            # we seem to have a 'domain name' uri
            try:
                domain, rest = uri.split("/", 1)
            except:
                domain = uri
                rest = ''
            
            tgtUri = self.namesiteLookup(domain)
            if not tgtUri:
                raise FCPNameLookupFailure(
                        "Failed to resolve freenet domain '%s'" % domain)
            if rest:
                uri = (tgtUri + "/" + rest).replace("//", "/")
            else:
                uri = tgtUri
    
        opts['URI'] = uri
        
        # determine a mimetype
        mimetype = kw.get("mimetype", None)
        if kw.has_key('mimetype'):
            # got an explicit mimetype - use it
            mimetype = kw['mimetype']
        else:
            # not explicitly given - figure one out
            ext = os.path.splitext(uri)[1]