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


Python ftplib.FTP_TLS属性代码示例

本文整理汇总了Python中ftplib.FTP_TLS属性的典型用法代码示例。如果您正苦于以下问题:Python ftplib.FTP_TLS属性的具体用法?Python ftplib.FTP_TLS怎么用?Python ftplib.FTP_TLS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在ftplib的用法示例。


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

示例1: __init__

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def __init__(self, one=None, globus_client=None):
        super().__init__(one=one)
        self.ftp = ftplib.FTP_TLS(host=FTP_HOST,
                                  user=one._par.FTP_DATA_SERVER_LOGIN,
                                  passwd=one._par.FTP_DATA_SERVER_PWD)
        # self.ftp.ssl_version = ssl.PROTOCOL_TLSv1
        # self.ftp.auth()
        self.ftp.prot_p()
        self.ftp.login(one._par.FTP_DATA_SERVER_LOGIN, one._par.FTP_DATA_SERVER_PWD) 
开发者ID:int-brain-lab,项目名称:ibllib,代码行数:11,代码来源:patcher.py

示例2: connect

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def connect(self, params={}):
        self.logger.info("Connect: Connecting..")
        host = params.get('host')
        username = params.get('credentials').get('username', 'anonymous')
        password = params.get('credentials').get('password', 'test@test.com')
        # Use secure mode?
        secure = params.get('secure', False)
        # Use passive mode?
        passive = params.get('passive', False)

        # Either ftplib.FTP or ftplib.FTP_TLS
        base_ftp_class = ftplib.FTP
        if secure:
            base_ftp_class = ftplib.FTP_TLS
        my_session_factory = ftputil.session.session_factory(
            base_class=base_ftp_class,
            use_passive_mode=passive)
        try:
            self.ftp_host = ftputil.FTPHost(host, username,
                                            password, session_factory=my_session_factory)
        except ftputil.error.PermanentError as e:
            raise e 
开发者ID:rapid7,项目名称:insightconnect-plugins,代码行数:24,代码来源:connection.py

示例3: test_context

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def test_context(self):
        self.client.quit()
        ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)
        self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE,
                          context=ctx)
        self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
                          context=ctx)
        self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
                          keyfile=CERTFILE, context=ctx)

        self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT)
        self.client.connect(self.server.host, self.server.port)
        self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
        self.client.auth()
        self.assertIs(self.client.sock.context, ctx)
        self.assertIsInstance(self.client.sock, ssl.SSLSocket)

        self.client.prot_p()
        sock = self.client.transfercmd('list')
        try:
            self.assertIs(sock.context, ctx)
            self.assertIsInstance(sock, ssl.SSLSocket)
        finally:
            sock.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:test_ftplib.py

示例4: get_conn

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def get_conn(self):
        """
        Returns a FTPS connection object.
        """
        if self.conn is None:
            params = self.get_connection(self.ftp_conn_id)
            pasv = params.extra_dejson.get("passive", True)

            if params.port:
                ftplib.FTP_TLS.port = params.port

            self.conn = ftplib.FTP_TLS(
                params.host, params.login, params.password
            )
            self.conn.set_pasv(pasv)

        return self.conn 
开发者ID:apache,项目名称:airflow,代码行数:19,代码来源:ftp.py

示例5: test_context

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def test_context(self):
        self.client.quit()
        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE,
                          context=ctx)
        self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
                          context=ctx)
        self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
                          keyfile=CERTFILE, context=ctx)

        self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT)
        self.client.connect(self.server.host, self.server.port)
        self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
        self.client.auth()
        self.assertIs(self.client.sock.context, ctx)
        self.assertIsInstance(self.client.sock, ssl.SSLSocket)

        self.client.prot_p()
        with self.client.transfercmd('list') as sock:
            self.assertIs(sock.context, ctx)
            self.assertIsInstance(sock, ssl.SSLSocket) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:test_ftplib.py

示例6: test_context

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def test_context(self):
        self.client.quit()
        ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
        ctx.check_hostname = False
        ctx.verify_mode = ssl.CERT_NONE
        self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE,
                          context=ctx)
        self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
                          context=ctx)
        self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
                          keyfile=CERTFILE, context=ctx)

        self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT)
        self.client.connect(self.server.host, self.server.port)
        self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
        self.client.auth()
        self.assertIs(self.client.sock.context, ctx)
        self.assertIsInstance(self.client.sock, ssl.SSLSocket)

        self.client.prot_p()
        with self.client.transfercmd('list') as sock:
            self.assertIs(sock.context, ctx)
            self.assertIsInstance(sock, ssl.SSLSocket) 
开发者ID:bkerler,项目名称:android_universal,代码行数:25,代码来源:test_ftplib.py

