feat: support use with statement to create a ftpserver temporarily#567
feat: support use with statement to create a ftpserver temporarily#567ramwin wants to merge 2 commits into
Conversation
|
@giampaolo the continuous-integration test failed. But the log shows that this is caused by |
|
@giampaolo , Please review this pull request when you have any free time. Thanks a lot. |
|
consider rerunning with current CI |
Signed-off-by: Xiang Wang <ramwin@qq.com>
Signed-off-by: Xiang Wang <ramwin@qq.com>
|
Hello, @gliptak . I rebase my branch onto the master branch. Review this pull request again when you are free. |
|
I don't think this is necessary (or at least not in this form). Do you need this to have a test FTP server to connect to during unit tests? If that's the case, then I think it may make more sense to add pyftpdlib/pyftpdlib/test/__init__.py Line 430 in 2784660 |
| return | ||
|
|
||
| def __exit__(self, exc_type, exc_value, traceback): | ||
| logger.debug("you are existing FTPServerContext") |
|
I have a simple script that need to start a ftpserver and call other web service to connect the ftpserver. It was inconvinent to first start a ftpserver and than run the simple script. I want to achieve this using with statement with FtpServer(ftpusername, ftppassword) as tmp_ftpserver:
requests.post("http://otherserver/download", json={
ftpusername, ftppassword, filepath
})after the script, the ftpserver can be closed automatically. |
|
Other wise, I will have to open two terminal. First terminal Second terminal and I can only stop the ftpserver after the main script finished. |
|
I forgot I added it, but |
The function |
|
I tried use the with FTPServer(("localhost", 2121), handler) as f:
f.serve_forever(blocking=False)
print("start success")
with FTP() as ftp:
ftp.connect(host='localhost', port=2121)
ftp.login()
print(ftp.dir())there is no |
No description provided.