当前位置: 首页>>代码示例>>Python>>正文


Python urllib.splitpasswd函数代码示例

本文整理汇总了Python中urllib.splitpasswd函数的典型用法代码示例。如果您正苦于以下问题:Python splitpasswd函数的具体用法?Python splitpasswd怎么用?Python splitpasswd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了splitpasswd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: chek_pages

def chek_pages(pages):
    try:
        for pages_url in pages:
            urllib.splitpasswd("[email protected]")
            urllib.splituser()
            code = urllib.urlopen(pages_url).getcode()
            print pages_url, code
            if code not in [200, 301]:
                failed_pages.append(pages_url)
    except socket.error, e:
        print "Ping Error", e
开发者ID:Renkar,项目名称:txxx-old-,代码行数:11,代码来源:test_pages.py

示例2: test_splitpasswd

 def test_splitpasswd(self):
     """Some of the password examples are not sensible, but it is added to
     confirming to RFC2617 and addressing issue4675.
     """
     self.assertEqual(('user', 'ab'),urllib.splitpasswd('user:ab'))
     self.assertEqual(('user', 'a\nb'),urllib.splitpasswd('user:a\nb'))
     self.assertEqual(('user', 'a\tb'),urllib.splitpasswd('user:a\tb'))
     self.assertEqual(('user', 'a\rb'),urllib.splitpasswd('user:a\rb'))
     self.assertEqual(('user', 'a\fb'),urllib.splitpasswd('user:a\fb'))
     self.assertEqual(('user', 'a\vb'),urllib.splitpasswd('user:a\vb'))
     self.assertEqual(('user', 'a:b'),urllib.splitpasswd('user:a:b'))
     self.assertEqual(('user', 'a b'),urllib.splitpasswd('user:a b'))
     self.assertEqual(('user 2', 'ab'),urllib.splitpasswd('user 2:ab'))
     self.assertEqual(('user+1', 'a+b'),urllib.splitpasswd('user+1:a+b'))
开发者ID:49476291,项目名称:android-plus-plus,代码行数:14,代码来源:test_urllib.py

示例3: test_splitpasswd

 def test_splitpasswd(self):
     """Some of the password examples are not sensible, but it is added to
     confirming to RFC2617 and addressing issue4675.
     """
     self.assertEqual(("user", "ab"), urllib.splitpasswd("user:ab"))
     self.assertEqual(("user", "a\nb"), urllib.splitpasswd("user:a\nb"))
     self.assertEqual(("user", "a\tb"), urllib.splitpasswd("user:a\tb"))
     self.assertEqual(("user", "a\rb"), urllib.splitpasswd("user:a\rb"))
     self.assertEqual(("user", "a\fb"), urllib.splitpasswd("user:a\fb"))
     self.assertEqual(("user", "a\vb"), urllib.splitpasswd("user:a\vb"))
     self.assertEqual(("user", "a:b"), urllib.splitpasswd("user:a:b"))
     self.assertEqual(("user", "a b"), urllib.splitpasswd("user:a b"))
     self.assertEqual(("user 2", "ab"), urllib.splitpasswd("user 2:ab"))
     self.assertEqual(("user+1", "a+b"), urllib.splitpasswd("user+1:a+b"))
开发者ID:plirof,项目名称:minibloq_v0.83,代码行数:14,代码来源:test_urllib.py

示例4: __init__

    def __init__(self, baseUri, headers=None, maxClients=None,
        maxConnections=None):

        self._headers = headers or HTTPHeaders()

        self._user = None
        self._passwd = None

        baseUri = baseUri.rstrip('/')
        self._scheme, loc, self._path, query, frag = urlparse.urlsplit(baseUri)

        userpass, self._hostport = urllib.splituser(loc)
        if userpass:
            self._user, self._passwd = urllib.splitpasswd(userpass)

        self._baseUri = urlparse.urlunsplit((self._scheme, self._hostport,
            self._path, None, None))

        if self._scheme not in ('http', 'https'):
            raise ValueError(self._scheme)

        self._dispatcher = RequestDispatcher(maxClients=maxClients,
            maxConnections=maxConnections)

        self._queryFragment = urlparse.urlunsplit(('', '', '', query, frag))
开发者ID:pombreda,项目名称:robj,代码行数:25,代码来源:client.py

示例5: parse_address_info

    def parse_address_info(cls, server_addr="nats://nats:[email protected]:4222"):
        '''\
        parse the metadata nats server uri;

        Params:
        =====
        addr: nats server address;

        Returns:
        =====
        user: username to login nats server;
        pswd: password to login nats server;
        host: ip address of nats server;
        port: port of nats server
        '''

        if type(server_addr) is not str:
            raise NotImplementException

        protocol, after_split = urllib.splittype(server_addr)

        if not protocol == "nats":
            raise NotImplementException

        auth_len = len(server_addr.split('@'))
        if auth_len > 1:
            auth, after_split = urllib.splituser(after_split)
            user_raw, pswd = urllib.splitpasswd(auth)
            user = user_raw.lstrip("/")
            _, after_split = urllib.splithost(after_split)
            host, port = urllib.splitport(after_split)
        else:
            user = pswd = None
            host, port = urllib.splitport(after_split)
        return user, pswd, host, int(port)
