Skip to content

Instantly share code, notes, and snippets.

@stuaxo
Created November 8, 2012 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuaxo/4039371 to your computer and use it in GitHub Desktop.
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.
# 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