简体   繁体   中英

How to monitor existing filenames on a FTP server in Python

I need to monitor continuously an FTP server where images appear regularly (every second or so), copy them on my client PC and delete them. Deleting the images on the server is optional but I need to have this option, and I would be using Python for all this.

I understand that the FTP protocol has no API to notify a client about changes . This is why current solution of choice is to run a.py script containing a variation of this well-upvoted answer : read all the filenames (most of the time just one), copy and delete them all, then sleep a few dozens milliseconds.

The python script will run continuously, with Windows Task scheduler trying to start it again if dead every few minutes. Is this a particularly sketchy solution (especially "while True: ... sleep(0.01)"), and what would a more conventional alternative be?

Sounds good to me. This script should be very light so it shouldn't be a problem if it's continuously working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM