Пример #1
0
def command_tag(args):

    def setup(parser):
        parser.add_option(
            '-d', '--dir-names',
            dest='show_dirnames',
            action='store_true',
            help='show directory names instead of run names')

    parser, options, args = cl_parse('tag', args, setup)
    if len(args) < 2:
        help_and_die(parser, 'two or more arguments required')

    action = args.pop(0)

    if action not in ('add', 'remove', 'list'):
        help_and_die(parser, 'invalid action: %s' % action)

    if action in ('add', 'remove'):
        if len(args) < 2:
            help_and_die(parser, 'three or more arguments required')

        tag = args.pop(0)

        rundirs = args

    if action == 'list':
        rundirs = args

    from grond.environment import Environment

    errors = False
    for rundir in rundirs:
        try:
            env = Environment([rundir])
            if options.show_dirnames:
                name = rundir
            else:
                name = env.get_problem().name

            info = env.get_run_info()
            if action == 'add':
                info.add_tag(tag)
                env.set_run_info(info)
            elif action == 'remove':
                info.remove_tag(tag)
                env.set_run_info(info)
            elif action == 'list':
                print('%-60s : %s' % (
                    name,
                    ', '.join(info.tags)))

        except grond.GrondError as e:
            errors = True
            logger.error(e)

    if errors:
        die('Errors occurred, see log messages above.')
Пример #2
0
def make_movie(dirname, xpar_name, ypar_name, movie_filename):
    env = Environment([dirname])
    optimiser = env.get_optimiser()
    problem = env.get_problem()
    history = env.get_history()
    movie_maker = optimiser.get_movie_maker(problem, history, xpar_name,
                                            ypar_name, movie_filename)

    movie_maker.render()