Example #1
0
def config_cmd(ctx):
    """Configure or reconfigure wn's settings"""
    if ctx.invoked_subcommand is None:
        conf = read_conf()
        proj_path = recommend_project_folder()
        eprint('I can automatically create a folder for your projects.')
        eprint('I think {} looks good.'.format(proj_path))
        if ctx and click.confirm('Do you want to change it?'):
            proj_path = click.prompt(
                'Location to store the source code',
                default=conf.get('source', ''),
                type=str).strip().strip('\'').strip('"').rstrip('/')
            if not Path(proj_path).exists():
                eprint(
                    'Bummer. Your path is invalid or the folder does not exist.'
                )
                eprint('Please first create it.')
                return
            else:
                conf['source'] = proj_path
        else:
            proj_path.mkdir(exist_ok=True)
            eprint('Okay, I created a folder at {}'.format(proj_path))
            conf['source'] = str(proj_path)
        conf['git_username'] = click.prompt('GitHub Username',
                                            type=str,
                                            default='optional')
        conf['git_password'] = click.prompt('GitHub Password',
                                            type=str,
                                            hide_input=True,
                                            default='optional')
        write_conf(conf)
        click.echo('All set!')
Example #2
0
def update(ctx, name, actions):
    """Update one or a group of projects."""
    check_config(ctx)
    projects = query_projects(name)
    if not projects:
        eprint('I don\'t know which projects you\'re referring to...')
        exit(2)
    for i in projects:
        if not project_exists(i):
            eprint('> Project %s does not exist, skipped' % i)
            continue
        eprint('> Updating project: {}'.format(i))
        available_actions = [
            a for a in list_actions(i).get('update', {})
            if a in actions or not actions
        ]
        for actn in ACTION_PRIORITY:
            if actn in available_actions:
                try:
                    run_op(i, 'update', actn)
                except NotImplementedError:
                    eprint(
                        '--> Action {} not implemented, skipped'.format(actn))
        print('> Project {} updated!'.format(i))
    print('> All set!')
Example #3
0
def init(ctx, name, actions):
    """Initializes source code projects.
    
    ACTION can be one of the following:
    - git: Clone the source code from git
    - env: Set up the environment for running the code
    """
    check_config(ctx)
    projects = query_projects(name)
    if not projects:
        eprint('I don\'t know which projects you\'re referring to...')
        exit(2)
    for i in projects:
        eprint('> Initializing project: {}'.format(i))
        available_actions = [
            a for a in list_actions(i).get('init', {})
            if a in actions or not actions
        ]
        for actn in ACTION_PRIORITY:
            if actn in available_actions:
                try:
                    run_op(i, 'init', actn)
                except NotImplementedError:
                    eprint(
                        '--> Action {} not implemented, skipped'.format(actn))
        print('> Project {} initialized!'.format(i))
    print('> All set!')
Example #4
0
def checkout(ctx, name, branch):
    """Switch a project or a group of them to the specified Git branch."""
    projects = query_projects(name)
    if not projects:
        eprint('I don\'t know which projects you\'re referring to...')
        exit(2)
    for i in projects:
        if not project_exists(i):
            eprint('> Project %s does not exist, skipped' % i)
            continue
        # Checkout the project
        if checkout_project(i, branch):
            eprint('> Project %s checked out to %s' % (i, branch))
    print('> All set!')
Example #5
0
def init(ctx, name, actions):
    check_config(ctx)
    projects = query_projects(name)
    if not projects:
        eprint('I don\'t know which projects you\'re referring to...')
        exit(2)
    for i in projects:
        eprint('> Initializing project: {}'.format(i))
        available_actions = [
            a for a in list_actions(i).get('init', {})
            if a in actions or not actions
        ]
        for actn in ACTION_PRIORITY:
            if actn in available_actions:
                try:
                    run_action(i, 'init', actn)
                except NotImplementedError:
                    eprint(
                        '--> Action {} not implemented, skipped'.format(actn))
        print('> Project {} initialized!'.format(i))
    print('> All set!')
Example #6
0
File: main.py Project: WaggleNet/wn
def cli():
    eprint("======= WaggleNet Ubercommand =======\n")
    pass