Ejemplo n.º 1
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.show_metrics:
        print("Known metrics are: %s\n"
              % (', '.join(list_known_metrics()),))
        exit(0)

    almost_required_options = ['input_path', 'output_dir', 'metrics']
    for option in almost_required_options:
        if getattr(opts, option) is None:
            option_parser.error('Required option --%s omitted.' % option)

    if opts.output_dir.endswith('.txt'):
        stderr.write('output must be a directory, files will be named' +
                     ' automatically.  And we refuse to make .txt directories\n')
        exit(1)

    if opts.tree_path == "None":
        opts.tree_path = None

    try:
        os.makedirs(opts.output_dir)
    except OSError:
        pass  # hopefully dir already exists

    if os.path.isdir(opts.input_path):
        multiple_file_beta(opts.input_path, opts.output_dir, opts.metrics,
                           opts.tree_path, opts.rows, full_tree=opts.full_tree)
    elif os.path.isfile(opts.input_path):
        single_file_beta(opts.input_path, opts.metrics, opts.tree_path,
                         opts.output_dir, opts.rows, full_tree=opts.full_tree)
    else:
        stderr.write("io error, input path not valid.  Does it exist?")
        exit(1)
Ejemplo n.º 2
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.show_metrics:
        print("Known metrics are: %s\n"
              % (', '.join(list_known_metrics()),))
        exit(0)

    almost_required_options = ['input_path', 'output_dir', 'metrics']
    for option in almost_required_options:
        if getattr(opts, option) is None:
            option_parser.error('Required option --%s omitted.' % option)

    if opts.output_dir.endswith('.txt'):
        stderr.write('output must be a directory, files will be named' +
                     ' automatically.  And we refuse to make .txt directories\n')
        exit(1)

    if opts.tree_path == "None":
        opts.tree_path = None

    try:
        os.makedirs(opts.output_dir)
    except OSError:
        pass  # hopefully dir already exists

    if os.path.isdir(opts.input_path):
        multiple_file_beta(opts.input_path, opts.output_dir, opts.metrics,
                           opts.tree_path, opts.rows, full_tree=opts.full_tree)
    elif os.path.isfile(opts.input_path):
        single_file_beta(opts.input_path, opts.metrics, opts.tree_path,
                         opts.output_dir, opts.rows, full_tree=opts.full_tree)
    else:
        stderr.write("io error, input path not valid.  Does it exist?")
        exit(1)