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


Python FTPServer.serve_forever方法代码示例

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


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

示例1: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
def main():
    port = 3334
    user = ''
    password = ''
    l = sys.argv

    if (len(l) > 1 and l[1]):
        user = l[1]

    if (len(l) > 2 and l[2]):
        password = l[2]

    if (len(l) > 3 and l[3]):
        port = int(l[3])


    authorizer = DummyAuthorizer()
    authorizer.add_user(user, password, os.getcwd(), perm='elradfmwM')
    authorizer.add_anonymous('.')

    handler = TLS_FTPHandler
    handler.certfile = CERTFILE
    handler.authorizer = authorizer

    server = FTPServer(("127.0.0.1", port), handler)
    server.serve_forever()
开发者ID:peteoconnell,项目名称:brackets-ftp-sync,代码行数:28,代码来源:ftpsd.py

示例2: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [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='elradfmwM')
    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:070499,项目名称:service.lan.ftp,代码行数:33,代码来源:basic_ftpd.py

示例3: FTPd

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
class FTPd(threading.Thread):
    def __init__(self, root_dir, address=None, timeout=0.001, dtp_handler=None):
        threading.Thread.__init__(self)
        self.__flag = threading.Event()
        self.__timeout = timeout
        authorizer = DummyAuthorizer()
        authorizer.add_anonymous(root_dir)
        handler = FTPHandler
        handler.authorizer = authorizer
        if dtp_handler is not None:
            handler.dtp_handler = dtp_handler
        self.server = FTPServer(address, handler)

    def start(self):
        self.__flag.clear()
        threading.Thread.start(self)
        self.__flag.wait()

    def run(self):
        self.__flag.set()
        while self.__flag.is_set():
            self.server.serve_forever(timeout=self.__timeout, blocking=False)
        self.server.close_all()
        self.server.close()

    def stop(self):
        self.__flag.clear()
        self.join()
开发者ID:jvivian,项目名称:s3am,代码行数:30,代码来源:FTPd.py

示例4: server_start

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
def server_start(is_verbose=False, port=None):
    if not os.path.isfile('conf.json'):
        print 'Conf file not found, please run setup.'
        sys.exit(1)
    with open('conf.json') as jd:
        template = json.load(jd)
    container.set_acc_db(str(template['user_db']), str(template['user_table']))
    container.set_shares_db(str(template['user_logs']))
    container.set_root_dir(str(template['root']))
    container.set_log_file(str(template['root']) + '/pyftpd.log')
    auth = authorizer()
    handle = handler
    handle.user_sendfile = True
    handle.timeout = None
    handle.authorizer = auth
    handle.banner = 'this is the banner'
    if port:  # untested
        address = ('', 1024)
    else:
        address = ('', 21)
    server = FTPServer(address, handle)
    server.max_cons = 256
    server.maxcons_per_ip = 1000000
    if not is_verbose:
        logging.basicConfig(filename=container.get_log_file(), level=logging.INFO)
    server.serve_forever()
开发者ID:Devon-Peroutky,项目名称:OneDir,代码行数:28,代码来源:onedir_runner.py

示例5: run

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
    def run(self):
        """Start the FTP Server for pulsar search."""
        self._log.info('Starting Pulsar Search Interface')
        # 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(self._config['login']['user'],
                            self._config['login']['psswd'], '.',
                            perm=self._config['login']['perm'])
        authorizer.add_anonymous(os.getcwd())

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

        # Define a customized banner (string returned when client connects)
        handler.banner = "SKA SDP pulsar search interface."

        # Instantiate FTP server class and listen on 0.0.0.0:7878
        address = (self._config['address']['listen'],
                   self._config['address']['port'])
        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:SKA-ScienceDataProcessor,项目名称:integration-prototype,代码行数:34,代码来源:pulsar_search.py

示例6: FTPListener

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
class FTPListener(threading.Thread):
    """
    Simple thread to run the FTP Server
    """

    def __init__(self, user=DEFAULT_USER, pwd=DEFAULT_PWD, port=DEFAULT_FTP_PORT, addr=DEFAULT_FTP_ADDR):
        """
        Constructor
        """
        self.user = user
        self.pwd = pwd
        self.port = port
        self.addr = addr
        threading.Thread.__init__(self)

    def run(self):
        """
        Starts the FTP server
        """
        authorizer = DummyAuthorizer()
        authorizer.add_user(self.user, self.pwd, ".", perm="elradfmw")
        handler = OneTimeFTPHandler
        handler.authorizer = authorizer
        self.server = FTPServer((self.addr, self.port), handler)
        self.server.serve_forever()

    def stop(self):
        """
        Stops the FTP server
        """
        if self.server is not None:
            self.server.close()
开发者ID:datacenter,项目名称:aci-export,代码行数:34,代码来源:aci-export.py

