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


Python servers.FTPServer方法代码示例

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


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

示例1: main

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def main():
    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()

    # anonymous user
    authorizer.add_anonymous(os.getcwd())

    # Instantiate FTP handler class
    handler = FTPHandler
    handler.authorizer = authorizer
    handler.permit_foreign_addresses = True

    # Instantiate FTP server class and listen on 0.0.0.0:21
    address = ('', 21)
    server = FTPServer(address, handler)

    # start ftp server
    server.serve_forever() 
开发者ID:hunters-forge,项目名称:mordor,代码行数:20,代码来源:ftp_server_start.py

示例2: setUp

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def setUp(self):
        class DummyFTPServer(FTPServer):
            """An overridden version of FTPServer class which forces
            serve_forever() to return immediately.
            """

            def serve_forever(self, *args, **kwargs):
                return

        if PY3:
            import io
            self.devnull = io.StringIO()
        else:
            self.devnull = BytesIO()
        sys.argv = self.SYSARGV[:]
        sys.stderr = self.STDERR
        self.original_ftpserver_class = FTPServer
        pyftpdlib.__main__.FTPServer = DummyFTPServer 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:20,代码来源:test_misc.py

示例3: main

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def main():
    authorizer = DummyAuthorizer()
    authorizer.add_user('user', '12345', os.getcwd(), perm='elradfmwMT')
    authorizer.add_anonymous(os.getcwd())

    dtp_handler = ThrottledDTPHandler
    dtp_handler.read_limit = 30720  # 30 Kb/sec (30 * 1024)
    dtp_handler.write_limit = 30720  # 30 Kb/sec (30 * 1024)

    ftp_handler = FTPHandler
    ftp_handler.authorizer = authorizer
    # have the ftp handler use the alternative dtp handler class
    ftp_handler.dtp_handler = dtp_handler

    server = FTPServer(('', 2121), ftp_handler)
    server.serve_forever() 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:18,代码来源:throttled_ftpd.py

示例4: start_ftp

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def start_ftp(masquerade_address, listen_address, port, log_level, bucket_endpoints, internal):

    if log_level == "DEBUG":
        level = logging.DEBUG
    elif log_level == "INFO":
        level = logging.INFO
    elif log_level == "WARNING":
        level = logging.WARNING
    elif log_level == "ERROR":
        level = logging.ERROR
    elif log_level == "CRITICAL":
        level = logging.CRITICAL
    else:
        print "wrong loglevel parameter: %s" % log_level
        exit(1)

    authorizer = OssAuthorizer()
    if bucket_endpoints != "":
        for url in bucket_endpoints.strip().split(','):
            if len(url.split('.', 1)) != 2:
                print "url:%s format error." % (url)
                continue
            bucket_name, endpoint = url.split('.', 1)
            authorizer.bucket_endpoints[bucket_name] = endpoint
    authorizer.internal = internal
    handler = FTPHandler
    handler.permit_foreign_addresses = True
    if handler.masquerade_address != "":
        handler.masquerade_address = masquerade_address 
    handler.authorizer = authorizer
    handler.abstracted_fs = OssFS
    handler.banner = 'oss ftpd ready.'
    address = (listen_address, port)
    set_logger(level)
    server = FTPServer(address, handler)
    server.serve_forever() 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:38,代码来源:ftpserver.py

示例5: ftp_init

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def ftp_init():
    authentication = load_user_table()
    if authentication:
        handler = FTPHandler
        handler.authorizer = authentication

        server = FTPServer((get_config('env', 'ftp_addr'), int(get_config('env', 'ftp_port'))), handler)
        server.serve_forever()
    else:
        print('==Unable to Start BioQueue FTP Server==') 
开发者ID:liyao001,项目名称:BioQueue,代码行数:12,代码来源:ftpserver.py

示例6: run

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def run(port=2121, passive_ports=range(60000, 65535), masquerade_address=None):
    authorizer = CosAuthorizer()
    for login_user, login_password, home_dir, permission in CosFtpConfig().login_users:
        perm = ""
        if "R" in permission:
            perm = perm + authorizer.read_perms
        if "W" in permission:
            perm = perm + authorizer.write_perms
        authorizer.add_user(login_user, login_password, home_dir, perm=perm)

    handler = CosFtpHandler
    handler.authorizer = authorizer
    handler.abstracted_fs = CosFileSystem
    handler.banner = "Welcome to COS FTP Service"
    handler.permit_foreign_addresses = True

    if masquerade_address is not None:
        handler.masquerade_address = masquerade_address

    handler.passive_ports = passive_ports

    server = FTPServer(("0.0.0.0", port), handler)
    server.max_cons = CosFtpConfig().max_connection_num

    print "starting  ftp server..."

    try:
        server.serve_forever()
    finally:
        server.close_all() 
开发者ID:tencentyun,项目名称:cos-ftp-server-V5,代码行数:32,代码来源:server.py

