def invoke_migrate_main(): # Migrate has its own args, so cannot use argparse config = get_config(sys.argv, use_argparse=False) db_url = config['db_url'] repo = config['repo'] main(repository=repo, url=db_url)
def invoke_create(): config = get_config(sys.argv) if config['database'] == 'galaxy': create_db(config['db_url'], config['config_file']) elif config['database'] == 'tool_shed': create_tool_shed_db(config['db_url']) elif config['database'] == 'install': create_install_db(config['db_url'])
def invoke_create(): config = get_config(sys.argv) if config["database"] == "galaxy": create_db(config["db_url"], config["config_file"]) elif config["database"] == "tool_shed": create_tool_shed_db(config["db_url"]) elif config["database"] == "install": create_install_db(config["db_url"])
def delete_galaxy_user(): db_url = get_config(sys.argv, use_argparse=False)['db_url'] options = cli_options() mapping = init('/tmp/', db_url) sa_session = mapping.context security_agent = mapping.security_agent delete_user(sa_session, security_agent, options.user)
def main(): ini_file = sys.argv.pop(1) config = get_config(ini_file) model = mapping.init( ini_file, config['db_url'], create_tables = False ) for row in model.context.query( model.Dataset ): if row.uuid is None: row.uuid = uuid.uuid4() print "Setting dataset:", row.id, " UUID to ", row.uuid model.context.flush()
def main(): ini_file = sys.argv.pop(1) config = get_config(ini_file) model = mapping.init(ini_file, config['db_url'], create_tables=False) for row in model.context.query(model.Dataset): if row.uuid is None: row.uuid = uuid.uuid4() print "Setting dataset:", row.id, " UUID to ", row.uuid model.context.flush()
def manage_galaxy_bootstrap_user(): db_url = get_config(sys.argv, use_argparse=False)['db_url'] options = cli_options() mapping = init('/tmp/', db_url) sa_session = mapping.context security_agent = mapping.security_agent if options.action == "create": add_user(sa_session, security_agent, options.user, options.password, key=options.key, username=options.username) elif options.action == "delete": delete_user(sa_session, security_agent, options.user)
def main(): if len(sys.argv) != 2 or sys.argv == "-h" or sys.argv == "--help": usage(sys.argv[0]) sys.exit() ini_file = sys.argv.pop(1) config = get_config(ini_file) model = mapping.init( ini_file, config['db_url'], create_tables=False ) for row in model.context.query( model.Dataset ): if row.uuid is None: row.uuid = uuid.uuid4() print("Setting dataset:", row.id, " UUID to ", row.uuid) model.context.flush() for row in model.context.query( model.Workflow ): if row.uuid is None: row.uuid = uuid.uuid4() print("Setting Workflow:", row.id, " UUID to ", row.uuid) model.context.flush()
def find_missing_indexes(): def load_indexes(metadata): indexes = {} for t in metadata.tables.values(): for index in t.indexes: index_tuple = tuple_from_index(index) indexes[index_tuple] = index.name return indexes # load metadata from mapping.py metadata = mapping.metadata mapping_indexes = load_indexes(metadata) # create EMPTY metadata, then load from database db_url = get_config(sys.argv)['db_url'] metadata = MetaData(bind=create_engine(db_url)) metadata.reflect() indexes_in_db = load_indexes(metadata) missing_indexes = set(mapping_indexes.keys()) - set(indexes_in_db.keys()) if missing_indexes: return [(mapping_indexes[index], index.table, index.column_names) for index in missing_indexes]
def invoke_migrate_main(): config = get_config(sys.argv) db_url = config['db_url'] repo = config['repo'] main(repository=repo, url=db_url)
def invoke_migrate_main(): config = get_config( sys.argv ) db_url = config['db_url'] repo = config['repo'] main( repository=repo, url=db_url )
if not user.default_permissions: security_agent.user_set_default_permissions(user, history=True, dataset=True) if key is not None: api_key = APIKeys() api_key.user_id = user.id api_key.key = key sa_session.add(api_key) sa_session.flush() return user if __name__ == "__main__": db_url = get_config(sys.argv, use_argparse=False)['db_url'] parser = argparse.ArgumentParser(description='Create Galaxy Admin User.') parser.add_argument("--user", required=True, help="Username, it should be an email address.") parser.add_argument("--password", required=True, help="Password.") parser.add_argument("--key", help="API-Key.") parser.add_argument( "--username", default="admin", help= "The public username. Public names must be at least three characters in length and contain only lower-case letters, numbers, and the '-' character." ) parser.add_argument('args', nargs=argparse.REMAINDER)
1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'lib'))) from galaxy.datatypes.registry import Registry from galaxy.model import * # noqa from galaxy.model import set_datatypes_registry # More explicit than `*` import from galaxy.model.mapping import init from galaxy.model.orm.scripts import get_config if sys.version_info > (3, ): long = int registry = Registry() registry.load_datatypes() set_datatypes_registry(registry) db_url = get_config(sys.argv)['db_url'] sa_session = init('/tmp/', db_url).context # Helper function for debugging sqlalchemy queries... # http://stackoverflow.com/questions/5631078/sqlalchemy-print-the-actual-query def printquery(statement, bind=None): """ Print a query, with values filled in for debugging purposes *only* for security, you should always separate queries from their values please also note that this function is quite slow """ import sqlalchemy.orm if isinstance(statement, sqlalchemy.orm.Query): if bind is None:
from flask import Flask, request, make_response, current_app, send_file from flask_socketio import SocketIO, emit, disconnect, join_room, leave_room import flask.ext.login as flask_login from flask.ext.login import current_user from datetime import timedelta from functools import update_wrapper from galaxy.model.orm.scripts import get_config from galaxy.model import mapping from galaxy.util.properties import load_app_properties from galaxy.web.security import SecurityHelper from galaxy.util.sanitize_html import sanitize_html # Get config file and load up SA session config = get_config( sys.argv ) model = mapping.init( '/tmp/', config['db_url'] ) sa_session = model.context.current # With the config file we can load the full app properties app_properties = load_app_properties(ini_file=config['config_file']) # We need the ID secret for configuring the security helper to decrypt # galaxysession cookies. if "id_secret" not in app_properties: log.warn('No ID_SECRET specified. Please set the "id_secret" in your galaxy.ini.') id_secret = app_properties.get('id_secret', 'dangerous_default') security_helper = SecurityHelper(id_secret=id_secret) # And get access to the models
from sqlalchemy.sql import label # noqa sys.path.insert( 1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'lib'))) from galaxy.datatypes.registry import Registry from galaxy.model import * # noqa from galaxy.model import set_datatypes_registry # More explicit than `*` import from galaxy.model.mapping import init from galaxy.model.orm.scripts import get_config registry = Registry() registry.load_datatypes() set_datatypes_registry(registry) config = get_config(sys.argv) db_url = config['db_url'] sa_session = init('/tmp/', db_url).context # Helper function for debugging sqlalchemy queries... # http://stackoverflow.com/questions/5631078/sqlalchemy-print-the-actual-query def printquery(statement, bind=None): """ Print a query, with values filled in for debugging purposes *only* for security, you should always separate queries from their values please also note that this function is quite slow """ import sqlalchemy.orm if isinstance(statement, sqlalchemy.orm.Query):
# # You can also use this script as a library, for instance see https://gist.github.com/1979583 # TODO: This script overlaps a lot with manage_db.py and create_db.py, # these should maybe be refactored to remove duplication. import sys import os.path db_shell_path = __file__ new_path = [ os.path.join( os.path.dirname( db_shell_path ), os.path.pardir, "lib" ) ] new_path.extend( sys.path[1:] ) # remove scripts/ from the path sys.path = new_path from galaxy.model.orm.scripts import get_config from galaxy import eggs eggs.require( "decorator" ) eggs.require( "Tempita" ) eggs.require( "SQLAlchemy" ) db_url = get_config( sys.argv )['db_url'] # Setup DB scripting environment from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.exc import * from galaxy.model.mapping import init sa_session = init( '/tmp/', db_url ).context from galaxy.model import *
# TODO: This script overlaps a lot with manage_db.py and create_db.py, # these should maybe be refactored to remove duplication. import datetime import decimal import os.path import sys db_shell_path = __file__ new_path = [os.path.join(os.path.dirname(db_shell_path), os.pardir, "lib")] new_path.extend(sys.path[1:]) # remove scripts/ from the path sys.path = new_path from galaxy.model.orm.scripts import get_config db_url = get_config(sys.argv)["db_url"] # Setup DB scripting environment from sqlalchemy import * # noqa from sqlalchemy.orm import * # noqa from sqlalchemy.exc import * # noqa from galaxy.model.mapping import init sa_session = init("/tmp/", db_url).context from galaxy.model import * # noqa # Helper function for debugging sqlalchemy queries... # http://stackoverflow.com/questions/5631078/sqlalchemy-print-the-actual-query