开发者ID:PyHUBKyiv,项目名称:python-nats,代码行数:35,代码来源:common.py

示例6: signon

	def signon(self, url='localhost:8889', login=None, password=None, startQueue=False, verbose=False):
		"""Sign on to RTS2 JSON server. url - JSON API URL (can include username and login)"""
		# try to get username (and password) from url
		purl = urlparse.urlsplit(url)
		userpass,host = urllib.splituser(purl.netloc)
		(userpass, netloc) = urllib.splituser(purl.netloc)
		if userpass is not None:
			(login, password) = urllib.splitpasswd(userpass)
			url = netloc + purl.path
			if purl.query:
				url += '?' + query
			if purl.fragment:
				url += '#' + fragment

		if login is None:
		  	self.verbose.set_active(verbose)
			self.dialog.show_all()
			if self.run():
				self.dialog.hide()
				sys.exit(-1)
			self.dialog.hide()
		else:
			# or just create server..
			createJsonServer(url, login, password, verbose=verbose)
			getProxy().loadJson('/api/devices')
		if startQueue:
			getProxy().startQueue()
		getProxy().refresh()
开发者ID:RTS2,项目名称:rts2-gtk,代码行数:28,代码来源:login.py

示例7: ftp_open

    def ftp_open(self, req):
        import ftplib
        import mimetypes
        host = req.get_host()
        if not host:
            raise IOError, ('ftp error', 'no host given')
        host, port = splitport(host)
        if port is None:
            port = ftplib.FTP_PORT
        else:
            port = int(port)

        # username/password handling
        user, host = splituser(host)
        if user:
            user, passwd = splitpasswd(user)
        else:
            passwd = None
        host = unquote(host)
        user = unquote(user or '')
        passwd = unquote(passwd or '')

        try:
            host = socket.gethostbyname(host)
        except socket.error, msg:
            raise URLError(msg)
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:26,代码来源:urllib2.py

示例8: __init__

    def __init__(self, url):
        """ Initialize the downloader with the specified url string """
        # FIXME: support HTTPS
        scheme, host, path, params, query, fragment = urlparse.urlparse(url)
        
        auth, host = urllib.splituser(host)
        self.host, self.port = urllib.splitport(host)
        if not self.port:
            self.port = 80

        self.username = self.password = None
        if auth:
            self.username, self.password = urllib.splitpasswd(auth)

        self.url = urlparse.urlunparse((scheme, host, path, params, query, fragment))

        self.nzbFilename = os.path.basename(path)
        self.tempFilename = os.path.join(Hellanzb.TEMP_DIR,
                                         tempFilename(self.TEMP_FILENAME_PREFIX) + '.nzb')
        # The HTTPDownloader
        self.downloader = None
        # The NZB category (e.g. 'Apps')
        self.nzbCategory = None
        # Whether or not the NZB file data is gzipped
        self.isGzipped = False
开发者ID:Bootz,项目名称:hellanzb,代码行数:25,代码来源:NZBDownloader.py

示例9: get_user_password

 def get_user_password (self):
     """Get tuple (user, password) from configured authentication.
     Both user and password can be None.
     """
     if self.userinfo:
         # URL itself has authentication info
         return urllib.splitpasswd(self.userinfo)
     return self.aggregate.config.get_user_password(self.url)
开发者ID:kyleskrinak,项目名称:linkchecker,代码行数:8,代码来源:urlbase.py

示例10: __init__

    def __init__(self, uri, username=None, password=None, *args, **kwargs):
        xmlrpclib.ServerProxy.__init__(self, uri, *args, **kwargs)
        # Hide password
        userpass, hostport = urllib.splituser(self.__host)
        if userpass and not username:
            self.__host = hostport
            username, password = urllib.splitpasswd(userpass)

        if username:
            password = util.ProtectedString(urllib.quote(password))
            self.__host = ProtectedTemplate('${user}:${password}@${host}',
                user=username, password=password, host=self.__host)
开发者ID:fedora-conary,项目名称:rbuild,代码行数:12,代码来源:__init__.py

