/scripts/check_eggs.py

https://bitbucket.org/cistrome/cistrome-harvard/ · Python · 41 lines · 26 code · 8 blank · 7 comment · 4 complexity · 2d4f18cee67a24cec3f8987330fcf0a1 MD5 · raw file

  1. #!/usr/bin/env python
  2. """
  3. Compares local dependency eggs to those in eggs.ini, displaying a warning if
  4. any are out of date.
  5. usage: check_eggs.py [options]
  6. """
  7. import os, sys, logging
  8. from optparse import OptionParser
  9. parser = OptionParser()
  10. parser.add_option( '-c', '--config', dest='config', help='Path to Galaxy config file (universe_wsgi.ini)', default='universe_wsgi.ini' )
  11. parser.add_option( '-q', '--quiet', dest='quiet', action="store_true", help='Quiet (no output, only set return code)', default=False )
  12. ( options, args ) = parser.parse_args()
  13. if not os.path.exists( options.config ):
  14. print "Config file does not exist (see 'python %s --help'): %s" % ( sys.argv[0], options.config )
  15. sys.exit( 1 )
  16. root = logging.getLogger()
  17. root.setLevel( 10 )
  18. root.addHandler( logging.StreamHandler( sys.stdout ) )
  19. config_arg = ''
  20. if options.config != 'universe_wsgi.ini':
  21. config_arg = '-c %s' % options.config
  22. lib = os.path.abspath( os.path.join( os.path.dirname( __file__ ), "..", "lib" ) )
  23. sys.path.append( lib )
  24. from galaxy.eggs import Crate
  25. c = Crate( options.config )
  26. if c.config_missing:
  27. if not options.quiet:
  28. print "Some of your Galaxy eggs are out of date. Please update them"
  29. print "by running:"
  30. print " python scripts/fetch_eggs.py %s" % config_arg
  31. sys.exit( 1 )
  32. sys.exit( 0 )