Created
November 8, 2012 15:10
-
-
Save stuaxo/4039371 to your computer and use it in GitHub Desktop.
Work around low bandwith connection with PIP to install a requirements file in jenkins.
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
# Terrible hack to get around pip bailing on flaky internet connection. | |
# | |
# Usage: | |
# python cackinstaller.py requirements.txt | |
# | |
import os | |
import sys | |
retries = 5 | |
LOCALSHOP_INSTANCE = 'http://192.168.91.37:8900/simple/' | |
if __name__ == '__main__': | |
if len(sys.argv) == 2: | |
filename = sys.argv[1] | |
# Try and instlal the old fashioned way first | |
command = 'pip install -r %s' % filename | |
status os.system(command) | |
if status == 0: | |
sys.exit(0) | |
for package in open(filename).readlines(): | |
if package.strip().startswith('#'): | |
continue | |
if package.strip() == '': | |
continue | |
for go in range(retries): | |
command = 'pip install %s' % package | |
if go == 0: | |
command += 'pip install -i %s %s' % (LOCALSHOP_INSTANCE, package) | |
else: | |
command = 'pip install %s' % package | |
status = os.system(command) | |
if not status: | |
break | |
else: | |
print 'Failed with %d retrys' % retries | |
sys.exit(1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment