コード例 #1
0
ファイル: processor.py プロジェクト: Niols/yasR
def process (to_process, config_path, ACTION):

    print_actions(to_process, ACTION)

    act = cinput('<Magenta>P</Magenta>rocess, <Magenta>E</Magenta>dit, <Magenta>C</Magenta>ancel? [Default: Edit]', default='E').lower()
    while act not in ['p', 'e', 'c']:
        log.warn('Invalid action.')
        act = cinput('<Magenta>P</Magenta>rocess, <Magenta>E</Magenta>dit, <Magenta>C</Magenta>ancel? [Default: Edit]', default='E').lower()

    if act == 'c':
        log.info('Aborting')
        return False

    if act == 'p':
        for i in range(len(to_process)):
            print(('({0:d}/{1:d}) Processing {2}.'.format(
                i+1,
                len(to_process),
                to_process[i].source))[:80],
                  end='\r')
            try:
                getattr(action, ACTION+'Action')(to_process[i])
            except:
                log.fail('Invalid action {}. Aborting.'.format(ACTION))
                return False

        log.info('All files processed. Thanks for using yasR.')
        return True

    if act == 'e':
        process (
            process_edition(to_process, config_path, ACTION),
            config_path,
            ACTION
        )
コード例 #2
0
ファイル: yasR.py プロジェクト: Niols/yasR
    def check_action (self):
        available_actions = [a[:-6] for a in dir(action) if re.match('[^_].*Action', a)]

        print()
        cprint('Actions available: ', 'white', attrs=['bold'])
        for act in available_actions:
            print(' - ' + act)
        print()

        if 'action' in PARAMS:
            ACTION = PARAMS['action']
            log.ok('Found action in parameters: %s.' % ACTION)
        else:
            log.info('No action found in parameters. Asking user.')
            ACTION = cinput('Enter action')

        while ACTION not in available_actions:
            log.warn('Action not available: %s.' % ACTION)
            ACTION = cinput('Enter action')
        log.ok('Action available.')

        PARAMS['action'] = ACTION
        save_params()
コード例 #3
0
def test_docker_run_basic(client, shipy):
    container = shipy.shipy(
        cinput('run --name {} {} {}'.format(cn(), cimage, cargs)))
    assert 1 == len(client.containers(
        filters={'id': container, 'status': 'running'}))