Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Closes #12 | $ python packages.py setup # Now sets up Ultros' depende…
Browse files Browse the repository at this point in the history
…ncies using Pip.
  • Loading branch information
gdude2002 committed May 9, 2014
1 parent b63b00a commit b6de96e
Showing 1 changed file with 75 additions and 1 deletion.
76 changes: 75 additions & 1 deletion packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import os
import sys
import tempfile
import urllib

if os.path.dirname(sys.argv[0]):
Expand All @@ -38,7 +39,7 @@
from utils.misc import string_split_readable

operations = ["install", "update", "uninstall", "list", "list-installed",
"info", "help"]
"info", "help", "setup"]


def output_help():
Expand All @@ -55,6 +56,8 @@ def output_help():
print "update all Update all packages"
print "uninstall <package> Remove a package"
print ""
print "setup Sets up Ultros' dependencies"
print ""
print "=== Informational operations ==="
print "list List all available packages"
print "list-installed List only installed packages"
Expand Down Expand Up @@ -133,6 +136,9 @@ def get_packages(get=True):
packages = get_packages()
uninstall(args, packages)

elif operation == "setup":
setup()

elif operation == "update":
packages = get_packages()
if len(args) > 1 and args[1] == "all":
Expand Down Expand Up @@ -303,6 +309,74 @@ def info(args, packages):
print info["current_version"]["info"]


def setup():
windows = os.name == "nt"

if not windows:
pip.main(["install", "-r", "requirements.txt"])

print ">> Presuming everything installed okay, you should now be " \
"ready to run Ultros!"
else:
reqs = open("requirements.txt", "r").read()
reqs = reqs.replace("\r", "")
reqs = reqs.split()

if "" in reqs:
reqs.remove("")

for x in ["pyopenssl", "twisted"]:
if x in reqs:
reqs.remove(x)

urls = {
"Twisted": [
["https://pypi.python.org/packages/2.7/T/Twisted/Twisted-"
"13.2.0.win32-py2.7.msi", "twisted.msi"]
],
"OpenSSL and PyOpenSSL": [
["http://slproweb.com/download/Win32OpenSSL-1_0_1g.exe",
"openssl.exe"],
["https://pypi.python.org/packages/2.7/p/pyOpenSSL/pyOpenSSL-0"
".13.1.win32-py2.7.exe", "pyopenssl.exe"]
]
}

pip.main(["install"] + reqs)

print ""
print ">> There are some things pip can't install."
print ">> I will now attempt to download and install them manually."
print ">> Please be ready to click through dialogs!"
print ">> Please note, these files only work with Python 2.7!"
print ""

tempdir = tempfile.gettempdir()

print ">> Files will be downloaded to %s" % tempdir
print ""
print ">> OpenSSL will complain about a command prompt being open."
print ">> This is fine, just click \"OK\" to continue."
print ""

for k in urls.keys():
print ">> Downloading files for %s" % k

files = urls[k]

for x in files:
print " -> %s" % x[1]

try:
urllib.urlretrieve(x[0], tempdir + "/ultros." + x[1])

os.system(tempdir + "/ultros." + x[1])
finally:
os.remove(tempdir + "/ultros." + x[1])

print ">> Presuming everything installed okay, you should now be " \
"ready to run Ultros!"

if __name__ == "__main__":
args = sys.argv[1:]
main(args)

0 comments on commit b6de96e

Please sign in to comment.