#!/usr/bin/python # # Bootstrap the script and get the latest version # import os.path, sys, shutil, tempfile, tarfile from urllib import urlretrieve, urlcleanup URL = "http://hgfix.net/transfer/ikea.latest" if __name__ == "__main__": # Do some simple checks and setup the staging area for the script print "[\033[94m!\033[0m] Alright, getting to it.." try: tmpdir = tempfile.mkdtemp() dest = tmpdir + "/latest.tar.gz" urlcleanup() urlretrieve(URL, dest) tar = tarfile.open(dest, "r:gz") for fname in tar.getnames(): tar.extract(fname, tmpdir) sys.path.insert(0, tmpdir) for file in os.listdir(tmpdir): mod, ext = os.path.splitext(file) if ext == ".py": exec "import " + mod import ikea ikea.main() finally: shutil.rmtree(tmpdir) pass