コード例 #1
0
def _upload_file(address, port, username, password, index, filepath):
    from ftplib import FTP
    from infi.gevent_utils.os import path, fopen
    from infi.app_repo.ftpserver import make_ftplib_gevent_friendly
    make_ftplib_gevent_friendly()
    ftp = FTP()
    ftp.connect(address, port)
    ftp.login(username, password)
    ftp.cwd(index)

    with fopen(filepath) as fd:
        ftp.storbinary("STOR %s" % path.basename(filepath), fd)
コード例 #2
0
ファイル: sync.py プロジェクト: Annakan/infi.app_repo
def _upload_file(address, port, username, password, index, filepath):
    from ftplib import FTP
    from infi.gevent_utils.os import path, fopen
    from infi.app_repo.ftpserver import make_ftplib_gevent_friendly
    make_ftplib_gevent_friendly()
    ftp = FTP()
    ftp.connect(address, port)
    ftp.login(username, password)
    ftp.cwd(index)

    with fopen(filepath) as fd:
        ftp.storbinary("STOR %s" % path.basename(filepath), fd)
コード例 #3
0
ファイル: extended.py プロジェクト: Annakan/infi.app_repo
def upload_file(config, index, filepath):
    from ftplib import FTP
    from infi.gevent_utils.os import path, fopen
    from infi.app_repo.ftpserver import make_ftplib_gevent_friendly
    from infi.gevent_utils.deferred import create_threadpool_executed_func
    make_ftplib_gevent_friendly()
    ftp = FTP()
    ftp.connect('127.0.0.1', config.ftpserver.port)
    ftp.login(config.ftpserver.username, config.ftpserver.password)
    ftp.cwd(index)

    with fopen(filepath) as fd:
        ftp.storbinary("STOR %s" % path.basename(filepath), fd)
コード例 #4
0
ファイル: extended.py プロジェクト: Annakan/infi.app_repo
def upload_file(config, index, filepath):
    from ftplib import FTP
    from infi.gevent_utils.os import path, fopen
    from infi.app_repo.ftpserver import make_ftplib_gevent_friendly
    from infi.gevent_utils.deferred import create_threadpool_executed_func
    make_ftplib_gevent_friendly()
    ftp = FTP()
    ftp.connect('127.0.0.1', config.ftpserver.port)
    ftp.login(config.ftpserver.username, config.ftpserver.password)
    ftp.cwd(index)

    with fopen(filepath) as fd:
        ftp.storbinary("STOR %s" % path.basename(filepath), fd)
コード例 #5
0
ファイル: test_case.py プロジェクト: Infinidat/infi.app_repo
    def ftp_client_context(self, config, login_with_credentials_in_config=False):
        from ftplib import FTP
        from infi.app_repo.ftpserver import make_ftplib_gevent_friendly
        make_ftplib_gevent_friendly()

        client = FTP()
        client.connect('127.0.0.1', self.config.ftpserver.port)
        if login_with_credentials_in_config:
            client.login(config.ftpserver.username, config.ftpserver.password)
        else:
            client.login()
        self.addCleanup(client.close)
        try:
            yield client
        finally:
            client.close()
コード例 #6
0
    def ftp_client_context(self,
                           config,
                           login_with_credentials_in_config=False):
        from ftplib import FTP
        from infi.app_repo.ftpserver import make_ftplib_gevent_friendly
        make_ftplib_gevent_friendly()

        client = FTP()
        client.connect('127.0.0.1', self.config.ftpserver.port)
        if login_with_credentials_in_config:
            client.login(config.ftpserver.username, config.ftpserver.password)
        else:
            client.login()
        self.addCleanup(client.close)
        try:
            yield client
        finally:
            client.close()