commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/1830e34c80c0/ Changeset: 1830e34c80c0 Branch: next-stable User: davebgx Date: 2014-05-22 16:59:18 Summary: Enable running the create_users and create_categories scripts via run_tool_shed.sh Affected #: 7 files diff -r f0a5e3666e844d907e7ef3c7fc4e23a443ba65d1 -r 1830e34c80c086696f83383871b6027f3b44ea8b lib/tool_shed/scripts/bootstrap_tool_shed/bootstrap_tool_shed.sh --- /dev/null +++ b/lib/tool_shed/scripts/bootstrap_tool_shed/bootstrap_tool_shed.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +stop_err() { + echo $1 + python ./scripts/paster.py serve tool_shed_wsgi.ini --pid-file=tool_shed_bootstrap.pid --log-file=tool_shed_bootstrap.log --stop-daemon + exit 1 +} + +tool_shed=`./lib/tool_shed/scripts/bootstrap_tool_shed/parse_run_sh_args.sh $@` + +if [ $? -ne 0 ] ; then + exit 0 +fi + +log_file="lib/tool_shed/scripts/bootstrap_tool_shed/bootstrap.log" + +database_result=`python ./lib/tool_shed/scripts/bootstrap_tool_shed/bootstrap_util.py --execute check_db --config_file tool_shed_wsgi.ini` + +if [ $? -ne 0 ] ; then + stop_err "Unable to bootstrap tool shed. $database_result" +fi + +echo "Bootstrapping from tool shed at $tool_shed." +echo -n "Creating database... " +python scripts/create_db.py tool_shed + +if [ $? -eq 0 ] ; then + echo "done." +else + stop_err "failed." +fi + +if [ $? -eq 0 ] ; then + user_auth=`python ./lib/tool_shed/scripts/bootstrap_tool_shed/bootstrap_util.py --execute admin_user_info --config_file tool_shed_wsgi.ini` + local_shed_url=`python ./lib/tool_shed/scripts/bootstrap_tool_shed/bootstrap_util.py --execute get_url --config_file tool_shed_wsgi.ini` +fi + +admin_user_name=`echo $user_auth | awk 'BEGIN { FS="__SEP__" } ; { print \$1 }'` +admin_user_email=`echo $user_auth | awk 'BEGIN { FS="__SEP__" } ; { print \$2 }'` +admin_user_password=`echo $user_auth | awk 'BEGIN { FS="__SEP__" } ; { print \$3 }'` + +echo -n "Creating user '$admin_user_name' with email address '$admin_user_email'..." + +python lib/tool_shed/scripts/bootstrap_tool_shed/create_user_with_api_key.py tool_shed_wsgi.ini >> $log_file + +echo " done." + +sed -i "s/#admin_users = user1@example.org,user2@example.org/admin_users = $admin_user_email/" tool_shed_wsgi.ini +echo -n "Starting tool shed in order to populate users and categories... " + +if [ -f tool_shed_bootstrap.pid ] ; then + stop_err "A bootstrap process is already running." +fi + +python ./scripts/paster.py serve tool_shed_wsgi.ini --pid-file=tool_shed_bootstrap.pid --log-file=tool_shed_bootstrap.log --daemon > /dev/null + +shed_pid=`cat tool_shed_bootstrap.pid` + +while : ; do + tail -n 1 tool_shed_bootstrap.log | grep -q "Removing PID file tool_shed_webapp.pid" + if [ $? -eq 0 ] ; then + echo "failed." + echo "More information about this failure may be found in the following log snippet from tool_shed_bootstrap.log:" + echo "========================================" + tail -n 40 tool_shed_bootstrap.log + echo "========================================" + stop_err " " + fi + tail -n 2 tool_shed_bootstrap.log | grep -q "Starting server in PID $shed_pid" + if [ $? -eq 0 ] ; then + echo "done." + break + fi +done + +echo -n "Retrieving admin user's API key..." +api_key_json=`curl -s --user $admin_user_email:$admin_user_password $local_shed_url/api/authenticate/baseauth/` +api_key=`echo $api_key_json | grep api_key | awk 'BEGIN { FS="\"" } ; { print \$4 }' | sed 's/\\s\+//'` + +if [[ -z $api_key && ${api_key+x} ]] ; then + stop_err "Error getting API key for user $admin_user_email." +fi + +echo " done." + +if [ $? -eq 0 ] ; then + echo -n "Creating users... " + python lib/tool_shed/scripts/api/create_users.py -a $api_key -f $tool_shed -t $local_shed_url >> $log_file + echo "done." + echo -n "Creating categories... " + python lib/tool_shed/scripts/api/create_categories.py -a $api_key -f $tool_shed -t $local_shed_url >> $log_file + echo "done." +else + stop_err "Error getting API key from local tool shed." +fi + +echo "Bootstrap complete, shutting down temporary tool shed process. A log has been saved to tool_shed_bootstrap.log" +python ./scripts/paster.py serve tool_shed_wsgi.ini --pid-file=tool_shed_bootstrap.pid --log-file=tool_shed_bootstrap.log --stop-daemon + +exit 0 \ No newline at end of file diff -r f0a5e3666e844d907e7ef3c7fc4e23a443ba65d1 -r 1830e34c80c086696f83383871b6027f3b44ea8b lib/tool_shed/scripts/bootstrap_tool_shed/bootstrap_util.py --- /dev/null +++ b/lib/tool_shed/scripts/bootstrap_tool_shed/bootstrap_util.py @@ -0,0 +1,130 @@ +#!/usr/bin/python +import argparse +import ConfigParser +import os +import sys + +new_path = [ os.path.join( os.getcwd(), "lib" ) ] +new_path.extend( sys.path[1:] ) +sys.path = new_path + +from galaxy import eggs +eggs.require( "SQLAlchemy >= 0.4" ) +import galaxy.webapps.tool_shed.model.mapping as tool_shed_model +from sqlalchemy.exc import ProgrammingError +from sqlalchemy.exc import OperationalError + +from tool_shed.util import xml_util + +def check_db( config_parser ): + dburi = None + + if config_parser.has_option( 'app:main', 'database_connection' ): + dburi = config_parser.get( 'app:main', 'database_connection' ) + elif config_parser.has_option( 'app:main', 'database_file' ): + db_file = config_parser.get( 'app:main', 'database_file' ) + dburi = "sqlite:///%s?isolation_level=IMMEDIATE" % db_file + else: + print 'The database configuration setting is missing from the tool_shed_wsgi.ini file. Add this setting before attempting to bootstrap.' + exit(1) + + sa_session = None + + database_exists_message = 'The database configured for this Tool Shed is not new, so bootstrapping is not allowed. ' + database_exists_message += 'Create a new database that has not been migrated before attempting to bootstrap.' + + try: + model = tool_shed_model.init( config_parser.get( 'app:main', 'file_path' ), dburi, engine_options={}, create_tables=False ) + sa_session = model.context.current + print database_exists_message + exit(1) + except ProgrammingError, e: + pass + except OperationalError, e: + pass + + try: + if sa_session is not None: + result = sa_session.execute( 'SELECT version FROM migrate_version' ).first() + if result[0] >= 2: + print database_exists_message + exit(1) + else: + pass + except ProgrammingError, e: + pass + + if config_parser.has_option( 'app:main', 'hgweb_config_dir' ): + hgweb_config_parser = ConfigParser.ConfigParser() + hgweb_dir = config_parser.get( 'app:main', 'hgweb_config_dir' ) + hgweb_config_file = os.path.join( hgweb_dir, 'hgweb.config' ) + if not os.path.exists( hgweb_config_file ): + exit(0) + hgweb_config_parser.read( hgweb_config_file ) + configured_repos = hgweb_config_parser.items( 'paths' ) + if len( configured_repos ) >= 1: + message = "This Tool Shed's hgweb.config file contains entries, so bootstrapping is not allowed. Delete" + message += " the current hgweb.config file along with all associated repositories in the configured " + message += "location before attempting to boostrap." + print + exit(1) + else: + exit(0) + else: + exit(0) + + exit(0) + +def admin_user_info( config_parser ): + user_info_config = os.path.abspath( os.path.join( os.getcwd(), 'lib/tool_shed/scripts/bootstrap_tool_shed', 'user_info.xml' ) ) + tree, error_message = xml_util.parse_xml( user_info_config ) + if tree is None: + print "The XML file ", user_info_config, " seems to be invalid, using defaults." + email = 'admin@test.org' + password = 'testuser' + username = 'admin' + else: + root = tree.getroot() + for elem in root: + if elem.tag == 'email': + email = elem.text + elif elem.tag == 'password': + password = elem.text + elif elem.tag == 'username': + username = elem.text + print '%s__SEP__%s__SEP__%s' % ( username, email, password ) + return 0 + +def get_local_tool_shed_url( config_parser ): + port = '9009' + if config_parser.has_section( 'server:main' ): + if config_parser.has_option( 'server:main', 'port' ): + port = config_parser.get( 'server:main', 'port' ) + host = '127.0.0.1' + print 'http://%s:%s' % ( host, port ) + return 0 + +def main( args ): + config_parser = ConfigParser.ConfigParser() + + if os.path.exists( args.config ): + config_parser.read( args.config ) + else: + return 1 + + if args.method == 'check_db': + return check_db( config_parser ) + elif args.method == 'admin_user_info': + return admin_user_info( config_parser ) + elif args.method == 'get_url': + return get_local_tool_shed_url( config_parser ) + else: + return 1 + +parser = argparse.ArgumentParser() +parser.add_argument( '-c', '--config_file', dest='config', action='store', default='tool_shed_wsgi.ini' ) +parser.add_argument( '-e', '--execute', dest='method', action='store', default='check_db' ) +args = parser.parse_args() + +if __name__ == '__main__': + exit( main( args ) ) \ No newline at end of file diff -r f0a5e3666e844d907e7ef3c7fc4e23a443ba65d1 -r 1830e34c80c086696f83383871b6027f3b44ea8b lib/tool_shed/scripts/bootstrap_tool_shed/create_user_with_api_key.py --- a/lib/tool_shed/scripts/bootstrap_tool_shed/create_user_with_api_key.py +++ b/lib/tool_shed/scripts/bootstrap_tool_shed/create_user_with_api_key.py @@ -125,7 +125,7 @@ return '' def validate_publicname( username ): - """""Validates the public username.""" + """Validates the public username.""" if len( username ) < 3: return "Public name must be at least 3 characters in length" if len( username ) > 255: @@ -154,5 +154,7 @@ if user is not None: api_key = create_api_key( app, user ) print "Created new user with public username '", user.username, ". An API key was also created and associated with the user." + exit(0) else: print "Problem creating a new user and an associated API key." + exit(1) diff -r f0a5e3666e844d907e7ef3c7fc4e23a443ba65d1 -r 1830e34c80c086696f83383871b6027f3b44ea8b lib/tool_shed/scripts/bootstrap_tool_shed/parse_run_sh_args.sh --- /dev/null +++ b/lib/tool_shed/scripts/bootstrap_tool_shed/parse_run_sh_args.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +while (( $# )) ; do + case "$1" in + -bootstrap_from_tool_shed|--bootstrap_from_tool_shed) + bootstrap="true" + tool_shed=$2 + echo $tool_shed + exit 0 + break + ;; + esac + shift 1 +done +exit 1 \ No newline at end of file diff -r f0a5e3666e844d907e7ef3c7fc4e23a443ba65d1 -r 1830e34c80c086696f83383871b6027f3b44ea8b run.sh --- a/run.sh +++ b/run.sh @@ -5,41 +5,7 @@ python ./scripts/check_python.py [ $? -ne 0 ] && exit 1 -SAMPLES=" - community_wsgi.ini.sample - datatypes_conf.xml.sample - external_service_types_conf.xml.sample - migrated_tools_conf.xml.sample - reports_wsgi.ini.sample - shed_tool_conf.xml.sample - tool_conf.xml.sample - shed_tool_data_table_conf.xml.sample - tool_data_table_conf.xml.sample - tool_sheds_conf.xml.sample - data_manager_conf.xml.sample - shed_data_manager_conf.xml.sample - openid_conf.xml.sample - job_metrics_conf.xml.sample - universe_wsgi.ini.sample - tool-data/shared/ncbi/builds.txt.sample - tool-data/shared/ensembl/builds.txt.sample - tool-data/shared/ucsc/builds.txt.sample - tool-data/shared/ucsc/publicbuilds.txt.sample - tool-data/shared/ucsc/ucsc_build_sites.txt.sample - tool-data/shared/igv/igv_build_sites.txt.sample - tool-data/shared/rviewer/rviewer_build_sites.txt.sample - tool-data/*.sample - static/welcome.html.sample -" - -# Create any missing config/location files -for sample in $SAMPLES; do - file=`echo $sample | sed -e 's/\.sample$//'` - if [ ! -f "$file" -a -f "$sample" ]; then - echo "Initializing $file from `basename $sample`" - cp $sample $file - fi -done +./scripts/copy_sample_files.sh if [ -n "$GALAXY_UNIVERSE_CONFIG_DIR" ]; then python ./scripts/build_universe_config.py "$GALAXY_UNIVERSE_CONFIG_DIR" diff -r f0a5e3666e844d907e7ef3c7fc4e23a443ba65d1 -r 1830e34c80c086696f83383871b6027f3b44ea8b run_tool_shed.sh --- a/run_tool_shed.sh +++ b/run_tool_shed.sh @@ -2,37 +2,14 @@ cd `dirname $0` -SAMPLES=" - tool_shed_wsgi.ini.sample - datatypes_conf.xml.sample - external_service_types_conf.xml.sample - migrated_tools_conf.xml.sample - reports_wsgi.ini.sample - shed_tool_conf.xml.sample - tool_conf.xml.sample - shed_tool_data_table_conf.xml.sample - tool_data_table_conf.xml.sample - tool_sheds_conf.xml.sample - openid_conf.xml.sample - universe_wsgi.ini.sample - lib/tool_shed/scripts/bootstrap_tool_shed/user_info.xml.sample - tool-data/shared/ncbi/builds.txt.sample - tool-data/shared/ensembl/builds.txt.sample - tool-data/shared/ucsc/builds.txt.sample - tool-data/shared/ucsc/publicbuilds.txt.sample - tool-data/shared/igv/igv_build_sites.txt.sample - tool-data/shared/rviewer/rviewer_build_sites.txt.sample - tool-data/*.sample - static/welcome.html.sample -" +./scripts/copy_sample_files.sh -# Create any missing config/location files -for sample in $SAMPLES; do - file=`echo $sample | sed -e 's/\.sample$//'` - if [ ! -f "$file" -a -f "$sample" ]; then - echo "Initializing $file from `basename $sample`" - cp $sample $file - fi -done +tool_shed=`./lib/tool_shed/scripts/bootstrap_tool_shed/parse_run_sh_args.sh $@` +args=$@ -python ./scripts/paster.py serve tool_shed_wsgi.ini --pid-file=tool_shed_webapp.pid --log-file=tool_shed_webapp.log $@ +if [ $? -eq 0 ] ; then + bash ./lib/tool_shed/scripts/bootstrap_tool_shed/bootstrap_tool_shed.sh $@ + args=`echo $@ | sed "s#-\?-bootstrap_from_tool_shed $tool_shed##"` +fi + +python ./scripts/paster.py serve tool_shed_wsgi.ini --pid-file=tool_shed_webapp.pid --log-file=tool_shed_webapp.log $args diff -r f0a5e3666e844d907e7ef3c7fc4e23a443ba65d1 -r 1830e34c80c086696f83383871b6027f3b44ea8b scripts/copy_sample_files.sh --- /dev/null +++ b/scripts/copy_sample_files.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +SAMPLES=" + tool_shed_wsgi.ini.sample + datatypes_conf.xml.sample + external_service_types_conf.xml.sample + migrated_tools_conf.xml.sample + reports_wsgi.ini.sample + shed_tool_conf.xml.sample + tool_conf.xml.sample + shed_tool_data_table_conf.xml.sample + tool_data_table_conf.xml.sample + tool_sheds_conf.xml.sample + data_manager_conf.xml.sample + shed_data_manager_conf.xml.sample + openid_conf.xml.sample + job_metrics_conf.xml.sample + universe_wsgi.ini.sample + lib/tool_shed/scripts/bootstrap_tool_shed/user_info.xml.sample + tool-data/shared/ncbi/builds.txt.sample + tool-data/shared/ensembl/builds.txt.sample + tool-data/shared/ucsc/builds.txt.sample + tool-data/shared/ucsc/publicbuilds.txt.sample + tool-data/shared/ucsc/ucsc_build_sites.txt.sample + tool-data/shared/igv/igv_build_sites.txt.sample + tool-data/shared/rviewer/rviewer_build_sites.txt.sample + tool-data/*.sample + static/welcome.html.sample +" + +# Create any missing config/location files +for sample in $SAMPLES; do + file=${sample%.sample} + if [ ! -f "$file" -a -f "$sample" ]; then + echo "Initializing $file from `basename $sample`" + cp $sample $file + fi +done + https://bitbucket.org/galaxy/galaxy-central/commits/e959799971fc/ Changeset: e959799971fc User: davebgx Date: 2014-05-22 18:41:13 Summary: Merge next-stable. Affected #: 0 files 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