1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/73daddf1324d/ changeset: 73daddf1324d user: natefoo date: 2011-06-08 18:10:51 summary: Remove hardcoding of universe_wsgi.ini, fixes issue #358 (except for the sample cleanup scripts which, as samples, are expected to be modified by the site anyway). affected #: 10 files (2.6 KB) --- a/lib/galaxy/app.py Wed Jun 08 11:52:42 2011 -0400 +++ b/lib/galaxy/app.py Wed Jun 08 12:10:51 2011 -0400 @@ -29,7 +29,7 @@ db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % self.config.database # Initialize database / check for appropriate schema version from galaxy.model.migrate.check import create_or_verify_database - create_or_verify_database( db_url, self.config.database_engine_options ) + create_or_verify_database( db_url, kwargs.get( 'global_conf', {} ).get( '__file__', None ), self.config.database_engine_options ) # Setup the database engine and ORM from galaxy.model import mapping self.model = mapping.init( self.config.file_path, --- a/lib/galaxy/eggs/__init__.py Wed Jun 08 11:52:42 2011 -0400 +++ b/lib/galaxy/eggs/__init__.py Wed Jun 08 12:10:51 2011 -0400 @@ -247,7 +247,7 @@ Reads the eggs.ini file for use with checking and fetching. """ config_file = os.path.join( galaxy_dir, 'eggs.ini' ) - def __init__( self, platform=None ): + def __init__( self, galaxy_config_file, platform=None ): self.eggs = {} self.config = CaseSensitiveConfigParser() self.repo = None @@ -256,7 +256,7 @@ self.py_platform = None if platform is not None: self.py_platform = platform.split( '-' )[0] - self.galaxy_config = GalaxyConfig() + self.galaxy_config = GalaxyConfig( galaxy_config_file ) self.parse() def parse( self ): self.config.read( Crate.config_file ) @@ -349,12 +349,14 @@ raise EggNotFetchable( missing ) class GalaxyConfig( object ): - config_file = os.path.join( galaxy_dir, "universe_wsgi.ini" ) always_conditional = ( 'GeneTrack', 'pysam', 'ctypes', 'python_daemon' ) - def __init__( self ): - self.config = ConfigParser.ConfigParser() - if self.config.read( GalaxyConfig.config_file ) == []: - raise Exception( "error: unable to read Galaxy config from %s" % GalaxyConfig.config_file ) + def __init__( self, config_file ): + if config_file is None: + self.config = None + else: + self.config = ConfigParser.ConfigParser() + if self.config.read( config_file ) == []: + raise Exception( "error: unable to read Galaxy config from %s" % config_file ) def check_conditional( self, egg_name ): def check_pysam(): # can't build pysam on solaris < 10 @@ -364,6 +366,10 @@ if int( minor ) < 10: return False return True + # If we're using require() we may not have a Galaxy config file, but if + # we're using require(), we don't care about conditionals. + if self.config is None: + return True if egg_name == "pysqlite": # SQLite is different since it can be specified in two config vars and defaults to True try: @@ -396,7 +402,7 @@ env = get_env() def require( req_str ): - c = Crate() + c = Crate( None ) req = pkg_resources.Requirement.parse( req_str ) # TODO: This breaks egg version requirements. Not currently a problem, but # it could become one. --- a/lib/galaxy/eggs/dist.py Wed Jun 08 11:52:42 2011 -0400 +++ b/lib/galaxy/eggs/dist.py Wed Jun 08 12:10:51 2011 -0400 @@ -39,10 +39,10 @@ Holds eggs with info on how to build them for distribution. """ dist_config_file = os.path.join( galaxy_dir, 'dist-eggs.ini' ) - def __init__( self, build_on='all' ): + def __init__( self, galaxy_config_file, build_on='all' ): self.dist_config = CaseSensitiveConfigParser() self.build_on = build_on - ScrambleCrate.__init__( self ) + ScrambleCrate.__init__( self, galaxy_config_file ) def parse( self ): self.dist_config.read( DistScrambleCrate.dist_config_file ) self.hosts = dict( self.dist_config.items( 'hosts' ) ) --- a/lib/galaxy/model/migrate/check.py Wed Jun 08 11:52:42 2011 -0400 +++ b/lib/galaxy/model/migrate/check.py Wed Jun 08 12:10:51 2011 -0400 @@ -20,7 +20,7 @@ "mysql" : "MySQL_python" } -def create_or_verify_database( url, engine_options={} ): +def create_or_verify_database( url, galaxy_config_file, engine_options={} ): """ Check that the database is use-able, possibly creating it if empty (this is the only time we automatically create tables, otherwise we force the @@ -98,8 +98,11 @@ # Verify that the code and the DB are in sync db_schema = schema.ControlledSchema( engine, migrate_repository ) if migrate_repository.versions.latest != db_schema.version: - raise Exception( "Your database has version '%d' but this code expects version '%d'. Please backup your database and then migrate the schema by running 'sh manage_db.sh upgrade'." - % ( db_schema.version, migrate_repository.versions.latest ) ) + config_arg = '' + if os.path.abspath( os.path.join( os.getcwd(), 'universe_wsgi.ini' ) ) != galaxy_config_file: + config_arg = ' -c %s' % galaxy_config_file.replace( os.path.abspath( os.getcwd() ), '.' ) + raise Exception( "Your database has version '%d' but this code expects version '%d'. Please backup your database and then migrate the schema by running 'sh manage_db.sh%s upgrade'." + % ( db_schema.version, migrate_repository.versions.latest, config_arg ) ) else: log.info( "At database version %d" % db_schema.version ) @@ -123,4 +126,4 @@ finally: for message in "".join( sys.stdout.buffer ).split( "\n" ): log.info( message ) - sys.stdout = old_stdout \ No newline at end of file + sys.stdout = old_stdout --- a/run.sh Wed Jun 08 11:52:42 2011 -0400 +++ b/run.sh Wed Jun 08 12:10:51 2011 -0400 @@ -32,7 +32,7 @@ [ "$arg" = "--stop-daemon" ] && FETCH_EGGS=0; break done if [ $FETCH_EGGS -eq 1 ]; then - python ./scripts/check_eggs.py quiet + python ./scripts/check_eggs.py -q if [ $? -ne 0 ]; then echo "Some eggs are out of date, attempting to fetch..." python ./scripts/fetch_eggs.py --- a/scripts/check_eggs.py Wed Jun 08 11:52:42 2011 -0400 +++ b/scripts/check_eggs.py Wed Jun 08 12:10:51 2011 -0400 @@ -3,27 +3,35 @@ usage: check_eggs.py """ import os, sys, logging +from optparse import OptionParser + +parser = OptionParser() +parser.add_option( '-c', '--config', dest='config', help='Path to Galaxy config file (universe_wsgi.ini)', default='universe_wsgi.ini' ) +parser.add_option( '-q', '--quiet', dest='quiet', action="store_true", help='Quiet (no output, only set return code)', default=False ) +( options, args ) = parser.parse_args() + +if not os.path.exists( options.config ): + print "Config file does not exist (see 'python %s --help'): %s" % ( sys.argv[0], options.config ) + sys.exit( 1 ) root = logging.getLogger() root.setLevel( 10 ) root.addHandler( logging.StreamHandler( sys.stdout ) ) +config_arg = '' +if options.config != 'universe_wsgi.ini': + config_arg = '-c %s' % options.config + lib = os.path.abspath( os.path.join( os.path.dirname( __file__ ), "..", "lib" ) ) sys.path.append( lib ) -try: - assert sys.argv[1] == 'quiet' - quiet = True -except: - quiet = False - from galaxy.eggs import Crate -c = Crate() +c = Crate( options.config ) if c.config_missing: - if not quiet: + if not options.quiet: print "Some of your Galaxy eggs are out of date. Please update them" print "by running:" - print " python scripts/fetch_eggs.py" + print " python scripts/fetch_eggs.py %s" % config_arg sys.exit( 1 ) sys.exit( 0 ) --- a/scripts/dist-scramble.py Wed Jun 08 11:52:42 2011 -0400 +++ b/scripts/dist-scramble.py Wed Jun 08 12:10:51 2011 -0400 @@ -1,11 +1,10 @@ -""" -usage: dist-scramble.py <egg_name> [platform] - egg_name - The egg to scramble (as defined in eggs.ini) - platform - The platform to scramble on (as defined in - dist-eggs.ini). Leave blank for all. - Platform-inspecific eggs ignore this argument. -""" import os, sys, logging +from optparse import OptionParser + +parser = OptionParser() +parser.add_option( '-e', '--egg-name', dest='egg_name', help='Egg name (as defined in eggs.ini) to scramble (required)' ) +parser.add_option( '-p', '--platform', dest='platform', help='Scramble for a specific platform (by default, eggs are scrambled for all platforms, see dist-eggs.ini for platform names)' ) +( options, args ) = parser.parse_args() root = logging.getLogger() root.setLevel( 10 ) @@ -17,18 +16,20 @@ from galaxy.eggs.dist import DistScrambleCrate, ScrambleFailure from galaxy.eggs import EggNotFetchable -if len( sys.argv ) > 3 or len( sys.argv ) < 2: - print __doc__ +if not options.egg_name: + print "ERROR: You must specify an egg to scramble (-e)" + parser.print_help() sys.exit( 1 ) -elif len( sys.argv ) == 3: - c = DistScrambleCrate( sys.argv[2] ) + +if options.platform: + c = DistScrambleCrate( None, options.platform ) else: - c = DistScrambleCrate() + c = DistScrambleCrate( None ) try: - eggs = c[sys.argv[1]] + eggs = c[options.egg_name] except: - print "error: %s not in eggs.ini" % sys.argv[1] + print "ERROR: %s not in eggs.ini" % options.egg_name sys.exit( 1 ) failed = [] for egg in eggs: --- a/scripts/fetch_eggs.py Wed Jun 08 11:52:42 2011 -0400 +++ b/scripts/fetch_eggs.py Wed Jun 08 12:10:51 2011 -0400 @@ -1,15 +1,15 @@ -""" -usage: fetch_eggs.py [egg_name] [platform] - With no arguments, fetches all eggs necessary according to the - settings in universe_wsgi.ini. - egg_name - Fetch only this egg (as defined in eggs.ini) or 'all' for - all eggs (even those not required by your settings). - platform - Fetch eggs for a specific platform (if not provided, fetch - eggs for *this* platform). Useful for fetching eggs for cluster - nodes which are of a different architecture than the head node. - Platform name can be determined with the get_platforms.py script. -""" import os, sys, logging +from optparse import OptionParser + +parser = OptionParser() +parser.add_option( '-c', '--config', dest='config', help='Path to Galaxy config file (universe_wsgi.ini)', default='universe_wsgi.ini' ) +parser.add_option( '-e', '--egg-name', dest='egg_name', help='Egg name (as defined in eggs.ini) to fetch, or "all" for all eggs, even those not needed by your configuration' ) +parser.add_option( '-p', '--platform', dest='platform', help='Fetch for a specific platform (by default, eggs are fetched for *this* platform' ) +( options, args ) = parser.parse_args() + +if not os.path.exists( options.config ): + print "Config file does not exist (see 'python %s --help'): %s" % ( sys.argv[0], options.config ) + sys.exit( 1 ) root = logging.getLogger() root.setLevel( 10 ) @@ -21,18 +21,18 @@ from galaxy.eggs import Crate, EggNotFetchable import pkg_resources +if options.platform: + c = Crate( options.config, platform = options.platform ) +else: + c = Crate( options.config ) try: - c = Crate( platform = sys.argv[2] ) -except: - c = Crate() -try: - if len( sys.argv ) == 1: + if not options.egg_name: c.resolve() # Only fetch eggs required by the config - elif sys.argv[1] == 'all': + elif options.egg_name == 'all': c.resolve( all=True ) # Fetch everything else: # Fetch a specific egg - name = sys.argv[1] + name = options.egg_name try: egg = c[name] except: @@ -41,12 +41,15 @@ dist = egg.resolve()[0] print "%s %s is installed at %s" % ( dist.project_name, dist.version, dist.location ) except EggNotFetchable, e: + config_arg = '' + if options.config != 'universe_wsgi.ini': + config_arg = '-c %s ' % options.config try: - assert sys.argv[1] != 'all' + assert options.egg_name != 'all' egg = e.eggs[0] print "%s %s couldn't be downloaded automatically. You can try" % ( egg.name, egg.version ) print "building it by hand with:" - print " python scripts/scramble.py %s" + print " python scripts/scramble.py %s-e %s" % ( config_arg, egg.name ) except ( AssertionError, IndexError ): print "One or more of the python eggs necessary to run Galaxy couldn't be" print "downloaded automatically. You can try building them by hand (all" @@ -54,6 +57,6 @@ print " python scripts/scramble.py" print "Or individually:" for egg in e.eggs: - print " python scripts/scramble.py %s" % egg.name + print " python scripts/scramble.py %s-e %s" % ( config_arg, egg.name ) sys.exit( 1 ) sys.exit( 0 ) --- a/scripts/manage_db.py Wed Jun 08 11:52:42 2011 -0400 +++ b/scripts/manage_db.py Wed Jun 08 12:10:51 2011 -0400 @@ -21,7 +21,15 @@ config_file = 'community_wsgi.ini' repo = 'lib/galaxy/webapps/community/model/migrate' else: + # Poor man's optparse config_file = 'universe_wsgi.ini' + if '-c' in sys.argv: + pos = sys.argv.index( '-c' ) + sys.argv.pop(pos) + config_file = sys.argv.pop( pos ) + if not os.path.exists( config_file ): + print "Galaxy config file does not exist (hint: use '-c config.ini' for non-standard locations): %s" % config_file + sys.exit( 1 ) repo = 'lib/galaxy/model/migrate' cp = SafeConfigParser() --- a/scripts/scramble.py Wed Jun 08 11:52:42 2011 -0400 +++ b/scripts/scramble.py Wed Jun 08 12:10:51 2011 -0400 @@ -1,11 +1,14 @@ -""" -usage: scramble.py [egg_name] - With no arguments, scrambles all eggs necessary according to the - settings in universe_wsgi.ini. - egg_name - Scramble only this egg (as defined in eggs.ini) or 'all' - for all eggs (even those not required by your settings). -""" import os, sys, logging +from optparse import OptionParser + +parser = OptionParser() +parser.add_option( '-c', '--config', dest='config', help='Path to Galaxy config file (universe_wsgi.ini)', default='universe_wsgi.ini' ) +parser.add_option( '-e', '--egg-name', dest='egg_name', help='Egg name (as defined in eggs.ini) to fetch, or "all" for all eggs, even those not needed by your configuration' ) +( options, args ) = parser.parse_args() + +if not os.path.exists( options.config ): + print "Config file does not exist (see 'python %s --help'): %s" % ( sys.argv[0], options.config ) + sys.exit( 1 ) root = logging.getLogger() root.setLevel( 10 ) @@ -16,22 +19,25 @@ from galaxy.eggs.scramble import ScrambleCrate, ScrambleFailure, EggNotFetchable -c = ScrambleCrate() +c = ScrambleCrate( options.config ) try: - if len( sys.argv ) == 1: + if not options.egg_name: eggs = c.scramble() - elif sys.argv[1] == 'all': + elif options.egg_name == 'all': c.scramble( all=True ) else: # Scramble a specific egg - name = sys.argv[1] + name = options.egg_name try: egg = c[name] except: print "error: %s not in eggs.ini" % name sys.exit( 1 ) for dependency in egg.dependencies: + config_arg = '' + if options.config != 'universe_wsgi.ini': + config_arg = '-c %s' % options.config print "Checking %s dependency: %s" % ( egg.name, dependency ) try: c[dependency].require() @@ -39,7 +45,7 @@ degg = e.eggs[0] print "%s build dependency %s %s couldn't be downloaded" % ( egg.name, degg.name, degg.version ) print "automatically. You can try building it by hand with:" - print " python scripts/scramble.py %s" % degg.name + print " python scripts/scramble.py %s-e %s" % ( config_agr, degg.name ) sys.exit( 1 ) egg.scramble() sys.exit( 0 ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.