def main()

in rotation.py [0:0]


def main():
    args = parse_args()
    logger.setLevel(logging.DEBUG if args.debug else logging.INFO)

    rotations = load_rotations()
    leaders = [m for m in MEMBERS if m.lead]
    while len(rotations) < len(leaders):
        # create some history to improve selection
        week = get_week(DATE - timedelta(weeks=(len(leaders) - len(rotations))))
        rotations.setdefault(week, generate_rotation(leaders, rotations))

    print(f"Generated on {DATE}")

    print("\nThis week:")
    this_week = get_week(DATE)
    if args.force or not rotations.get(this_week):
        rotations[this_week] = generate_rotation(leaders, rotations)
    print(f"{this_week}: {rotations[this_week]}")

    print("\nNext week:")
    next_week = get_week(DATE + timedelta(weeks=1))
    generated_next_week = False
    if args.force or not rotations.get(next_week):
        generated_next_week = True
        rotations[next_week] = generate_rotation(leaders, rotations)
    print(f"{next_week}: {rotations[next_week]}")

    print("\nHistory:")
    for week, rotation in list(sorted(rotations.items(), reverse=True))[2:]:
        print(f"{week}: {rotation}")

    generate_html(rotations)

    with SAVED_ROTATIONS_PATH.open(mode="wb") as f:
        pickle.dump(rotations, f)

    print("")  # Add a newline between rotation output and calendar reminder output.
    try:
        add_gcal_reminder(args.production, rotations[next_week], generated_next_week)
    except Exception as err:
        # If this script fails (returns a non-zero exit code), the triage rotation website will not
        # get updated. Since contacting the network to send a reminder can hit a lot of errors, we
        # catch all exceptions to be safe and avoid this possibility.
        # TODO: separate this into a separate build task to make generate rotation even safer.
        if type(err) is HttpError:
            logging.exception(
                "during network request when adding google calendar reminder"
            )
        elif type(err) is FileNotFoundError:
            logging.exception(
                "unable to locate Google Cloud Project secrets when adding google calendar reminder"
            )
        else:
            # Exception types include gcal.CredentialException & GoogleAuthError
            logging.exception("cause unknown")