示例7: run

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def run(ns):
    """starts the server."""
    auth = DummyAuthorizer()
    if ns.user is not None:
        auth.add_user(ns.user, ns.pswd, ns.path, perm=ns.perm)
    else:
        auth.add_anonymous(ns.path, perm=ns.perm)
    handler = FTPHandler
    handler.authorizer = auth
    handler.banner = "StaSh v{v} FTP-Server".format(v=_stash.__version__)
    address = ("0.0.0.0", ns.port)
    server = FTPServer(address, handler)
    server.max_cons = 128
    server.max_cons_per_ip = 128
    # setup logging
    logger = logging.getLogger("pyftpdlib")
    logger.setLevel(logging.CRITICAL)
    logger.propagate = False
    # server needs to run in a thread to be killable
    thr = threading.Thread(name="FTP-Server Thread", target=server.serve_forever)
    thr.daemon = True
    thr.start()
    print("FTP-Server started on {h}:{p}".format(h=address[0], p=str(address[1])))
    try:
        while True:
            time.sleep(0.2)
    except KeyboardInterrupt:
        print("Stopping Server...")
        server.close_all() 
开发者ID:ywangd,项目名称:stash,代码行数:31,代码来源:ftpserver.py

示例8: run

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def run(self):
        authorizer = DummyAuthorizer()
        authorizer.add_user(self.username, self.password, os.environ['HOME'], perm="elradfmw")

        handler = FTPHandler
        handler.authorizer = authorizer

        self.__server = FTPServer(('0.0.0.0', self.port), handler)

        if self.enabled:
            ftp_thread = threading.Thread(target=self.__server.serve_forever)
            ftp_thread.daemon = True
            ftp_thread.start() 
开发者ID:gamer-os,项目名称:steam-buddy,代码行数:15,代码来源:server.py

示例9: tearDown

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def tearDown(self):
        self.devnull.close()
        sys.argv = self.SYSARGV[:]
        sys.stderr = self.STDERR
        pyftpdlib.servers.FTPServer = self.original_ftpserver_class 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:7,代码来源:test_misc.py

示例10: test_sock_instead_of_addr

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def test_sock_instead_of_addr(self):
        # pass a socket object instead of an address tuple to FTPServer
        # constructor
        with contextlib.closing(socket.socket()) as sock:
            sock.bind((HOST, 0))
            sock.listen(5)
            ip, port = sock.getsockname()[:2]
            self.server = self.server_class(sock)
            self.server.start()
            self.client = self.client_class(timeout=TIMEOUT)
            self.client.connect(ip, port)
            self.client.login(USER, PASSWD) 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:14,代码来源:test_servers.py

示例11: test_ctx_mgr

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def test_ctx_mgr(self):
        with servers.FTPServer((HOST, 0), handlers.FTPHandler) as server:
            self.assertIsNotNone(server)


# =====================================================================
# --- threaded FTP server mixin tests
# =====================================================================

# What we're going to do here is repeat the original functional tests
# defined in test_functinal.py but by using different concurrency
# modules (multi thread and multi process instead of async.
# This is useful as we reuse the existent functional tests which are
# supposed to work no matter what the concurrency model is. 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:16,代码来源:test_servers.py

示例12: main

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def main():
    authorizer = WindowsAuthorizer()
    # Use Guest user with empty password to handle anonymous sessions.
    # Guest user must be enabled first, empty password set and profile
    # directory specified.
    # authorizer = WindowsAuthorizer(anonymous_user="Guest",
    #                                anonymous_password="")
    handler = FTPHandler
    handler.authorizer = authorizer
    ftpd = FTPServer(('', 21), handler)
    ftpd.serve_forever() 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:13,代码来源:winnt_ftpd.py

示例13: main

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def main():
    # get a hash digest from a clear-text password
    hash = md5(b'12345').hexdigest()
    authorizer = DummyMD5Authorizer()
    authorizer.add_user('user', hash, os.getcwd(), perm='elradfmwMT')
    authorizer.add_anonymous(os.getcwd())
    handler = FTPHandler
    handler.authorizer = authorizer
    server = FTPServer(('', 2121), handler)
    server.serve_forever() 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:12,代码来源:md5_ftpd.py

示例14: main

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def main():
    authorizer = UnixAuthorizer(rejected_users=["root"],
                                require_valid_shell=True)
    handler = FTPHandler
    handler.authorizer = authorizer
    handler.abstracted_fs = UnixFilesystem
    server = FTPServer(('', 21), handler)
    server.serve_forever() 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:10,代码来源:unix_ftpd.py

示例15: main

# 需要导入模块: from pyftpdlib import servers [as 别名]
# 或者: from pyftpdlib.servers import FTPServer [as 别名]
def main():
    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()

    # Define a new user having full r/w permissions and a read-only
    # anonymous user
    authorizer.add_user('user', '12345', os.getcwd(), perm='elradfmwMT')
    authorizer.add_anonymous(os.getcwd())

    # Instantiate FTP handler class
    handler = FTPHandler
    handler.authorizer = authorizer

    # Define a customized banner (string returned when client connects)
    handler.banner = "pyftpdlib based ftpd ready."

    # Specify a masquerade address and the range of ports to use for
    # passive connections.  Decomment in case you're behind a NAT.
    # handler.masquerade_address = '151.25.42.11'
    handler.passive_ports = range(60000, 65535)

    # Instantiate FTP server class and listen on 0.0.0.0:2121
    address = ('', 2121)
    server = FTPServer(address, handler)

    # set a limit for connections
    server.max_cons = 256
    server.max_cons_per_ip = 5

    # start ftp server
    server.serve_forever() 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:33,代码来源:basic_ftpd.py


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