• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python urllib.splitpasswd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: parse_remote_repository

def parse_remote_repository (uri, ) :
    _pa = urlparse.urlsplit(uri)
    (_a_user, _a_host, ) = urllib.splituser(_pa.netloc, )
    _user, _password = None, None
    if _a_user :
        (_user, _password, ) = urllib.splitpasswd(_a_user, )
    _defaut_port = _pa.scheme.lower() in ("svn+ssh", "ssh", ) and 22 or None
    (_host, _port, ) = urllib.splitnport(_a_host, defport=_defaut_port, )

    return dict(
        host=_host,
        port=_port,
        scheme=_pa.scheme.lower(),
        user=_user,
        password=_password,
        path=os.path.normpath(
            _pa.path.strip().startswith("/") and _pa.path or ("/" + _pa.path)
        ),
    )
开发者ID:spikeekips,项目名称:source-over-ssh,代码行数:19,代码来源:utils.py


示例17: parse_backend

def parse_backend(url):
    def unescape(s):
        return urllib.unquote(s.replace('+', ' '))

    try:
        proto, u = urllib.splittype(url)
        auth, path = urllib.splithost(u)
        user, host = urllib.splituser(auth)
        user, password = urllib.splitpasswd(user)
        host, _ = urllib.splitport(host)
        _, query = urllib.splitquery(path)

        args = query.split('&')
        hot_user = None
        hot_pass = None
        level = 0
        mode = -1
        for arg in args:
            k, v = arg.split('=', 2)
            v = unescape(v)
            if k == 'hot_user':
                hot_user = v
            elif k == 'hot_pass':
                hot_pass = v
            elif k == 'level':
                level = parse_level(v)
            elif k == 'mode':
                mode = parse_mode(v)
            elif k == 'extra':
                hot_addr, extra = parse_extra(v)
        if hot_user != None and hot_addr == None:
            hot_addr = host

        Backend = namedtuple('Backend', ['address', 'user', 'password',
                                         'hot_addr', 'hot_user', 'hot_pass',
                                         'extra', 'level', 'mode'])
        return Backend(address=host, user=user, password=password,
                       hot_addr=hot_addr, hot_user=hot_user, hot_pass=hot_pass,
                       extra=extra, level=level, mode=mode)
    except Exception:
        logging.getLogger('mwtm_executor').error('bad backend: %s', url,
                                                 exc_info=True)
        _exit(1)
开发者ID:dlf412,项目名称:thunderCopyright,代码行数:43,代码来源:task_executor.py


示例18: parse_uri

def parse_uri(uri, **kwargs):
    scheme, rest = urllib.splittype(uri)
    host, rest = urllib.splithost(rest)
    user, host = urllib.splituser(host)
    if user:
        username, password = urllib.splitpasswd(user)
    else:
        username = password = None
    host, port = urllib.splitnport(host)
    path, query = urllib.splitquery(rest)
    if query:
        kwargs.update(dict(cgi.parse_qsl(query)))
    return dict(
        scheme=scheme,
        host=host,
        username=username,
        password=password,
        port=port,
        path=path,
        query=kwargs)
开发者ID:jaivikram,项目名称:Ming_the_merciless,代码行数:20,代码来源:utils.py


示例19: _parse_proxy

def _parse_proxy(proxy):
    scheme, r_scheme = splittype(proxy)
    if not r_scheme.startswith('/'):
        scheme = None
        authority = proxy
    else:
        if not r_scheme.startswith('//'):
            raise ValueError('proxy URL with no authority: %r' % proxy)
        end = r_scheme.find('/', 2)
        if end == -1:
            end = None
        authority = r_scheme[2:end]
    userinfo, hostport = splituser(authority)
    if userinfo is not None:
        user, password = splitpasswd(userinfo)
    else:
        user = password = None
    return (scheme,
     user,
     password,
     hostport)
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:21,代码来源:urllib2.py


示例20: _getBaseServerUrlData

 def _getBaseServerUrlData(self):
     """
     Fetch serverUrl from ~/.rbuilderrc if it exists and is specified;
     removes user and password from the URL and returns them separately.
     @return serverUrl, user, password
     """
     serverUrl = self._getBaseServerUrl()
     if not serverUrl:
         return (None, None, None)
     scheme, rest = serverUrl.split(":", 1)
     host = urllib.splithost(rest)[0]
     user = urllib.splituser(host)[0]
     if user:
         user, password = urllib.splitpasswd(user)
     else:
         password = None
     if password:
         serverUrl = serverUrl.replace(":%s" % password, "", 1)
     if user:
         serverUrl = serverUrl.replace("%[email protected]" % user, "", 1)
     return serverUrl, user, password
开发者ID:pombredanne,项目名称:rbuild,代码行数:21,代码来源:rbuilderfacade.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python urllib.splitport函数代码示例发布时间:2022-05-27
下一篇:
Python urllib.splitnport函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap