Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fs.expose.ftp for compatibility with latest pyftpdlib. #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions fs/expose/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import errno
from functools import wraps

from pyftpdlib import ftpserver
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.filesystems import AbstractedFS
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

from fs.path import *
from fs.osfs import OSFS
Expand Down Expand Up @@ -70,7 +73,7 @@ def __init__(self, **kwargs):
setattr(self, attr, value)


class FTPFS(ftpserver.AbstractedFS):
class FTPFS(AbstractedFS):
"""
The basic FTP Filesystem. This is a bridge between a pyfs filesystem and pyftpdlib's
AbstractedFS. This class will cause the FTP server to serve the given fs instance.
Expand Down Expand Up @@ -232,7 +235,7 @@ def lexists(self, path):
return True


class FTPFSHandler(ftpserver.FTPHandler):
class FTPFSHandler(FTPHandler):
"""
An FTPHandler class that closes the filesystem when done.
"""
Expand Down Expand Up @@ -283,10 +286,9 @@ def serve_fs(fs, addr, port):
Creates a basic anonymous FTP server serving the given FS on the given address/port
combo.
"""
from pyftpdlib.contrib.authorizers import UnixAuthorizer
ftp_handler = FTPFSHandler
ftp_handler.authorizer = ftpserver.DummyAuthorizer()
ftp_handler.authorizer = DummyAuthorizer()
ftp_handler.authorizer.add_anonymous('/')
ftp_handler.abstracted_fs = FTPFSFactory(fs)
s = ftpserver.FTPServer((addr, port), ftp_handler)
s = FTPServer((addr, port), ftp_handler)
s.serve_forever()