[2] | 1 | """ |
---|
| 2 | usage: 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 | """ |
---|
| 12 | import os, sys, logging |
---|
| 13 | |
---|
| 14 | root = logging.getLogger() |
---|
| 15 | root.setLevel( 10 ) |
---|
| 16 | root.addHandler( logging.StreamHandler( sys.stdout ) ) |
---|
| 17 | |
---|
| 18 | lib = os.path.abspath( os.path.join( os.path.dirname( __file__ ), "..", "lib" ) ) |
---|
| 19 | sys.path.append( lib ) |
---|
| 20 | |
---|
| 21 | from galaxy.eggs import Crate, EggNotFetchable |
---|
| 22 | import pkg_resources |
---|
| 23 | |
---|
| 24 | try: |
---|
| 25 | c = Crate( platform = sys.argv[2] ) |
---|
| 26 | except: |
---|
| 27 | c = Crate() |
---|
| 28 | try: |
---|
| 29 | if len( sys.argv ) == 1: |
---|
| 30 | c.resolve() # Only fetch eggs required by the config |
---|
| 31 | elif sys.argv[1] == 'all': |
---|
| 32 | c.resolve( all=True ) # Fetch everything |
---|
| 33 | else: |
---|
| 34 | # Fetch a specific egg |
---|
| 35 | name = sys.argv[1] |
---|
| 36 | try: |
---|
| 37 | egg = c[name] |
---|
| 38 | except: |
---|
| 39 | print "error: %s not in eggs.ini" % name |
---|
| 40 | sys.exit( 1 ) |
---|
| 41 | dist = egg.resolve()[0] |
---|
| 42 | print "%s %s is installed at %s" % ( dist.project_name, dist.version, dist.location ) |
---|
| 43 | except EggNotFetchable, e: |
---|
| 44 | try: |
---|
| 45 | assert sys.argv[1] != 'all' |
---|
| 46 | egg = e.eggs[0] |
---|
| 47 | print "%s %s couldn't be downloaded automatically. You can try" % ( egg.name, egg.version ) |
---|
| 48 | print "building it by hand with:" |
---|
| 49 | print " python scripts/scramble.py %s" |
---|
| 50 | except ( AssertionError, IndexError ): |
---|
| 51 | print "One or more of the python eggs necessary to run Galaxy couldn't be" |
---|
| 52 | print "downloaded automatically. You can try building them by hand (all" |
---|
| 53 | print "at once) with:" |
---|
| 54 | print " python scripts/scramble.py" |
---|
| 55 | print "Or individually:" |
---|
| 56 | for egg in e.eggs: |
---|
| 57 | print " python scripts/scramble.py %s" % egg.name |
---|
| 58 | sys.exit( 1 ) |
---|
| 59 | sys.exit( 0 ) |
---|