/scripts/fetch_eggs.py
Python | 60 lines | 56 code | 0 blank | 4 comment | 1 complexity | 27cae02a80ad379052e81248d1946e11 MD5 | raw file
1""" 2usage: fetch_eggs.py [egg_name] [platform] 3 With no arguments, fetches all eggs necessary according to the 4 settings in universe_wsgi.ini. 5 egg_name - Fetch only this egg (as defined in eggs.ini) or 'all' for 6 all eggs (even those not required by your settings). 7 platform - Fetch eggs for a specific platform (if not provided, fetch 8 eggs for *this* platform). Useful for fetching eggs for cluster 9 nodes which are of a different architecture than the head node. 10 Platform name can be determined with the get_platforms.py script. 11""" 12import os, sys, logging 13 14root = logging.getLogger() 15root.setLevel( 10 ) 16root.addHandler( logging.StreamHandler( sys.stdout ) ) 17 18lib = os.path.abspath( os.path.join( os.path.dirname( __file__ ), "..", "lib" ) ) 19sys.path.append( lib ) 20 21from galaxy.eggs import Crate, EggNotFetchable 22import pkg_resources 23 24c = Crate() 25try: 26 c.platform = sys.argv[2] 27except: 28 pass 29try: 30 if len( sys.argv ) == 1: 31 c.resolve() # Only fetch eggs required by the config 32 elif sys.argv[1] == 'all': 33 c.resolve( all=True ) # Fetch everything 34 else: 35 # Fetch a specific egg 36 name = sys.argv[1] 37 try: 38 egg = c[name] 39 except: 40 print "error: %s not in eggs.ini" % name 41 sys.exit( 1 ) 42 dist = egg.resolve()[0] 43 print "%s %s is installed at %s" % ( dist.project_name, dist.version, dist.location ) 44except EggNotFetchable, e: 45 try: 46 assert sys.argv[1] != 'all' 47 egg = e.eggs[0] 48 print "%s %s couldn't be downloaded automatically. You can try" % ( egg.name, egg.version ) 49 print "building it by hand with:" 50 print " python scripts/scramble.py %s" 51 except ( AssertionError, IndexError ): 52 print "One or more of the python eggs necessary to run Galaxy couldn't be" 53 print "downloaded automatically. You can try building them by hand (all" 54 print "at once) with:" 55 print " python scripts/scramble.py" 56 print "Or individually:" 57 for egg in e.eggs: 58 print " python scripts/scramble.py %s" % egg.name 59 sys.exit( 1 ) 60sys.exit( 0 )