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


Python servers.FTPServer类代码示例

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


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

示例1: server_start

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,代码行数:26,代码来源:onedir_runner.py

示例2: FTPListener

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,代码行数:32,代码来源:aci-export.py

示例3: run

    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,代码行数:32,代码来源:pulsar_search.py

示例4: custom_server

 def custom_server(self, start=1):
     # TODO: finish me
     from pyftpdlib.authorizers import DummyAuthorizer
     from pyftpdlib.handlers import FTPHandler
     from pyftpdlib.servers import FTPServer
     # Generate random username and password for ftp session
     logging.debug('generating arguments')
     if not os.path.isdir(self.path):
         logging.info('%s create directory: %s' %
                      ('device.name', self.path))
         os.makedirs(self.path)
     # Add ftp user
     authorizer = DummyAuthorizer()
     logging.debug('generated args: user=%s password=%s path=%s perm=%s' %
                   (self.user, self.password, self.path, self.password))
     authorizer.add_user(self.user, self.password, self.path,
                         perm=self.perm)
     handler = FTPHandler
     handler.authorizer = authorizer
     # Instantiate FTP server class and listen
     logging.debug('%s ftp server listen on: %s %s' %
                   ('device.name', self.address, self.port))
     addr = (self.address, self.port)
     server = FTPServer(addr, handler)
     # Set a limit for connections
     server.max_cons = 32
     server.max_cons_per_ip = 5
     # Start ftp server
     logging.debug('starting disposable ftp server')
     server.serve_forever(timeout=600, blocking=False)
开发者ID:drunkard,项目名称:lazycat,代码行数:30,代码来源:ftp.py

示例5: main

def main(profiles):
    authorizer = DummyAuthorizer()
    # 将每个profile映射为一个用户
    uploadTmpRoot = tempfile.gettempdir()
    for p, c in profiles.items():
        # perm权限定义说明:
        # Read permissions:
        # "e" = change directory (CWD, CDUP commands)
        # "l" = list files (LIST, NLST, STAT, MLSD, MLST, SIZE commands)
        # "r" = retrieve file from the server (RETR command)
        # Write permissions:

        # "a" = append data to an existing file (APPE command)
        # "d" = delete file or directory (DELE, RMD commands)
        # "f" = rename file or directory (RNFR, RNTO commands)
        # "m" = create directory (MKD command)
        # "w" = store a file to the server (STOR, STOU commands)
        # "M" = change mode/permission (SITE CHMOD command) New in 0.7.0
        # 注意:投产时权限似乎应限制为只写,即:'w'
        uploadTmp = path.join(uploadTmpRoot, p)
        print uploadTmp
        if not path.isdir(uploadTmp):
            mkdir(uploadTmp)

        authorizer.add_user(p, c["upload"].get("password", ""), uploadTmp, perm="ledw")

    handler = UploadHandler
    handler.authorizer = authorizer
    handler.banner = "OSO fileserv"
    address = ("", int(getenv("FTP_PORT", "2121")))
    logging.basicConfig(filename="logs/ftp.log", level=logging.INFO)
    server = FTPServer(address, handler)
    server.max_cons = 256
    server.max_cons_per_ip = 5
    server.serve_forever()
开发者ID:chenchen0,项目名称:fileserv,代码行数:35,代码来源:server.py

示例6: main

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,代码行数:28,代码来源:ftps.py

示例7: start_ftp_server

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,代码行数:7,代码来源:test.py

示例8: main

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,代码行数:7,代码来源:unix_ftpd.py

示例9: main

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,代码行数:26,代码来源:ftpsd.py

示例10: ftp_server

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,代码行数:28,代码来源:Egress-Assess.py

示例11: start_ftp_server

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,代码行数:35,代码来源:ftp_server.py

示例12: main

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,代码行数:31,代码来源:basic_ftpd.py

示例13: main

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,代码行数:27,代码来源:ftpd.py

示例14: main

def main():
    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()
    # Define a new user having full r/w permissions
    authorizer.add_user("user_name", "pass_word", "./", perm="elradfmwM", msg_login="welcome", msg_quit="bye")
    # Define a read-only anonymous user
    authorizer.add_anonymous("./")

    # Instantiate FTP handler class
    handler = FTPHandler
    handler.authorizer = authorizer
    handler.max_login_attempts = 3
    handler.permit_foreign_addresses = True
    handler.tcp_no_delay = True

    # Define a customized banner (string returned when client connects)
    handler.banner = "Welcome to my FTP."

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

    # set a limit for connections
    server.max_cons = 128
    server.max_cons_per_ip = 2

    absfs = AbstractedFS(u"./", handler)
    absfs.cwd = u"/bbb/ss/"
    # start ftp server
    server.serve_forever()
开发者ID:oska874,项目名称:py-study-code,代码行数:30,代码来源:ftp0.py

示例15: main

def main(args):
    user = DEFAULT_USER
    password = DEFAULT_PASSWORD
    ip = DEFAULT_IP
    port = DEFAULT_PORT
    directory = args.directory
    permissions = DEFAULT_PERM
    
    if args.user:
        user = args.user
    
    if args.password:
        password = args.password
        
    if args.ip:
        ip = args.ip
        
    if args.port:
        port = args.port
        
    authorizer = DummyAuthorizer()
    authorizer.add_user(user, password, directory, perm=permissions)
    
    #handler = TLS_FTPHandler
    #handler.certfile = 'server.crt'
    handler = FTPHandler
    handler.authorizer = authorizer
    
    server = FTPServer((ip, port), handler)
    server.serve_forever()
开发者ID:Schnobb,项目名称:ftpd,代码行数:30,代码来源:ftpd.py


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