示例11: ftp_open

    def ftp_open(self, req):
        import ftplib
        import mimetypes
        host = req.get_host()
        if not host:
            raise URLError('ftp error: no host given')
        host, port = splitport(host)
        if port is None:
            port = ftplib.FTP_PORT
        else:
            port = int(port)
        user, host = splituser(host)
        if user:
            user, passwd = splitpasswd(user)
        else:
            passwd = None
        host = unquote(host)
        user = user or ''
        passwd = passwd or ''
        try:
            host = socket.gethostbyname(host)
        except socket.error as msg:
            raise URLError(msg)

        path, attrs = splitattr(req.get_selector())
        dirs = path.split('/')
        dirs = map(unquote, dirs)
        dirs, file = dirs[:-1], dirs[-1]
        if dirs and not dirs[0]:
            dirs = dirs[1:]
        try:
            fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout)
            type = file and 'I' or 'D'
            for attr in attrs:
                attr, value = splitvalue(attr)
                if attr.lower() == 'type' and value in ('a', 'A', 'i', 'I', 'd', 'D'):
                    type = value.upper()

            fp, retrlen = fw.retrfile(file, type)
            headers = ''
            mtype = mimetypes.guess_type(req.get_full_url())[0]
            if mtype:
                headers += 'Content-type: %s\n' % mtype
            if retrlen is not None and retrlen >= 0:
                headers += 'Content-length: %d\n' % retrlen
            sf = StringIO(headers)
            headers = mimetools.Message(sf)
            return addinfourl(fp, headers, req.get_full_url())
        except ftplib.all_errors as msg:
            raise URLError, 'ftp error: %s' % msg, sys.exc_info()[2]

        return
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:52,代码来源:urllib2.py

示例12: _getconnection

def _getconnection(netloc):
    """Return a FTP connection object to the specified server."""
    # NOTE: this method is not thread safe
    if _ftpconnections.has_key(netloc):
        return _ftpconnections[netloc]
    # split url into useful parts
    (userpass, host) = urllib.splituser(netloc)
    if userpass is not None:
        (user, passwd) = urllib.splitpasswd(userpass)
    else:
        (user, passwd) = ('anonymous', '')
    (host, port) = urllib.splitnport(host, ftplib.FTP_PORT)
    # initialize a new connection
    ftp = ftplib.FTP()
    debugio.debug('schemes.ftp._getconnection(): CONNECT: '+ftp.connect(host, port))
    debugio.debug('schemes.ftp._getconnection(): LOGIN: '+ftp.login(user, passwd))
    _ftpconnections[netloc] = ftp
    return ftp
开发者ID:buptjz,项目名称:PythonGod,代码行数:18,代码来源:ftp.py

示例13: urlSplit

def urlSplit(url, defaultPort = None):
    """A function to split a URL in the format
    <scheme>://<user>:<pass>@<host>:<port>/<path>;<params>#<fragment>
    into a tuple
    (<scheme>, <user>, <pass>, <host>, <port>, <path>, <params>, <fragment>)
    Any missing pieces (user/pass) will be set to None.
    If the port is missing, it will be set to defaultPort; otherwise, the port
    should be a numeric value.
    """
    scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
    userpass, hostport = urllib.splituser(netloc)
    host, port = urllib.splitnport(hostport, None)
    if userpass:
        user, passwd = urllib.splitpasswd(userpass)
    else:
        user, passwd = None, None
    return scheme, user, passwd, host, port, path, \
        query or None, fragment or None
开发者ID:pombredanne,项目名称:mint,代码行数:18,代码来源:helperfuncs.py

示例14: check_args

def check_args(options, args):
    if not args:
        return
    # someway to test if it is a SIP URI
    if 'sip:' in args[0]:
        setattr(options, 'target_uri', args[0])

    userpass, hostport = urllib.splituser(args[0])

    if hostport[:4] == 'sip:': hostport = hostport[4:]
    host, port = urllib.splitnport(hostport, 5060)
    # XXX Overwrites!
    setattr(options, 'target_addr', (host, port))

    if userpass:
        user, passwd = urllib.splitpasswd(userpass)
        user and setattr(options, 'user', user)
        passwd and setattr(options, 'passwd', passwd)
开发者ID:EricSB,项目名称:voipy,代码行数:18,代码来源:siping.py

示例15: __init__

    def __init__(self, url):
        type, uri = urllib.splittype(url)
        #if type not in ("http", "https"):
        #    raise IOError, "unsupported XML-RPC protocol"
        self.host, self.url = urllib.splithost(uri)
        if self.url == "":
            self.url = "/"

        self.user = self.password = None
        self.user, self.host = urllib.splituser(self.host)
        try:
            self.user, self.password = urllib.splitpasswd(self.user)
        except TypeError:
            pass
        
        self.host, self.port = urllib.splitport(self.host)
        self.port = int(self.port)
        
        self.secure = type == 'https'
开发者ID:Bootz,项目名称:hellanzb,代码行数:19,代码来源:xmlrpc.py


注:本文中的urllib.splitpasswd函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。