Python ftplib 模块-FTP_PORT 实例源码

Python ftplib 模块,FTP_PORT 实例源码

我们从Python开源项目中,提取了以下42个代码示例,用于说明如何使用ftplib.FTP_PORT

项目:kinect-2-libras    作者:inessadl    | 项目源码 | 文件源码
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)

        # username/password handling
        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, 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, msg:
            raise URLError, ('ftp error: %s' % msg), sys.exc_info()[2]
项目:kinect-2-libras    作者:inessadl    | 项目源码 | 文件源码
def open_ftp(self, url):
        """Use FTP protocol."""
        if not isinstance(url, str):
            raise IOError, ('ftp error', 'proxy support for ftp protocol currently not implemented')
        import mimetypes, mimetools
        try:
            from cStringIO import StringIO
        except ImportError:
            from StringIO import StringIO
        host, path = splithost(url)
        if not host: raise IOError, 'no host given')
        host, port = splitport(host)
        user, host = splituser(host)
        if user: user, passwd = splitpasswd(user)
        else: passwd = None
        host = unquote(host)
        user = user or ''
        passwd = passwd or ''
        host = socket.gethostbyname(host)
        if not port:
            import ftplib
            port = ftplib.FTP_PORT
        else:
            port = int(port)
        path, attrs = splitattr(path)
        path = unquote(path)
        dirs = path.split('/')
        dirs, dirs[-1]
        if dirs and not dirs[0]: dirs = dirs[1:]
        if dirs and not dirs[0]: dirs[0] = '/'
        key = user, '/'.join(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 key in self.ftpcache:
                self.ftpcache[key] = \
                    ftpwrapper(user, dirs)
            if not file: type = 'D'
            else: type = 'I'
            for attr in attrs:
                attr, 'D'):
                    type = value.upper()
            (fp, retrlen) = self.ftpcache[key].retrfile(file, type)
            mtype = mimetypes.guess_type("ftp:" + url)[0]
            headers = ""
            if mtype:
                headers += "Content-Type: %s\n" % mtype
            if retrlen is not None and retrlen >= 0:
                headers += "Content-Length: %d\n" % retrlen
            headers = mimetools.Message(StringIO(headers))
            return addinfourl(fp, "ftp:" + url)
        except ftperrors(), msg:
            raise IOError, msg), sys.exc_info()[2]
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def open_ftp(self, sys.exc_info()[2]
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def open_ftp(self, sys.exc_info()[2]
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def open_ftp(self, sys.exc_info()[2]
项目:hakkuframework    作者:4shadoww    | 项目源码 | 文件源码
def ftp_open(self, req):
        import ftplib
        import mimetypes
        host = req.host
        if not host:
            raise URLError('ftp error: no host given')
        host, 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.selector)
        dirs = path.split('/')
        dirs = list(map(unquote, dirs))
        dirs, type)
            headers = ""
            mtype = mimetypes.guess_type(req.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
            headers = email.message_from_string(headers)
            return addinfourl(fp, req.full_url)
        except ftplib.all_errors as exp:
            exc = URLError('ftp error: %r' % exp)
            raise_with_traceback(exc)
项目:hakkuframework    作者:4shadoww    | 项目源码 | 文件源码
def open_ftp(self, str):
            raise URLError('ftp error: proxy support for ftp protocol currently not implemented')
        import mimetypes
        host, path = splithost(url)
        if not host: raise URLError('ftp error: no host given')
        host, passwd = splitpasswd(user)
        else: passwd = None
        host = unquote(host)
        user = unquote(user or '')
        passwd = unquote(passwd or '')
        host = socket.gethostbyname(host)
        if not port:
            import ftplib
            port = ftplib.FTP_PORT
        else:
            port = int(port)
        path,rather arbitrarily
            for k in self.ftpcache.keys():
                if k != key:
                    v = self.ftpcache[k]
                    del self.ftpcache[k]
                    v.close()
        try:
            if key not in self.ftpcache:
                self.ftpcache[key] = \
                    ftpwrapper(user, type)
            mtype = mimetypes.guess_type("ftp:" + url)[0]
            headers = ""
            if mtype:
                headers += "Content-Type: %s\n" % mtype
            if retrlen is not None and retrlen >= 0:
                headers += "Content-Length: %d\n" % retrlen
            headers = email.message_from_string(headers)
            return addinfourl(fp, "ftp:" + url)
        except ftperrors() as exp:
            raise_with_traceback(URLError('ftp error %r' % exp))
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def ftp_open(self, req.full_url)
        except ftplib.all_errors as msg:
            exc = URLError('ftp error: %s' % msg)
            raise exc.with_traceback(sys.exc_info()[2])
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def open_ftp(self, str):
            raise URLError('ftp error', 'proxy support for ftp protocol currently not implemented')
        import mimetypes
        from io import StringIO
        host, path = splithost(url)
        if not host: raise URLError('ftp error', "ftp:" + url)
        except ftperrors() as msg:
            raise URLError('ftp error', msg).with_traceback(sys.exc_info()[2])
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def open_ftp(self, sys.exc_info()[2]
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def open_ftp(self, sys.exc_info()[2]
项目:packaging    作者:blockstack    | 项目源码 | 文件源码
def ftp_open(self, req.full_url)
        except ftplib.all_errors as exp:
            exc = URLError('ftp error: %r' % exp)
            raise_with_traceback(exc)
项目:packaging    作者:blockstack    | 项目源码 | 文件源码
def open_ftp(self, "ftp:" + url)
        except ftperrors() as exp:
            raise_with_traceback(URLError('ftp error %r' % exp))
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def open_ftp(self, sys.exc_info()[2]
项目:islam-buddy    作者:hamir    | 项目源码 | 文件源码
def ftp_open(self, req.full_url)
        except ftplib.all_errors as exp:
            exc = URLError('ftp error: %r' % exp)
            raise_with_traceback(exc)
项目:islam-buddy    作者:hamir    | 项目源码 | 文件源码
def open_ftp(self, "ftp:" + url)
        except ftperrors() as exp:
            raise_with_traceback(URLError('ftp error %r' % exp))
项目:cheapstream    作者:miltador    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def ftp_open(self, 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, sys.exc_info()[2]
项目:FightstickDisplay    作者:calexil    | 项目源码 | 文件源码
def ftp_open(self, req.full_url)
        except ftplib.all_errors as exp:
            exc = URLError('ftp error: %r' % exp)
            raise_with_traceback(exc)
项目:FightstickDisplay    作者:calexil    | 项目源码 | 文件源码
def open_ftp(self, "ftp:" + url)
        except ftperrors() as exp:
            raise_with_traceback(URLError('ftp error %r' % exp))
项目:plugin.video.streamondemand-pureita    作者:orione7    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def open_ftp(self, sys.exc_info()[2]
项目:cryptogram    作者:xinmingzhang    | 项目源码 | 文件源码
def ftp_open(self, req.full_url)
        except ftplib.all_errors as exp:
            exc = URLError('ftp error: %r' % exp)
            raise_with_traceback(exc)
项目:cryptogram    作者:xinmingzhang    | 项目源码 | 文件源码
def open_ftp(self, "ftp:" + url)
        except ftperrors() as exp:
            raise_with_traceback(URLError('ftp error %r' % exp))
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def ftp_open(self, req.full_url)
        except ftplib.all_errors as exp:
            exc = URLError('ftp error: %r' % exp)
            raise_with_traceback(exc)
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def open_ftp(self, "ftp:" + url)
        except ftperrors() as exp:
            raise_with_traceback(URLError('ftp error %r' % exp))
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def open_ftp(self, sys.exc_info()[2]
项目:land-leg-PY    作者:xfkencon    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def ftp_open(self, passwd = splitpasswd(user)
        else:
            passwd = None
        host = unquote(host)
        user = user or ''
        passwd = passwd or ''

        try:
            host = socket.gethostbyname(host)
        except OSError as msg:
            raise URLError(msg)
        path, req.full_url)
        except ftplib.all_errors as exp:
            exc = URLError('ftp error: %r' % exp)
            raise exc.with_traceback(sys.exc_info()[2])
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def open_ftp(self,rather arbitrarily
            for k in list(self.ftpcache):
                if k != key:
                    v = self.ftpcache[k]
                    del self.ftpcache[k]
                    v.close()
        try:
            if key not in self.ftpcache:
                self.ftpcache[key] = \
                    ftpwrapper(user, "ftp:" + url)
        except ftperrors() as exp:
            raise URLError('ftp error %r' % exp).with_traceback(sys.exc_info()[2])
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def open_ftp(self, sys.exc_info()[2]
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def open_ftp(self,rather arbitrarily
            for k in self.ftpcache.keys():
                if k != key:
                    v = self.ftpcache[k]
                    del self.ftpcache[k]
                    v.close()
        try:
            if not key in self.ftpcache:
                self.ftpcache[key] = ftpwrapper(user, value = splitvalue(attr)
                if attr.lower() == 'type' and value in ('a', sys.exc_info()[2]
项目:empyrion-python-api    作者:huhlig    | 项目源码 | 文件源码
def ftp_open(self, sys.exc_info()[2]

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Python ftplib 模块,error_proto() 实例源码 我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用ftplib.error_proto()。
Python ftplib 模块,Error() 实例源码 我们从Python开源项目中,提取了以下33个代码示例,用于说明如何使用ftplib.Error()。
Python ftplib 模块,error_reply() 实例源码 我们从Python开源项目中,提取了以下36个代码示例,用于说明如何使用ftplib.error_reply()。
Python ftplib 模块,error_temp() 实例源码 我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用ftplib.error_temp()。
Python ftplib 模块,FTP_TLS 实例源码 我们从Python开源项目中,提取了以下42个代码示例,用于说明如何使用ftplib.FTP_TLS。
Python ftplib 模块,FTP_PORT 实例源码 我们从Python开源项目中,提取了以下42个代码示例,用于说明如何使用ftplib.FTP_PORT。
Python ftplib 模块,all_errors() 实例源码 我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用ftplib.all_errors()。
Python ftplib 模块,error_perm() 实例源码 我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用ftplib.error_perm()。
Python ftplib 模块,FTP 实例源码 我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用ftplib.FTP。
Python sklearn.base 模块,is_classifier() 实例源码 我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用sklearn.base.is_classifier()。
Python sklearn.base 模块,ClusterMixin() 实例源码 我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用sklearn.base.ClusterMixin()。
Python sklearn.base 模块,RegressorMixin() 实例源码 我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用sklearn.base.RegressorMixin()。
Python sklearn.base 模块,clone() 实例源码 我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sklearn.base.clone()。
Python sklearn.base 模块,ClassifierMixin() 实例源码 我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用sklearn.base.ClassifierMixin()。
Python sklearn.base 模块,TransformerMixin() 实例源码 我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用sklearn.base.TransformerMixin()。
Python sklearn.base 模块,BaseEstimator() 实例源码 我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用sklearn.base.BaseEstimator()。
Python colorama.Fore 模块,LIGHTCYAN_EX 实例源码 我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用colorama.Fore.LIGHTCYAN_EX。
Python colorama.Fore 模块,LIGHTMAGENTA_EX 实例源码 我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用colorama.Fore.LIGHTMAGENTA_EX。
Python colorama.Fore 模块,LIGHTBLUE_EX 实例源码 我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用colorama.Fore.LIGHTBLUE_EX。
Python colorama.Fore 模块,LIGHTWHITE_EX 实例源码 我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用colorama.Fore.LIGHTWHITE_EX。