本文整理汇总了Python中urllib.ftpwrapper函数的典型用法代码示例。如果您正苦于以下问题:Python ftpwrapper函数的具体用法?Python ftpwrapper怎么用?Python ftpwrapper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftpwrapper函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: connect_ftp
def connect_ftp(self, user, passwd, host, port, dirs, timeout):
try:
fw = ftpwrapper(user, passwd, host, port, dirs, timeout)
except TypeError:
# Python < 2.6, no per-connection timeout support
fw = ftpwrapper(user, passwd, host, port, dirs)
## fw.ftp.set_debuglevel(1)
return fw
开发者ID:ufal,项目名称:lindat-aai-shibbie,代码行数:8,代码来源:_urllib2_fork.py
示例2: connect_ftp
def connect_ftp(self, user, passwd, host, port, dirs):
key = user, host, port, '/'.join(dirs)
if key in self.cache:
self.timeout[key] = time.time() + self.delay
else:
self.cache[key] = ftpwrapper(user, passwd, host, port, dirs)
self.timeout[key] = time.time() + self.delay
self.check_cache()
return self.cache[key]
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:9,代码来源:urllib2.py
示例3: connect_ftp
def connect_ftp(self, user, passwd, host, port, dirs):
key = user, passwd, host, port
if self.cache.has_key(key):
self.timeout[key] = time.time() + self.delay
else:
self.cache[key] = ftpwrapper(user, passwd, host, port, dirs)
self.timeout[key] = time.time() + self.delay
self.check_cache()
return self.cache[key]
开发者ID:paulgay,项目名称:crf_dia_ident,代码行数:9,代码来源:urllib2.py
示例4: open_ftp
def open_ftp(self, url):
host, path = urllib.splithost(url)
if not host: raise IOError, ('ftp error', 'no host given')
host, port = urllib.splitport(host)
user, host = urllib.splituser(host)
# if user: user, passwd = splitpasswd(user)
if user: passwd = getpass.getpass()
else: passwd = None
host = urllib.unquote(host)
user = urllib.unquote(user or '')
passwd = urllib.unquote(passwd or '')
host = socket.gethostbyname(host)
if not port:
import ftplib
port = ftplib.FTP_PORT
else:
port = int(port)
path, attrs = urllib.splitattr(path)
path = urllib.unquote(path)
dirs = string.splitfields(path, '/')
dirs, file = dirs[:-1], dirs[-1]
if dirs and not dirs[0]: dirs = dirs[1:]
key = (user, host, port, string.joinfields(dirs, '/'))
# XXX thread unsafe!
if len(self.ftpcache) > MAXFTPCACHE:
# Prune the cache, rather arbitrarily
for k in self.ftpcache.keys():
if k != key:
v = self.ftpcache[k]
del self.ftpcache[k]
v.close()
try:
if not self.ftpcache.has_key(key):
print 'Creating ftpwrapper: ',user,host,port,dirs
self.ftpcache[key] = \
urllib.ftpwrapper(user, passwd, host, port, dirs)
if not file: type = 'D'
else: type = 'I'
for attr in attrs:
attr, value = urllib.splitvalue(attr)
if string.lower(attr) == 'type' and \
value in ('a', 'A', 'i', 'I', 'd', 'D'):
type = string.upper(value)
(fp, retrlen) = self.ftpcache[key].retrfile(file, type)
if retrlen is not None and retrlen >= 0:
import mimetools, StringIO
headers = mimetools.Message(StringIO.StringIO(
'Content-Length: %d\n' % retrlen))
else:
headers = noheaders()
return urllib.addinfourl(fp, headers, "ftp:" + url)
except urllib.ftperrors(), msg:
raise IOError, ('ftp error', msg), sys.exc_info()[2]
开发者ID:AZed,项目名称:uvcdat,代码行数:53,代码来源:cdurllib.py
示例5: connect_ftp
def connect_ftp(self, user, passwd, host, port, dirs, timeout):
fw = ftpwrapper(user, passwd, host, port, dirs, timeout, persistent=False)
return fw
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:3,代码来源:urllib2.py
示例6:
"""An extensible library for opening URLs using a variety of protocols
开发者ID:mcyril,项目名称:ravel-ftn,代码行数:1,代码来源:urllib2.py
注:本文中的urllib.ftpwrapper函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论