commit/galaxy-central: jmchilton: Merge latest next-stable.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/5cda4ac27e0a/ Changeset: 5cda4ac27e0a User: jmchilton Date: 2014-09-22 23:33:42+00:00 Summary: Merge latest next-stable. Affected #: 5 files diff -r f89efbcfd102b4aab4ffe29285348e3ee6a02cca -r 5cda4ac27e0a3c7b688e479a593698bfb3f0deb8 .hgtags --- a/.hgtags +++ b/.hgtags @@ -18,4 +18,4 @@ 81fbe25bd02edcd53065e8e4476dd1dfb5a72cf2 latest_2013.11.04 2a756ca2cb1826db7796018e77d12e2dd7b67603 latest_2014.02.10 ca45b78adb4152fc6e7395514d46eba6b7d0b838 release_2014.08.11 -21f2a42a06d7d2b8c408aed22c691f5e8b209311 latest_2014.08.11 +9f495158c5ba45fcf61fc37d82aa8545eaba0bd5 latest_2014.08.11 diff -r f89efbcfd102b4aab4ffe29285348e3ee6a02cca -r 5cda4ac27e0a3c7b688e479a593698bfb3f0deb8 lib/galaxy/config.py --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -13,6 +13,7 @@ import ConfigParser from datetime import timedelta from galaxy.web.formatting import expand_pretty_datetime_format +from galaxy.util.properties import load_app_properties from galaxy.util import string_as_bool from galaxy.util import listify from galaxy.util.dbkeys import GenomeBuilds @@ -20,9 +21,6 @@ log = logging.getLogger( __name__ ) -CONFIG_DEFAULT_PREFIX = "GALAXY_CONFIG_" -CONFIG_OVERRIDE_PREFIX = "GALAXY_CONFIG_OVERRIDE_" - def resolve_path( path, root ): """If 'path' is relative make absolute by prepending 'root'""" @@ -39,15 +37,9 @@ deprecated_options = ( 'database_file', ) def __init__( self, **kwargs ): - for key in os.environ: - if key.startswith( CONFIG_OVERRIDE_PREFIX ): - config_key = key[ len( CONFIG_OVERRIDE_PREFIX ): ].lower() - kwargs[ config_key ] = os.environ[ key ] - elif key.startswith( CONFIG_DEFAULT_PREFIX ): - config_key = key[ len( CONFIG_DEFAULT_PREFIX ): ].lower() - if config_key not in kwargs: - kwargs[ config_key ] = os.environ[ key ] - + kwargs = load_app_properties( + kwds=kwargs + ) self.config_dict = kwargs self.root = kwargs.get( 'root_dir', '.' ) diff -r f89efbcfd102b4aab4ffe29285348e3ee6a02cca -r 5cda4ac27e0a3c7b688e479a593698bfb3f0deb8 lib/galaxy/model/orm/scripts.py --- a/lib/galaxy/model/orm/scripts.py +++ b/lib/galaxy/model/orm/scripts.py @@ -3,7 +3,6 @@ """ import logging import os.path -from ConfigParser import SafeConfigParser from galaxy import eggs @@ -12,6 +11,7 @@ eggs.require( "SQLAlchemy" ) eggs.require( "sqlalchemy_migrate" ) +from galaxy.util.properties import load_app_properties from galaxy.model.orm import dialect_to_egg import pkg_resources @@ -112,13 +112,13 @@ if cwd: config_file = os.path.join( cwd, config_file ) - cp = SafeConfigParser() - cp.read( config_file ) + properties = load_app_properties( ini_file=config_file ) - if cp.has_option( "app:main", "%sdatabase_connection" % config_prefix): - db_url = cp.get( "app:main", "%sdatabase_connection" % config_prefix ) - elif cp.has_option( "app:main", "%sdatabase_file" % config_prefix ): - db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % cp.get( "app:main", "database_file" ) + if ("%sdatabase_connection" % config_prefix) in properties: + db_url = properties[ "%sdatabase_connection" % config_prefix ] + elif ("%sdatabase_file" % config_prefix) in properties: + database_file = properties[ "%sdatabase_file" % config_prefix ] + db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % database_file else: db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % default_sqlite_file diff -r f89efbcfd102b4aab4ffe29285348e3ee6a02cca -r 5cda4ac27e0a3c7b688e479a593698bfb3f0deb8 lib/galaxy/util/properties.py --- /dev/null +++ b/lib/galaxy/util/properties.py @@ -0,0 +1,41 @@ +""" Module used to blend ini, environment, and explicit dictionary properties +to determine application configuration. Some hard coded defaults for Galaxy but +this should be reusable by tool shed and pulsar as well. +""" +import os +import os.path + + +def load_app_properties( + kwds={}, + ini_file=None, + ini_section="app:main", + config_prefix="GALAXY_CONFIG_" +): + properties = kwds.copy() if kwds else {} + if ini_file: + defaults = { + 'here': os.path.dirname(os.path.abspath(ini_file)), + '__file__': os.path.abspath(ini_file) + } + # Mimic the way loadwsgi loads configuration files - needed for + # correctness given the very specific ways interpolation is handled. + from galaxy.util.pastescript.loadwsgi import NicerConfigParser + parser = NicerConfigParser(ini_file, defaults=defaults) + parser.optionxform = str # Don't lower-case keys + with open(ini_file) as f: + parser.read_file(f) + + properties.update( dict( parser.items( ini_section ) ) ) + + override_prefix = "%sOVERRIDE_" % config_prefix + for key in os.environ: + if key.startswith( override_prefix ): + config_key = key[ len( override_prefix ): ].lower() + properties[ config_key ] = os.environ[ key ] + elif key.startswith( config_prefix ): + config_key = key[ len( config_prefix ): ].lower() + if config_key not in properties: + properties[ config_key ] = os.environ[ key ] + + return properties 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.
participants (1)
-
commits-noreply@bitbucket.org