Wednesday, May 21, 2014

code: sync files using FTP

My webhost doesn't support rsync, only FTP.  For grins I wrote a script to scan through interesting local files and push them up to my webhost.  Alas the progress wasn't as trivial as I'd hoped, so I abandoned the effort and used lftp the "mirror" command.

The code shows a number of best practices:

  • don't store passwords/keys, pass them in via environment variables
  • make an iterator of files, add to it using chain()
  • Python3 subprocess.check_output() is a little odd
  • logging, like voting, should be done early and often
  • code ensures FTP connection always closed cleanly

No comments:

Post a Comment