Python urllib.splithost() Examples

The following are code examples for showing how to use urllib.splithost(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: vscode-mayapy   Author: FXTD-ODYSSEY   File: _pydev_xmlrpclib.py    MIT License 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError("unsupported XML-RPC protocol")
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 2
Project: IronHydra   Author: microdee   File: xmlrpclib.py    MIT License 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 3
Project: griffith   Author: Strit   File: PluginMovieMovieMeter.py    GNU General Public License v2.0 6 votes vote down vote up
def make_connection(self, host):
        self.realhost = host
        proxies = urllib.getproxies()
        proxyurl = None
        if 'http' in proxies:
            proxyurl = proxies['http']
        elif 'all' in proxies:
            proxyurl = proxies['all']
        if proxyurl:
            urltype, proxyhost = urllib.splittype(proxyurl)
            host, selector = urllib.splithost(proxyhost)
            h = httplib.HTTP(host)
            self.proxy_is_used = True
            return h
        else:
            self.proxy_is_used = False
            return Transport.make_connection(self, host) 
Example 4
Project: eve-metrics   Author: ccpgames   File: simplejsonrpc.py    MIT License 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0):
        self.location = uri             # server location (url)
        self.trace = verbose            # show debug messages
        self.exceptions = True          # raise errors? (JSONRPCError)
        self.timeout = None
        self.json_request = self.json_response = ''

        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError("unsupported JSON-RPC protocol")
        self.__host, self.__handler = urllib.splithost(uri)

        if transport is None:
            if type == "https":
                transport = JSONSafeTransport()
            else:
                transport = JSONTransport()
        self.__transport = transport
        self.__encoding = encoding
        self.__verbose = verbose 
Example 5
Project: spc   Author: whbrewer   File: simplejsonrpc.py    MIT License 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,version=None):
        self.location = uri             # server location (url)
        self.trace = verbose            # show debug messages
        self.exceptions = True          # raise errors? (JSONRPCError)
        self.timeout = None
        self.json_request = self.json_response = ''
        self.version = version          # '2.0' for jsonrpc2

        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError("unsupported JSON-RPC protocol")
        self.__host, self.__handler = urllib.splithost(uri)

        if transport is None:
            if type == "https":
                transport = JSONSafeTransport()
            else:
                transport = JSONTransport()
        self.__transport = transport
        self.__encoding = encoding
        self.__verbose = verbose 
Example 6
Project: kinect-2-libras   Author: inessadl   File: xmlrpclib.py    Apache License 2.0 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 7
Project: AsemanOs   Author: AsemanOS   File: _pydev_xmlrpclib.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError("unsupported XML-RPC protocol")
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 8
Project: harpoon   Author: evilhero   File: scgi.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=False,
                 allow_none=False, use_datetime=False):
        type, uri = urllib.splittype(uri)
        if type not in ('scgi'):
            raise IOError('unsupported XML-RPC protocol')
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = '/'

        if transport is None:
            transport = SCGITransport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 9
Project: harpoon   Author: evilhero   File: scgi.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=False,
                 allow_none=False, use_datetime=False):
        type, uri = urllib.splittype(uri)
        if type not in ('scgi'):
            raise IOError('unsupported XML-RPC protocol')
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = '/'

        if transport is None:
            transport = SCGITransport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 10
Project: harpoon   Author: evilhero   File: scgi.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=False,
                 allow_none=False, use_datetime=False):
        type, uri = urllib.splittype(uri)
        if type not in ('scgi'):
            raise IOError('unsupported XML-RPC protocol')
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = '/'

        if transport is None:
            transport = SCGITransport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 11
Project: Hot   Author: dsolimando   File: xmlrpclib.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 12
Project: jobmaster   Author: sassoftware   File: proxy.py    Apache License 2.0 6 votes vote down vote up
def _connect(self, upstream):
        # Figure out who we're proxying to.
        peer = self.socket.getpeername()[0]
        url = self.server.findTarget(peer)
        if not url:
            return self.send_text('403 Forbidden', 'Peer not recognized\r\n')

        # Split the URL to get the hostname.
        scheme, url = urllib.splittype(url)
        if scheme != 'http':
            return self.send_text('504 Gateway Timeout',
                    'Invalid target URL\r\n')
        host, port = _split_hostport(urllib.splithost(url)[0])

        # Resolve the hostname to an address.
        try:
            addresses = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)
        except socket.gaierror, err:
            log.error("Error resolving target URL: %s", err)
            addresses = [] 