示例7: __init__

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def __init__(self, host, username='', password=''):
        self._client = ftplib.FTP_TLS(timeout=10)
        self._client.connect(host)

        # enable TLS
        try:
            self._client.auth()
        except ftplib.error_perm:
            # TLS authentication not supported
            # fallback to a plain FTP client
            self._client.close()
            self._client = ftplib.FTP(timeout=10)
            self._client.connect(host)
        
        self._client.login(username, password)

        if hasattr(self._client, 'prot_p'):
            self._client.prot_p() 
开发者ID:PacktPublishing,项目名称:Modern-Python-Standard-Library-Cookbook,代码行数:20,代码来源:networking_03.py

示例8: _ftp_connect

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def _ftp_connect(self):
        try:
            self.conn.voidcmd("NOOP")
            return True
        except:
            if self.tls:
                self.conn = ftplib.FTP_TLS()
            else:
                self.conn = ftplib.FTP()
            self.conn.connect(self.host, self.port, timeout=self.timeout)
            self.conn.login(self.username, self.password)
            if self.tls:
                self.conn.prot_p() 
开发者ID:d6t,项目名称:d6tpipe,代码行数:15,代码来源:ftp.py

示例9: setUp

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def setUp(self):
        self.server = DummyTLS_FTPServer((HOST, 0))
        self.server.start()
        self.client = ftplib.FTP_TLS(timeout=10)
        self.client.connect(self.server.host, self.server.port)
        # enable TLS
        self.client.auth()
        self.client.prot_p() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_ftplib.py

示例10: test_check_hostname

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def test_check_hostname(self):
        self.client.quit()
        ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)
        ctx.verify_mode = ssl.CERT_REQUIRED
        ctx.check_hostname = True
        ctx.load_verify_locations(CAFILE)
        self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT)

        # 127.0.0.1 doesn't match SAN
        self.client.connect(self.server.host, self.server.port)
        with self.assertRaises(ssl.CertificateError):
            self.client.auth()
        # exception quits connection

        self.client.connect(self.server.host, self.server.port)
        self.client.prot_p()
        with self.assertRaises(ssl.CertificateError):
            self.client.transfercmd("list").close()
        self.client.quit()

        self.client.connect("localhost", self.server.port)
        self.client.auth()
        self.client.quit()

        self.client.connect("localhost", self.server.port)
        self.client.prot_p()
        self.client.transfercmd("list").close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:29,代码来源:test_ftplib.py

示例11: login

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def login(self, *args, **kwargs):
            ftplib.FTP_TLS.login(self, *args, **kwargs)
            self.prot_p() 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:5,代码来源:test_functional_ssl.py

示例12: setUp

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def setUp(self):
        self.server = FTPSServer()
        self.server.start()
        self.client = ftplib.FTP_TLS(timeout=TIMEOUT)
        self.client.connect(self.server.host, self.server.port) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:7,代码来源:test_functional_ssl.py

示例13: setUp

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def setUp(self):
        self.server = DummyTLS_FTPServer((HOST, 0))
        self.server.start()
        self.client = ftplib.FTP_TLS(timeout=TIMEOUT)
        self.client.connect(self.server.host, self.server.port)
        # enable TLS
        self.client.auth()
        self.client.prot_p() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:10,代码来源:test_ftplib.py

示例14: test_check_hostname

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def test_check_hostname(self):
        self.client.quit()
        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        ctx.verify_mode = ssl.CERT_REQUIRED
        ctx.check_hostname = True
        ctx.load_verify_locations(CAFILE)
        self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT)

        # 127.0.0.1 doesn't match SAN
        self.client.connect(self.server.host, self.server.port)
        with self.assertRaises(ssl.CertificateError):
            self.client.auth()
        # exception quits connection

        self.client.connect(self.server.host, self.server.port)
        self.client.prot_p()
        with self.assertRaises(ssl.CertificateError):
            with self.client.transfercmd("list") as sock:
                pass
        self.client.quit()

        self.client.connect("localhost", self.server.port)
        self.client.auth()
        self.client.quit()

        self.client.connect("localhost", self.server.port)
        self.client.prot_p()
        with self.client.transfercmd("list") as sock:
            pass 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:31,代码来源:test_ftplib.py

示例15: get_file_ftps

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import FTP_TLS [as 别名]
def get_file_ftps(host, path_to_file, ftps_configuration):
    """
        Copy an existing file from FTP via ftp://*host*/*path_to_file* link to home directory.
        The function return the full path to the file that has been downloaded.
    """
    # Construct FTP object and get the file on a server
    with ftplib.FTP_TLS(host, user = ftps_configuration["user"], passwd = ftps_configuration["psswd"]) as ftps:
        filename = re.findall("[^/]*$", path_to_file)[0]
        ftps.prot_p()
        with open(filename, "wb") as wf:
            ftps.retrbinary("RETR " + filename, wf.write)

    file_location = gc_write_dir + "/" + filename
    print("File " + path_to_file + " has got successfully.")
    return file_location 
开发者ID:OWOX,项目名称:BigQuery-integrations,代码行数:17,代码来源:main.py


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