0

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?

charmd
  • 103
  • 2
  • @MartinPrikryl the first post is rather a "negative" information (I cannot use Python's watchdog library to watch a FTP server as I would a folder). And I didn't like the second solution so much specifically because of the while loop with a sleep(...). It feels like something I would do (i.e. quite amateurish) and not so robust – charmd Sep 27 '22 at 10:30
  • If however nothing is shocking about this approach, I can (and I will) accept the first answer. Apologies for the quality of the post, I will try to formulate my problems differently in the future – charmd Sep 27 '22 at 10:32

1 Answers1

0

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

Rayon Magique
  • 130
  • 2
  • 15