Example 13
Project: scrimmage-scoreboard   Author: ShySec   File: simplejsonrpc.py    GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,version=None):
        self.location = uri             # server location (url)
        self.trace = verbose            # show debug messages
        self.exceptions = True          # raise errors? (JSONRPCError)
        self.timeout = None
        self.json_request = self.json_response = ''
        self.version = version          # '2.0' for jsonrpc2

        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError("unsupported JSON-RPC protocol")
        self.__host, self.__handler = urllib.splithost(uri)

        if transport is None:
            if type == "https":
                transport = JSONSafeTransport()
            else:
                transport = JSONTransport()
        self.__transport = transport
        self.__encoding = encoding
        self.__verbose = verbose 
Example 14
Project: libtorrent   Author: galaxy001   File: brpclib.py    MIT License 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported B-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = xmlrpclib.SafeTransport()
            else:
                transport = xmlrpclib.Transport()
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 15
Project: libtorrent   Author: galaxy001   File: ebrpclib.py    MIT License 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported EB-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = xmlrpclib.SafeTransport()
            else:
                transport = xmlrpclib.Transport()
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 16
Project: dotfiles   Author: xbaysal11   File: _pydev_xmlrpclib.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError("unsupported XML-RPC protocol")
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 17
Project: senior-design   Author: james-tate   File: xmlrpclib.py    GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 18
Project: pyblish-win   Author: pyblish   File: websucker.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def savefilename(self, url):
        type, rest = urllib.splittype(url)
        host, path = urllib.splithost(rest)
        path = path.lstrip("/")
        user, host = urllib.splituser(host)
        host, port = urllib.splitnport(host)
        host = host.lower()
        if not path or path[-1] == "/":
            path = path + "index.html"
        if os.sep != "/":
            path = os.sep.join(path.split("/"))
        path = os.path.join(host, path)
        return path 
Example 19
Project: pyblish-win   Author: pyblish   File: xmlrpclib.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0, context=None):
        # establish a "logical" server connection

        if isinstance(uri, unicode):
            uri = uri.encode('ISO-8859-1')

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime, context=context)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 20
Project: Splunk_CBER_App   Author: MHaggis   File: binding.py    MIT License 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 21
Project: misp42splunk   Author: remg427   File: binding.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 22
Project: grand_central   Author: amiracle   File: binding.py    MIT License 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 23
Project: SplunkForPCAP   Author: DanielSchwartz1   File: binding.py    MIT License 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 24
Project: python-netsurv   Author: sofia-netsurv   File: unittest_checker_python3.py    MIT License 5 votes vote down vote up
def test_bad_urllib_attribute(self):
        nodes = astroid.extract_node(
            """
        import urllib
        urllib.addbase #@
        urllib.splithost #@
        urllib.urlretrieve #@
        urllib.urlopen #@
        urllib.urlencode #@
        """
        )
        for node in nodes:
            message = testutils.Message("deprecated-urllib-function", node=node)
            with self.assertAddsMessages(message):
                self.checker.visit_attribute(node) 
Example 25
Project: python-netsurv   Author: sofia-netsurv   File: unittest_checker_python3.py    MIT License 5 votes vote down vote up
def test_bad_urllib_attribute(self):
        nodes = astroid.extract_node(
            """
        import urllib
        urllib.addbase #@
        urllib.splithost #@
        urllib.urlretrieve #@
        urllib.urlopen #@
        urllib.urlencode #@
        """
        )
        for node in nodes:
            message = testutils.Message("deprecated-urllib-function", node=node)
            with self.assertAddsMessages(message):
                self.checker.visit_attribute(node) 
