mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-19 10:51:34 +08:00
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).
This commit is contained in:
+1
-1
@@ -29,7 +29,7 @@ class UniverseApplication( object ):
|
||||
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,
|
||||
|
||||
@@ -247,7 +247,7 @@ class Crate( object ):
|
||||
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 @@ class Crate( object ):
|
||||
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 @@ class Crate( object ):
|
||||
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 @@ class GalaxyConfig( object ):
|
||||
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 @@ def get_env():
|
||||
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.
|
||||
|
||||
@@ -39,10 +39,10 @@ class DistScrambleCrate( ScrambleCrate ):
|
||||
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' ) )
|
||||
|
||||
@@ -20,7 +20,7 @@ dialect_to_egg = {
|
||||
"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 @@ def create_or_verify_database( url, engine_options={} ):
|
||||
# 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 @@ def migrate_to_current_version( engine, schema ):
|
||||
finally:
|
||||
for message in "".join( sys.stdout.buffer ).split( "\n" ):
|
||||
log.info( message )
|
||||
sys.stdout = old_stdout
|
||||
sys.stdout = old_stdout
|
||||
|
||||
@@ -32,7 +32,7 @@ for arg in "$@"; do
|
||||
[ "$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
|
||||
|
||||
+17
-9
@@ -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 )
|
||||
|
||||
+15
-14
@@ -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 @@ sys.path.append( lib )
|
||||
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:
|
||||
|
||||
+24
-21
@@ -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 @@ sys.path.append( lib )
|
||||
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 @@ try:
|
||||
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 @@ except EggNotFetchable, e:
|
||||
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 )
|
||||
|
||||
@@ -21,7 +21,15 @@ if sys.argv[-1] in [ 'community' ]:
|
||||
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()
|
||||
|
||||
+18
-12
@@ -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 @@ sys.path.append( lib )
|
||||
|
||||
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 @@ try:
|
||||
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 )
|
||||
|
||||
Reference in New Issue
Block a user