Exemplo n.º 1
0
def run(argv=None):
    # Initialise programs
    get_settings().get_programs()

    # Initialise console
    console = Console()
    console.init()

    # Create parser
    usage = "%prog [options] [OPTION_FILE.xml or RESULTS_FILE.zip or RESULTS_FILE.h5 ...]"
    description = "pyMonteCarlo update tool. This script updates old version " + \
                  "of options or results file to the newer one."
    epilog = "For more information, see http://pymontecarlo.bitbucket.org"

    parser = OptionParser(usage=usage, description=description, epilog=epilog)

    parser.add_option('-v',
                      '--verbose',
                      dest='verbose',
                      default=False,
                      action='store_true',
                      help='Debug mode')

    # Parse arguments
    (values, args) = parser.parse_args(argv)

    if values.verbose:
        logging.getLogger().setLevel(logging.DEBUG)

    if not args:
        console.print_error('Please specify at least one file')

    for filepath in args:
        if not os.path.exists(filepath):
            console.print_error('File %s does not exists' % filepath)

        ext = os.path.splitext(filepath)[1]

        if ext == '.xml':
            console.print_info("Updating options %s" % filepath)
            filepath = OptionsUpdater().update(filepath)
            console.print_success("Successfully updated %s" % filepath)
        elif ext == '.zip' or ext == '.h5':
            console.print_info("Updating results %s" % filepath)
            filepath = ResultsUpdater().update(filepath)
            console.print_success("Successfully results %s" % filepath)
        else:
            console.print_error('Unknown extension %s' % ext)

    console.close()
Exemplo n.º 2
0
def run(argv=None):
    # Initialise programs
    get_settings().get_programs()

    # Initialise console
    console = Console()
    console.init()

    # Create parser
    usage = "%prog [options] [OPTION_FILE.xml or RESULTS_FILE.zip or RESULTS_FILE.h5 ...]"
    description = "pyMonteCarlo update tool. This script updates old version " + \
                  "of options or results file to the newer one."
    epilog = "For more information, see http://pymontecarlo.bitbucket.org"

    parser = OptionParser(usage=usage, description=description, epilog=epilog)

    parser.add_option('-v', '--verbose', dest='verbose', default=False,
                      action='store_true', help='Debug mode')

    # Parse arguments
    (values, args) = parser.parse_args(argv)

    if values.verbose:
        logging.getLogger().setLevel(logging.DEBUG)

    if not args:
        console.print_error('Please specify at least one file')

    for filepath in args:
        if not os.path.exists(filepath):
            console.print_error('File %s does not exists' % filepath)

        ext = os.path.splitext(filepath)[1]

        if ext == '.xml':
            console.print_info("Updating options %s" % filepath)
            filepath = OptionsUpdater().update(filepath)
            console.print_success("Successfully updated %s" % filepath)
        elif ext == '.zip' or ext == '.h5':
            console.print_info("Updating results %s" % filepath)
            filepath = ResultsUpdater().update(filepath)
            console.print_success("Successfully results %s" % filepath)
        else:
            console.print_error('Unknown extension %s' % ext)

    console.close()
Exemplo n.º 3
0
def run(argv=None):
    # Initialize
    console = Console()
    console.init()

    console.print_message("Configuration of pyMonteCarlo")
    console.print_line()

    # Find settings.cfg
    settings = get_settings()

    # Programs
    programs = []

    for program_alias in settings.get_available_program_aliases():
        default = program_alias in settings.get_program_aliases()
        answer = \
            console.prompt_boolean("Do you want to setup %s?" % program_alias, default)
        if answer:
            cli = settings.get_program_cli(program_alias)
            try:
                pass
            except Exception as ex:
                console.print_exception(ex)
                return

            cli.configure(console, settings)

            programs.append(program_alias)
        else:
            if program_alias in settings:
                delattr(settings, program_alias)

        console.print_line()

    settings.pymontecarlo.programs = ','.join(programs)

    # Save
    settings.write()
    console.print_success("Settings saved")

    # Finalize
    console.close()