示例7: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [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:070499,项目名称:service.lan.ftp,代码行数:9,代码来源:unix_ftpd.py

示例8: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [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(konf.ftp_username,
                        konf.ftp_password,
                        'ftp/',
                        perm='elradfmwM')
    # 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."

    # 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:jpf,项目名称:ftp-to-s3,代码行数:31,代码来源:server.py

示例9: handle

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
 def handle(self, *args, **options):
     handler = TLS_FTPHandler
     handler.certfile = Config.objects.get(key='certfile').value
     handler.authorizer = DjangoFtpAuthorizer()
     handler.abstracted_fs = CloudFS
     server = FTPServer(("0.0.0.0", 21), handler)
     server.serve_forever()
开发者ID:meeuw,项目名称:cfbrowser,代码行数:9,代码来源:ftpserver.py

示例10: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
def main():
    port = 3334
    user = ''
    password = ''
    l = sys.argv

    if (len(l) > 1 and l[1]):
        user = l[1]

    if (len(l) > 2 and l[2]):
        password = l[2]

    if (len(l) > 3 and l[3]):
        port = int(l[3])


    authorizer = DummyAuthorizer()
    authorizer.add_user(user, password, os.getcwd(), perm='elradfmwM')
    #authorizer.add_anonymous("/home/nobody")

    handler = FTPHandler
    handler.authorizer = authorizer

    logging.basicConfig(level=logging.DEBUG)

    server = FTPServer(("127.0.0.1", port), handler)
    server.serve_forever()
开发者ID:peteoconnell,项目名称:brackets-ftp-sync,代码行数:29,代码来源:ftpd.py

示例11: start_ftp_server

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
def start_ftp_server():
    cs.CSClient().log(APP_NAME, 'start_ftp_server()...')
    try:
        authorizer = DummyAuthorizer()
        # Define a new user having full r/w permissions and a read-only
        # anonymous user
        authorizer.add_user('user', '12345', FTP_DIR, perm='elradfmwM')
        authorizer.add_anonymous(FTP_DIR)

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

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

        # Instantiate FTP server class and listen on 0.0.0.0:2121.
        # Application can only use ports higher that 1024 and the port
        # will need to be allowed in the router firewall
        address = ('', 2121)
        server = FTPServer(address, handler)

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

        # start ftp server
        cs.CSClient().log(APP_NAME, 'Starting FTP server...')
        server.serve_forever()
        # This will run the server in another thread
        # t = Thread(target=server.serve_forever())
        # t.start()

    except Exception as e:
        cs.CSClient().log(APP_NAME, 'Exception occurred! exception: {}'.format(e))
开发者ID:cradlepoint,项目名称:sdk-samples,代码行数:37,代码来源:ftp_server.py

示例12: serve

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
    def serve(self):
        # current directory
        exfil_directory = os.path.join(os.getcwd(), "data")
        loot_path = exfil_directory + "/"

        # Check to make sure the agent directory exists, and a loot
        # directory for the agent.  If not, make them
        if not os.path.isdir(loot_path):
            os.makedirs(loot_path)

        try:
            authorizer = DummyAuthorizer()
            authorizer.add_user(
                self.username, self.password,
                loot_path, perm="elradfmwM")

            handler = FTPHandler
            handler.authorizer = authorizer

            # Define a customized banner (string returned when client connects)
            handler.banner = "Connecting to Egress-Assess's FTP server!"

            try:
                server = FTPServer(('', self.port), handler)
                server.serve_forever()
            except socket.error:
                print "[*][*] Error: Port %d is currently in use!" % self.port
                print "[*][*] Error: Please restart when port is free!\n"
                sys.exit()
        except ValueError:
            print "[*] Error: The directory you provided may not exist!"
            print "[*] Error: Please re-run with a valid FTP directory."
            sys.exit()
        return
开发者ID:453483289,项目名称:Egress-Assess,代码行数:36,代码来源:ftp_server.py

示例13: start_ftp_server

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
def start_ftp_server():
    authorizer = DummyAuthorizer()
    authorizer.add_anonymous("ftpvista/test")
    handler = FTPHandler
    handler.authorizer = authorizer
    server = FTPServer(("127.0.0.1", 2121), handler)
    server.serve_forever()
开发者ID:magne4000,项目名称:ftpvista,代码行数:9,代码来源:test.py

示例14: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
def main():
    """
    Main ftp server code
    """
    with open("ABSOLUTE_PATH_OF_config.yaml", 'r') as stream:
        config = yaml.load(stream)
        authorizer = DummyAuthorizer()
        if config.get('user'):
            for each_user in config['user']:
                if not os.path.exists(each_user['details']['home_directory']):
                    os.makedirs(each_user['details']['home_directory'])
                authorizer.add_user(
                    each_user['details']['username'],
                    each_user['details']['password'],
                    each_user['details']['home_directory'],
                    perm=each_user['details']['permission']
                )
        authorizer.add_anonymous('.')
        handler = MyHandler
        handler.certfile = config['certfile']
        handler.authorizer = authorizer
        handler.masquerade_address = config['masquerade_address']
        # requires SSL for both control and data channel
        handler.tls_control_required = True
        handler.tls_data_required = True
        handler.passive_ports = range(60000, 60099)
        server = FTPServer(('', 21), handler)
        server.serve_forever()
开发者ID:santoshghimire,项目名称:python-ftp-server,代码行数:30,代码来源:ftps.py

示例15: ftp_server

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import serve_forever [as 别名]
def ftp_server(command_line_object):
    # current directory
    exfil_directory = os.path.join(os.getcwd(), "data")
    loot_path = exfil_directory + "/"

    # Check to make sure the agent directory exists, and a loot
    # directory for the agent.  If not, make them
    if not os.path.isdir(loot_path):
        os.makedirs(loot_path)

    try:
        authorizer = DummyAuthorizer()
        authorizer.add_user(
            command_line_object.username, command_line_object.password,
            loot_path, perm="lrw")

        handler = FTPHandler
        handler.authorizer = authorizer

        # Define a customized banner (string returned when client connects)
        handler.banner = "Connecting to Egress-Assess's FTP server!"

        server = FTPServer(('', 21), handler)
        server.serve_forever()
    except ValueError:
        print "[*] Error: The directory you provided may not exist!"
        print "[*] Error: Please re-run with a valid FTP directory."
        sys.exit()
开发者ID:johnjohnsp1,项目名称:Egress-Assess,代码行数:30,代码来源:Egress-Assess.py


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