/scripts/fetch_eggs.py

https://bitbucket.org/h_morita_dbcls/galaxy-central · Python · 60 lines · 56 code · 0 blank · 4 comment · 1 complexity · 27cae02a80ad379052e81248d1946e11 MD5 · raw file

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