Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A script to download DoXCmd (http://github.com/OllieTerrance/DoXCmd) and DoXTray (http://github.com/OllieTerrance/DoXTray) to the current directory, including the DoX API (http://github.com/OllieTerrance/DoX). Can also be re-run to update to newer versions. Once run, you can use DoXCmd by running DoXCmd/cmd.py from a terminal. DoXTray can be lau…
try:
import os, shutil, zipfile
except ImportError as e:
print("")
print("Error: installation module not available:")
print("{}.".format(e))
print("")
quit()
try:
import urllib
except ImportError:
try:
import urllib.request as urllib
except ImportError as e:
print("")
print("Error: installation module not available:")
print("{}.".format(e))
print("")
quit()
try:
import copy, datetime, re, shlex, time
except ImportError as e:
print("")
print("Warning: required module not available:")
print("{}.".format(e))
print("You will not be able to use DoX without it.")
try:
import sys
except ImportError as e:
print("")
print("Warning: command-line component module not available:")
print("{}.".format(e))
print("You will not be able to use DoXCmd without it.")
try:
import html, PyQt4, webbrowser
except ImportError as e:
print("")
print("Warning: system tray component module not available:")
print("{}.".format(e))
print("You will not be able to use DoXTray without it.")
print("")
path = os.path.dirname(os.path.realpath(__file__))
print("Path: {}".format(path))
for repo in ["DoX", "DoXCmd", "DoXTray"]:
print("")
print("Processing repo: \"{}\"".format(repo))
if os.path.isdir(os.path.join(path, repo)):
shutil.rmtree(repo)
print("Removed old version.")
print("Downloading {}.zip...".format(repo))
file, headers = urllib.urlretrieve("https://github.com/OllieTerrance/{}/archive/master.zip".format(repo), "{}.zip".format(repo))
print("Unpacking files...")
zip = zipfile.ZipFile(file)
for item in zip.namelist():
if item.count("/") >= 2:
dest = os.path.join(path, item.replace("{}-master/".format(repo), ""))
if not os.path.isdir(os.path.dirname(dest)):
os.makedirs(os.path.dirname(dest))
data = zip.read(item)
if not os.path.isdir(dest):
f = open(dest, "wb")
f.write(data)
f.close()
zip.close()
os.remove(file)
print("Removed zip.")
print("")
print("All files downloaded.")
print("")
print("Organising files...")
shutil.copytree("DoX", os.path.join("DoXCmd", "dox"))
shutil.move("DoX", os.path.join("DoXTray", "dox"))
print("")
print("All done.")
print("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment