1 | """ |
---|
2 | usage: scramble.py [egg_name] |
---|
3 | With no arguments, scrambles all eggs necessary according to the |
---|
4 | settings in universe_wsgi.ini. |
---|
5 | egg_name - Scramble only this egg (as defined in eggs.ini) or 'all' |
---|
6 | for all eggs (even those not required by your settings). |
---|
7 | """ |
---|
8 | import os, sys, logging |
---|
9 | |
---|
10 | root = logging.getLogger() |
---|
11 | root.setLevel( 10 ) |
---|
12 | root.addHandler( logging.StreamHandler( sys.stdout ) ) |
---|
13 | |
---|
14 | lib = os.path.abspath( os.path.join( os.path.dirname( __file__ ), "..", "lib" ) ) |
---|
15 | sys.path.append( lib ) |
---|
16 | |
---|
17 | from galaxy.eggs.scramble import ScrambleCrate, ScrambleFailure, EggNotFetchable |
---|
18 | |
---|
19 | c = ScrambleCrate() |
---|
20 | |
---|
21 | try: |
---|
22 | if len( sys.argv ) == 1: |
---|
23 | eggs = c.scramble() |
---|
24 | elif sys.argv[1] == 'all': |
---|
25 | c.scramble( all=True ) |
---|
26 | else: |
---|
27 | # Scramble a specific egg |
---|
28 | name = sys.argv[1] |
---|
29 | try: |
---|
30 | egg = c[name] |
---|
31 | except: |
---|
32 | print "error: %s not in eggs.ini" % name |
---|
33 | sys.exit( 1 ) |
---|
34 | for dependency in egg.dependencies: |
---|
35 | print "Checking %s dependency: %s" % ( egg.name, dependency ) |
---|
36 | try: |
---|
37 | c[dependency].require() |
---|
38 | except EggNotFetchable, e: |
---|
39 | degg = e.eggs[0] |
---|
40 | print "%s build dependency %s %s couldn't be downloaded" % ( egg.name, degg.name, degg.version ) |
---|
41 | print "automatically. You can try building it by hand with:" |
---|
42 | print " python scripts/scramble.py %s" % degg.name |
---|
43 | sys.exit( 1 ) |
---|
44 | egg.scramble() |
---|
45 | sys.exit( 0 ) |
---|
46 | except ScrambleFailure, e: |
---|
47 | if len( e.eggs ) == 1: |
---|
48 | raise |
---|
49 | else: |
---|
50 | print 'Scrambling the following eggs failed:\n ', |
---|
51 | print '\n '.join( [ egg.name for egg in e.eggs ] ) |
---|
52 | sys.exit( 1 ) |
---|