从giampaolo/pyftpdlib库中删除了通配符支持。在r358之前,Globbing功能一直可用。我们可以回到r357,看看删除了什么,然后重新实现它。https://github.com/giampaolo/pyftpdlib/issues/106#issuecomment-44425620
不支持通配符的全局化(例如,NLST *.txt
将不起作用)。“-从合规文档https://github.com/giampaolo/pyftpdlib/blob/64d629aa480be4340cbab4ced1213211b4eee8db/docs/rfc-compliance.rst
此外,他建议使用MLSD而不是NLST作为一种可能的解决方案。https://github.com/giampaolo/pyftpdlib/issues/106#issuecomment-44425620。我的猜测是,通过对库的修改,通配符功能可以恢复。你知道吗
有人知道如何做到这一点吗?你知道吗
其他详细信息:
我们遵循this tutorial,并在ubuntu14.04上使用可怕的pyftpdlibPython库创建了一个FTP服务器。设置服务器、添加用户和创建挂钩都很容易。你知道吗
有些客户端使用mget直接从服务器与FTP服务器通信。如果直接指定文件名,但传递通配符失败,那么mget命令可以工作。下面是一个示例响应:
ftp> dir
229 Entering extended passive mode (|||26607|).
125 Data connection already open. Transfer starting.
-rw-r--r-- 1 serverpilot serverpilot 914 Oct 06 19:05 index.php
226 Transfer complete.
ftp> mget *.php
No such file or directory.
ftp> glob
Globbing off.
ftp> mget *.php
mget *.php [anpqy?]? y
229 Entering extended passive mode (|||60975|).
550 No such file or directory.
ftp> mget index.php
mget index.php [anpqy?]? y
229 Entering extended passive mode (|||17945|).
125 Data connection already open. Transfer starting.
100% |***************************************************************************************************************************************************************| 914 763.53 KiB/s 00:00 ETA
226 Transfer complete.
914 bytes received in 00:00 (692.99 KiB/s)
我们的脚本如下所示:
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
# The port the FTP server will listen on.
# This must be greater than 1023 unless you run this script as root.
FTP_PORT = 2121
# The name of the FTP user that can log in.
FTP_USER = "myuser"
# The FTP user's password.
FTP_PASSWORD = "change_this_password"
# The directory the FTP user will have full read/write access to.
FTP_DIRECTORY = "/srv/users/serverpilot/apps/APPNAME/public/"
def main():
authorizer = DummyAuthorizer()
# Define a new user having full r/w permissions.
authorizer.add_user(FTP_USER, FTP_PASSWORD, FTP_DIRECTORY, perm='elradfmw')
handler = FTPHandler
handler.authorizer = authorizer
# Define a customized banner (string returned when client connects)
handler.banner = "pyftpdlib based ftpd ready."
# Optionally specify range of ports to use for passive connections.
#handler.passive_ports = range(60000, 65535)
address = ('', FTP_PORT)
server = FTPServer(address, handler)
server.max_cons = 256
server.max_cons_per_ip = 5
server.serve_forever()
if __name__ == '__main__':
main()
看起来通配符是基于this issue故意从库中排除的。作为参考,这里还有my own issue。你知道吗
谁能提供更多的见解或指导我重新启用通配符?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