Last active
December 19, 2015 12:58
-
-
Save Terrance/5958418 to your computer and use it in GitHub Desktop.
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…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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