Example 26
Project: ironpython2   Author: IronLanguages   File: test_urllib.py    Apache License 2.0 5 votes vote down vote up
def test_splithost(self):
        splithost = urllib.splithost
        self.assertEqual(splithost('//www.example.org:80/foo/bar/baz.html'),
                         ('www.example.org:80', '/foo/bar/baz.html'))
        self.assertEqual(splithost('//www.example.org:80'),
                         ('www.example.org:80', ''))
        self.assertEqual(splithost('/foo/bar/baz.html'),
                         (None, '/foo/bar/baz.html'))

        # bpo-30500: # starts a fragment.
        self.assertEqual(splithost('//127.0.0.1#@host.com'),
                         ('127.0.0.1', '/#@host.com'))
        self.assertEqual(splithost('//127.0.0.1#@host.com:80'),
                         ('127.0.0.1', '/#@host.com:80'))
        self.assertEqual(splithost('//127.0.0.1:80#@host.com'),
                         ('127.0.0.1:80', '/#@host.com'))

        # Empty host is returned as empty string.
        self.assertEqual(splithost("///file"),
                         ('', '/file'))

        # Trailing semicolon, question mark and hash symbol are kept.
        self.assertEqual(splithost("//example.net/file;"),
                         ('example.net', '/file;'))
        self.assertEqual(splithost("//example.net/file?"),
                         ('example.net', '/file?'))
        self.assertEqual(splithost("//example.net/file#"),
                         ('example.net', '/file#')) 
Example 27
Project: ironpython2   Author: IronLanguages   File: xmlrpclib.py    Apache License 2.0 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0, context=None):
        # establish a "logical" server connection

        if unicode and isinstance(uri, unicode):
            uri = uri.encode('ISO-8859-1')

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime, context=context)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 28
Project: TA-Send_to_HEC   Author: georgestarcher   File: binding.py    MIT License 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 29
Project: SA-dmarc   Author: aholzel   File: binding.py    GNU General Public License v3.0 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 30
Project: git_for_splunk   Author: ChrisYounger   File: binding.py    Apache License 2.0 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 31
Project: git_for_splunk   Author: ChrisYounger   File: binding.py    Apache License 2.0 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 32
Project: TA-esreplacefields   Author: georgestarcher   File: binding.py    MIT License 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 33
Project: xuemc   Author: skycucumber   File: Client.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, url, config = Config):
        proto, uri = urllib.splittype(url)

        # apply some defaults
        if uri[0:2] != '//':
            if proto != None:
                uri = proto + ':' + uri

            uri = '//' + uri
            proto = 'http'

        host, path = urllib.splithost(uri)

        try:
            int(host)
            host = 'localhost:' + host
        except:
            pass

        if not path:
            path = '/'

        if proto not in ('http', 'https', 'httpg'):
            raise IOError, "unsupported SOAP protocol"
        if proto == 'httpg' and not config.GSIclient:
            raise AttributeError, \
                  "GSI client not supported by this Python installation"
        if proto == 'https' and not config.SSLclient:
            raise AttributeError, \
                "SSL client not supported by this Python installation"

        self.user,host = urllib.splituser(host)
        self.proto = proto
        self.host = host
        self.path = path 
Example 34
Project: oss-ftp   Author: aliyun   File: websucker.py    MIT License 5 votes vote down vote up
def savefilename(self, url):
        type, rest = urllib.splittype(url)
        host, path = urllib.splithost(rest)
        path = path.lstrip("/")
        user, host = urllib.splituser(host)
        host, port = urllib.splitnport(host)
        host = host.lower()
        if not path or path[-1] == "/":
            path = path + "index.html"
        if os.sep != "/":
            path = os.sep.join(path.split("/"))
        path = os.path.join(host, path)
        return path 
Example 35
Project: oss-ftp   Author: aliyun   File: xmlrpclib.py    MIT License 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0, context=None):
        # establish a "logical" server connection

        if isinstance(uri, unicode):
            uri = uri.encode('ISO-8859-1')

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime, context=context)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 36
Project: dkodi   Author: dknlght   File: jsonrpc.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, 
                 verbose=0, version=None):
        import urllib
        if not version:
            version = config.version
        self.__version = version
        schema, uri = urllib.splittype(uri)
        if schema not in ('http', 'https', 'unix'):
            raise IOError('Unsupported JSON-RPC protocol.')
        if schema == 'unix':
            if not USE_UNIX_SOCKETS:
                # Don't like the "generic" Exception...
                raise UnixSocketMissing("Unix sockets not available.")
            self.__host = uri
            self.__handler = '/'
        else:
            self.__host, self.__handler = urllib.splithost(uri)
            if not self.__handler:
                # Not sure if this is in the JSON spec?
                #self.__handler = '/'
                self.__handler == '/'
        if transport is None:
            if schema == 'unix':
                transport = UnixTransport()
            elif schema == 'https':
                transport = SafeTransport()
            else:
                transport = Transport()
        self.__transport = transport
        self.__encoding = encoding
        self.__verbose = verbose 
