def main(_unused_argv):
    with open(FLAGS.log_list, "rb") as f:
        json_data = f.read()

    if not FLAGS.skip_signature_check:
        if not FLAGS.signature:
            raise app.UsageError("ERROR: --signature flag not set.")
        if not FLAGS.signer_key:
            raise app.UsageError("ERROR: --signer_key flag not set.")
        if not is_signature_valid(json_data, FLAGS.signature, FLAGS.signer_key):
            raise app.UsageError(
                "ERROR: Signature over list of logs is not valid.")

    parsed_json = json.loads(json_data)
    if not FLAGS.log_list_schema:
        raise app.UsageError("ERROR: --log_list_schema flag not set.")
    if not is_log_list_valid(parsed_json, FLAGS.log_list_schema):
        raise app.UsageError(
            "ERROR: Log list is signed but does not conform to the schema.", 2)
    if FLAGS.header_output:
        generate_cpp_header(parsed_json, FLAGS.header_output)
    if FLAGS.java_output:
        generate_java_source(parsed_json, FLAGS.java_output, FLAGS.java_class)
    if FLAGS.openssl_output:
        generate_openssl_conf(parsed_json, FLAGS.openssl_output)

    if not FLAGS.header_output and \
       not FLAGS.java_output and \
       not FLAGS.openssl_output:
        print_formatted_log_list(parsed_json)
def run():
    with open(FLAGS.log_list, "rb") as f:
        json_data = f.read()

    if (not FLAGS.skip_signature_check) and not is_signature_valid(
            json_data, FLAGS.signature, FLAGS.signer_key):
        print "ERROR: Signature over list of logs is not valid, not proceeding."
        sys.exit(1)

    parsed_json = json.loads(json_data)
    if not is_log_list_valid(parsed_json, FLAGS.log_list_schema):
        print "ERROR: Log list is signed but does not conform to the schema."
        sys.exit(2)
    if FLAGS.header_output:
        generate_cpp_header(parsed_json, FLAGS.header_output)
    if FLAGS.java_output:
        generate_java_source(parsed_json, FLAGS.java_output, FLAGS.java_class)
    if FLAGS.openssl_output:
        generate_openssl_conf(parsed_json, FLAGS.openssl_output)

    if not FLAGS.header_output and not FLAGS.java_output:
        print_formatted_log_list(parsed_json)
def run():
    with open(FLAGS.log_list, "rb") as f:
        json_data = f.read()

    if (not FLAGS.skip_signature_check) and not is_signature_valid(
        json_data, FLAGS.signature, FLAGS.signer_key):
        print "ERROR: Signature over list of logs is not valid, not proceeding."
        sys.exit(1)

    parsed_json = json.loads(json_data)
    if not is_log_list_valid(parsed_json, FLAGS.log_list_schema):
        print "ERROR: Log list is signed but does not conform to the schema."
        sys.exit(2)
    if FLAGS.header_output:
        generate_cpp_header(parsed_json, FLAGS.header_output)
    if FLAGS.java_output:
        generate_java_source(parsed_json, FLAGS.java_output, FLAGS.java_class)
    if FLAGS.openssl_output:
        generate_openssl_conf(parsed_json, FLAGS.openssl_output)

    if not FLAGS.header_output and not FLAGS.java_output:
        print_formatted_log_list(parsed_json)