示例#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'}))