Ejemplo n.º 1
0
def build(args):
    context = {
        'dbsnp_build': args.dbsnp_build,
        'genome_build': args.genome_build,
        'prefix': args.prefix,
        'target': args.target,
    }
    context['db_name'] = '{prefix}_{dbsnp_build}_{genome_build}'.format(**context)
    context['db_user'] = '******'
    log.info(colored(pformat(context), 'blue'))

    with cd(DBSNP_HOME):
        force('createuser {db_user}'.format(**context))
        force('createdb --owner={db_user} {db_name}'.format(**context))

        target = [DBSNP_HOME] if 'core' in args.target else []
        target += [os.path.join(DBSNP_HOME, 'contrib', x) for x in set(args.target) if x != 'core']

        for src in target:
            with cd(src):
                run('pwd')
                if glob.glob('02_drop_create_table.*'):
                    context.update(src=src)
                    run('./01_fetch_data.sh        -d {dbsnp_build} -r {genome_build} {src}/data'.format(**context))
                    run('./02_drop_create_table.sh {db_name} {db_user} {src}'.format(**context))
                    run('./03_import_data.sh       {db_name} {db_user} {src} {src}/data'.format(**context))

    log.info('Done')
    log.info('To connect via psql, run:')
    log.info('')
    log.info(colored('$ psql {db_name} -U {db_user}'.format(**context), 'blue', attrs=['bold']))
    log.info('')
Ejemplo n.º 2
0
def apply_launcher_patches(launcher):
    patches = Path('patches').absolute()
    if not patches.exists():
        fail('No patches')
    apply = git.apply
    with cd(launcher):
        for p in patches.iterdir():
            print('Patching', p.absolute())
            if not p.is_file():
                fail('Patch {} is not a file. Please remove it.'.format(p.absolute()))
            if 'version.txt' == str(p.name):
                continue
            apply(str(p.absolute()))
Ejemplo n.º 3
0
def init_demo(args):
    context = {
        'db_user': args.demo_db_user,
        'db_name': args.demo_db_name,
    }
    log.info(colored(pformat(context), 'blue'))

    with cd(DBSNP_HOME):
        force('createuser {db_user}'.format(**context))
        force('createdb --owner={db_user} {db_name}'.format(**context))

        for src in [DBSNP_HOME] + glob.glob(DBSNP_HOME + '/contrib/*'):
            with cd(src):
                run('pwd')
                if glob.glob('02_drop_create_table.*'):
                    context.update(src=src)
                    run('./02_drop_create_table.sh {db_name} {db_user} {src}'.format(**context))
                    run('./03_import_data.sh       {db_name} {db_user} {src} {src}/test/data'.format(**context))

    log.info('Done')
    log.info('To connect via psql, run:')
    log.info('')
    log.info(colored('$ psql {} -U {}'.format(args.demo_db_name, args.demo_db_user), 'blue', attrs=['bold']))
    log.info('')
Ejemplo n.º 4
0
def require_folder_git(src, target, branch=None):
    if not target.exists():
        print('Cloning', src, target)
        clone = git.clone.bake(src, target)
        if branch:
            clone = clone.bake('--branch', branch, '--single-branch')
        if clone().exit_code:
            fail("Couldn't clone")
    else:
        try:
            with cd(target):
                git.pull()
                git.reset('--hard', 'HEAD')
        except sh.ErrorReturnCode:
            import traceback
            traceback.print_exc()
            shutil.rmtree(str(target))
            return require_folder_git(src, target, branch=branch)
    return target
Ejemplo n.º 5
0
def restore(args):
    context = {
        'dbsnp_build': args.dbsnp_build,
        'genome_build': args.genome_build,
        'prefix': args.prefix,
        'tag': args.tag,
    }
    context['db_src_name'] = 'dbsnp_{dbsnp_build}_{genome_build}'.format(**context)
    context['db_name'] = '{prefix}_{dbsnp_build}_{genome_build}'.format(**context)
    context['db_user'] = '******'
    log.info(colored(pformat(context), 'blue'))

    with cd(DBSNP_HOME):
        force('createuser {db_user}'.format(**context))
        run('./script/pg_restore.sh {db_src_name} {db_name} {db_user} {tag}'.format(**context))

    log.info('Done')
    log.info('To connect via psql, run:')
    log.info('')
    log.info(colored('$ psql {db_name} -U {db_user}'.format(**context), 'blue', attrs=['bold']))
    log.info('')
Ejemplo n.º 6
0
def fail_if_no_changes(downloads, version, launcher_version):
    msg = make_commit_message(launcher_version, version)
    with cd(downloads):
        last_msg = git_last_commit_message(_out=None).stdout.decode().strip()
    if msg == last_msg:
        fail("No changes, '{}' == '{}'".format(msg, last_msg))
Ejemplo n.º 7
0
def discover_launcher_version(launcher):
    with cd(launcher):
        return git_last_commit_sha(_out=None).stdout.decode().strip()
Ejemplo n.º 8
0
def upload_downloads(d, version, launcher_version):
    with cd(d):
        git.add('.')
        git.commit('-m', make_commit_message(launcher_version, version))
        git.push()
Ejemplo n.º 9
0
 def __call__(self, *args, **kwargs):
     with cd(self.dir):
         return self._gradle(*args, **kwargs)