-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
feat: support use with statement to create a ftpserver temporarily #567
base: master
Are you sure you want to change the base?
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 <[email protected]>
Signed-off-by: Xiang Wang <[email protected]>
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: existing -> exiting
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.