The script starts here.

def run_rpc_differ():
    """The script starts here."""
    args = parse_arguments()

    # Set up DEBUG logging if needed
    if args.debug:
        log.setLevel(logging.DEBUG)
    elif args.verbose:
        log.setLevel(logging.INFO)

    # Create the storage directory if it doesn't exist already.
    try:
        storage_directory = osa_differ.prepare_storage_dir(args.directory)
    except OSError:
        print("ERROR: Couldn't create the storage directory {0}. "
              "Please create it manually.".format(args.directory))
        sys.exit(1)

    # Prepare the rpc-openstack repository.
    rpc_repo_url = args.rpc_repo_url
    rpc_repo_dir = "{0}/rpc-openstack".format(storage_directory)
    osa_differ.update_repo(rpc_repo_dir, rpc_repo_url, args.update)

    # Validate/update the commits.
    rpc_old_commit = validate_rpc_sha(rpc_repo_dir, args.old_commit[0])
    rpc_new_commit = validate_rpc_sha(rpc_repo_dir, args.new_commit[0])

    # Generate RPC report header.
    report_rst = make_rpc_report(rpc_repo_dir,
                                 rpc_old_commit,
                                 rpc_new_commit,
                                 args)

    # Get the list of RPC roles from the newer and older commits.
    try:
        role_yaml = osa_differ.get_roles(
            rpc_repo_dir,
            rpc_old_commit,
            args.role_requirements_old_commit
        )
    except IOError:
        role_yaml = osa_differ.get_roles(
            rpc_repo_dir,
            rpc_old_commit,
            ROLE_REQ_FILE
        )

    try:
        role_yaml_latest = osa_differ.get_roles(
            rpc_repo_dir,
            rpc_new_commit,
            args.role_requirements
        )
    except IOError:
        role_yaml_latest = osa_differ.get_roles(
            rpc_repo_dir,
            rpc_new_commit,
            ROLE_REQ_FILE
        )

    # Generate the role report.
    report_rst += ("\nRPC-OpenStack Roles\n"
                   "-------------------")
    report_rst += osa_differ.make_report(storage_directory,
                                         role_yaml,
                                         role_yaml_latest,
                                         args.update,
                                         args.version_mappings)

    report_rst += "\n"

    # Generate OpenStack-Ansible report.
    repo = Repo(rpc_repo_dir)
    osa_old_commit = get_osa_commit(repo,
                                    rpc_old_commit,
                                    rpc_product=args.rpc_product_old_commit)
    osa_new_commit = get_osa_commit(repo,
                                    rpc_new_commit,
                                    rpc_product=args.rpc_product)
    log.debug("OSA Commits old:{old} new:{new}".format(old=osa_old_commit,
                                                       new=osa_new_commit))

    osa_repo_dir = "{0}/openstack-ansible".format(storage_directory)
    # NOTE:
    # An exception is thrown by osa_differ if these two commits
    # are the the same, but it is sometimes necessary to compare
    # two RPC tags that have the same OSA SHA. For example,
    # comparing two tags that only have differences between the
    # two RPCO commit, but no differences between the OSA SHAs
    # that correspond to those two commits.
    # To handle this case, the exception will be caught and flow
    # of execution will continue normally.
    try:
        report_rst += osa_differ.make_osa_report(osa_repo_dir,
                                                 osa_old_commit,
                                                 osa_new_commit,
                                                 args)
    except exceptions.InvalidCommitRangeException:
        pass

    # Get the list of OpenStack-Ansible roles from the newer and older commits.
    try:
        role_yaml = osa_differ.get_roles(osa_repo_dir,
                                         osa_old_commit,
                                         args.role_requirements_old_commit)
    except IOError:
        role_yaml = osa_differ.get_roles(osa_repo_dir,
                                         osa_old_commit,
                                         ROLE_REQ_FILE)
    try:
        role_yaml_latest = osa_differ.get_roles(osa_repo_dir,
                                                osa_new_commit,
                                                args.role_requirements)
    except IOError:
        role_yaml_latest = osa_differ.get_roles(osa_repo_dir,
                                                osa_new_commit,
                                                ROLE_REQ_FILE)

    # Generate the role report.
    report_rst += ("\nOpenStack-Ansible Roles\n"
                   "-----------------------")
    report_rst += osa_differ.make_report(storage_directory,
                                         role_yaml,
                                         role_yaml_latest,
                                         args.update,
                                         args.version_mappings)

    project_yaml = osa_differ.get_projects(osa_repo_dir,
                                           osa_old_commit)
    project_yaml_latest = osa_differ.get_projects(osa_repo_dir,
                                                  osa_new_commit)

    # Generate the project report.
    report_rst += ("OpenStack-Ansible Projects\n"
                   "--------------------------")
    report_rst += osa_differ.make_report(storage_directory,
                                         project_yaml,
                                         project_yaml_latest,
                                         args.update,
                                         args.version_mappings)

    # Publish report according to the user's request.
    output = publish_report(report_rst,
                            args,
                            rpc_old_commit,
                            rpc_new_commit)
    print(output)