Example 37
Project: conf   Author: XonqNopp   File: unittest_checker_python3.py    GNU General Public License v3.0 5 votes vote down vote up
def test_bad_urllib_attribute(self):
        nodes = astroid.extract_node('''
        import urllib
        urllib.addbase #@
        urllib.splithost #@
        urllib.urlretrieve #@
        urllib.urlopen #@
        urllib.urlencode #@
        ''')
        for node in nodes:
            message = testutils.Message('deprecated-urllib-function', node=node)
            with self.assertAddsMessages(message):
                self.checker.visit_attribute(node) 
Example 38
Project: conf   Author: XonqNopp   File: unittest_checker_python3.py    GNU General Public License v3.0 5 votes vote down vote up
def test_bad_urllib_attribute(self):
        nodes = astroid.extract_node('''
        import urllib
        urllib.addbase #@
        urllib.splithost #@
        urllib.urlretrieve #@
        urllib.urlopen #@
        urllib.urlencode #@
        ''')
        for node in nodes:
            message = testutils.Message('deprecated-urllib-function', node=node)
            with self.assertAddsMessages(message):
                self.checker.visit_attribute(node) 
Example 39
Project: SA-ctf_scoreboard_admin   Author: splunk   File: binding.py    Creative Commons Zero v1.0 Universal 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 40
Project: ptliar2   Author: pantouyu   File: bt.py    GNU General Public License v2.0 5 votes vote down vote up
def split_url(url):
    """
    split url to tuple (scheme, domain, path)
    ex. http://ptliar.com/hi?123 => ("http", "ptliar.com", "hi?123")
    """
    scheme, rest = splittype(url)
    domain, path = splithost(rest)
    return scheme, domain, path 
Example 41
Project: pmatic   Author: LarsMichelsen   File: xmlrpclib.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0):
        # establish a "logical" server connection

        if isinstance(uri, unicode):
            uri = uri.encode('ISO-8859-1')

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 42
Project: godot-zeronet-plugin   Author: zam-org   File: xmlrpclib.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0, context=None):
        # establish a "logical" server connection

        if isinstance(uri, unicode):
            uri = uri.encode('ISO-8859-1')

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime, context=context)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 43
Project: godot-zeronet-plugin   Author: zam-org   File: xmlrpclib.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0, context=None):
        # establish a "logical" server connection

        if isinstance(uri, unicode):
            uri = uri.encode('ISO-8859-1')

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime, context=context)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 44
Project: godot-zeronet-plugin   Author: zam-org   File: xmlrpclib.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0, context=None):
        # establish a "logical" server connection

        if isinstance(uri, unicode):
            uri = uri.encode('ISO-8859-1')

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime, context=context)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 45
Project: godot-zeronet-plugin   Author: zam-org   File: xmlrpclib.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0, context=None):
        # establish a "logical" server connection

        if unicode and isinstance(uri, unicode):
            uri = uri.encode('ISO-8859-1')

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime, context=context)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 46
Project: godot-zeronet-plugin   Author: zam-org   File: xmlrpclib.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0, context=None):
        # establish a "logical" server connection

        if isinstance(uri, unicode):
            uri = uri.encode('ISO-8859-1')

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime, context=context)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
Example 47
Project: DCRUM-Splunk-Application   Author: Dynatrace   File: binding.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 48
Project: TA-statemachine   Author: doksu   File: binding.py    Apache License 2.0 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 49
Project: TA-asngen   Author: doksu   File: binding.py    MIT License 5 votes vote down vote up
def _spliturl(url):
    scheme, opaque = urllib.splittype(url)
    netloc, path = urllib.splithost(opaque)
    host, port = urllib.splitport(netloc)
    # Strip brackets if its an IPv6 address
    if host.startswith('[') and host.endswith(']'): host = host[1:-1]
    if port is None: port = DEFAULT_PORT
    return scheme, host, port, path

# Given an HTTP request handler, this wrapper objects provides a related
# family of convenience methods built using that handler. 
Example 50
Project: KalutClient   Author: TwoUnderscorez   File: xmlrpclib.py    Apache License 2.0 5 votes vote down vote up
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0, use_datetime=0, context=None):
        # establish a "logical" server connection

        if unicode and isinstance(uri, unicode):
            uri = uri.encode('ISO-8859-1')

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported XML-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = SafeTransport(use_datetime=use_datetime, context=context)
            else:
                transport = Transport(use_datetime=use_datetime)
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none