import sys sys.path.insert(1,'/galaxy-central') sys.path.insert(1,'/galaxy-central/lib') from scripts.db_shell import * from galaxy.util.bunch import Bunch from galaxy.security import GalaxyRBACAgent from sqlalchemy.orm import sessionmaker from sqlalchemy import * import argparse bunch = Bunch( **globals() ) engine = create_engine('postgres://*****:*****@localhost:5432/galaxy') bunch.session = sessionmaker(bind=engine) # For backward compatibility with "model.context.current" bunch.context = sessionmaker(bind=engine) security_agent = GalaxyRBACAgent( bunch ) security_agent.sa_session = sa_session def add_user(email, password, key=None): """ Add Galaxy User. From John https://gist.github.com/jmchilton/4475646 """ query = sa_session.query( User ).filter_by( email=email ) if query.count() > 0: return query.first() else: User.use_pbkdf2 = False user = User(email)
# FROM https://github.com/bgruening/docker-galaxy-stable/blob/master/galaxy/create_galaxy_user.py from scripts.db_shell import * from galaxy.util.bunch import Bunch from galaxy.security import GalaxyRBACAgent from sqlalchemy.orm import sessionmaker from sqlalchemy import * import argparse bunch = Bunch(**globals()) #engine = create_engine('postgres://*****:*****@localhost:5432/galaxy') engine = create_engine( 'sqlite:///home/vagrant/galaxy/database/universe.sqlite') bunch.session = sessionmaker(bind=engine) # For backward compatibility with "model.context.current" bunch.context = sessionmaker(bind=engine) security_agent = GalaxyRBACAgent(bunch) security_agent.sa_session = sa_session def add_user(email, password, key=None): """ Add Galaxy User. From John https://gist.github.com/jmchilton/4475646 """ query = sa_session.query(User).filter_by(email=email) if query.count() > 0: return query.first() else: user = User(email) user.set_password_cleartext(password) sa_session.add(user)