Python Is Fun

Usually, I don’t do much programming because it’s always taken a lot of work to do even the simplest of things. However, since I’ve discovered Python, I’ve been having a blast. Just yesterday, I wrote a command line tool to upload files to Box.com. While I could have used somebody else’s libraries to do the heavy lifting, I wanted to roll my own code. I thought it would be both more fun and more educational that way, and it was. My initial purpose for writing this program was that I could use it in a cron job to perform server backups. Now, because server backup was my primary goal and I can encrypt the backup archives before uploading, security wasn’t much of an issue. Because I wasn’t very concerned with the security of the transfers, I didn’t bother to do things like check for SSL/TLS certificate validity. Additionally, I put my API key right in the code, so I can’t just distribute it and let people see that. If you want it, I’ve put it up on Pastebin with my API key removed here. The license is Public Domain because it’s so simple and I only spent around 6 hours writing it. Currently, it can upload multiple files in the same command, but it’s not exactly elegant because it makes a new connection for each file. The “proper” way to do it is to use the multiple-file-upload part of the API, but that would have taken a significant rewrite of the upload function and, well, “If it ain’t broke, don’t fix it!” Oh, and it freaks out if you tell it to upload a folder, so don’t do that.

This entry was posted in Programming. Bookmark the permalink.