Chromium Nightly Build Downloader After realizing that I was spending a lot of time getting the latest version of Chromium, I figured I would throw together a quick script. Over time, I wanted to make the script more efficient, cleaner, and pythonic. Here is what I came up with:

from zipfile import ZipFile
from os import rename, remove, path
from shutil import rmtree, copytree
from httplib2 import Http
from sys import argv, exit
from easygui import indexbox


h = Http('.cache')
saveDir = 'C:\\Program Files\\Chromium\\'

def getLatestVersion():
    verSite = ('http://build.chromium.org/f/chromium/snapshots/' +
            'Win/LATEST')
    re, ver = h.request(verSite)
    ver = str(ver, encoding='utf8')
    return ver


def delCurrent():
    try:
        rmtree(path.join(saveDir, 'Current'))
    except Exception:
        print('Chromium could not be removed.')


def delBackup():
    try:
        rmtree(path.join(saveDir, 'Backup'))
    except Exception:
        print('Backup could not be removed.')


def downloadChromium(ver):
    site = ('http://build.chromium.org/buildbot/snapshots/Win/'
            + ver + '/chrome-win32.zip')
    re, chrome = h.request(site)
    file = open(path.join(saveDir, 'latest.zip'), 'wb')
    file.write(chrome)
    file.close()


def unzip():
    zip = ZipFile(saveDir + 'latest.zip', 'r')
    zip.extractall(saveDir)
    rename(path.join(saveDir, 'chrome-win32'), path.join(saveDir, 'Current'))
    zip.close()
    remove(path.join(saveDir, 'latest.zip'))


def revert():
    delCurrent()
    copytree(path.join(saveDir, 'Backup'), path.join(saveDir, 'Current'))


def backup():
    delBackup()
    copytree(path.join(saveDir, 'Current'), path.join(saveDir, 'Backup'))


def gui():
    ver = getLatestVersion()
    choices = ['Download version %s' % ver, 'Backup', 'Revert', 'Exit']
    choice = indexbox('What do you want to do?',
            'Chromium Downloader', choices)
    if choice == 0:
        delCurrent()
        downloadChromium(ver)
        unzip()
    elif choice == 1:
        backup()
    elif choice == 2:
        revert()
    elif choice == 3:
        exit()
    gui()


def usage():
    print('-h         Display help text\n' +
          '-g         Launches the GUI Program\n' +
          '-v         Only gets the version\n' +
          '-r         Reverts to last backup\n' +
          '-b         Saves a new backup\n' +
          '-o         Specify version to download\n')


def main():
    if '-g' in argv:
        gui()
        exit()
    elif '-h' in argv:
        usage()
        exit(2)
    elif '-r' in argv:
        revert()
        exit()

    if '-o' in argv:
        ver = argv.index('-o') + 1
    else:
        ver = getLatestVersion()
        print('Latest Version: ', ver)
    if '-v' in argv:
        exit()

    delCurrent()
    downloadChromium(ver)
    unzip()

    if '-b' in argv:
        backup()

if __name__ == "__main__":
    main()


Are there any major things that should be changed to make this code better?
I assume you are aware of Chrome Canary, which I gather is able to use binary deltas? I don't think it's pure Chromium though.

Your code is pretty clean. You could be using argparse for parsing the command line, currently you are ignoring flags that don't match. You could wrap the exit call around main, like this: exit(main()), and use return / return 2 statements instead. You could replace "C:\\Program Files" with %PROGRAMFILES%, or pick up some defaults from the registry, but that's not necessary unless you plan for a larger audience. You could also reduce the window Chromium is unavailable by unzipping somewhere else, then moving the directories, then clearing the previous one (but I don't think you can make it atomic without something like symlinks or hardlinks).