Skip to content

Commit

Permalink
Update fs.expose.ftp for compatibility with latest pyftpdlib.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Cunningham committed Oct 7, 2015
1 parent 9d9440e commit 08bac4b
Showing 1 changed file with 8 additions and 6 deletions.
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()

1 comment on commit 08bac4b

@kitsmag
Copy link

@kitsmag kitsmag commented on 08bac4b Jan 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.