def main():
    libchocoload.setup_logger(logger)

    parser = argparse.ArgumentParser()
    libchocoload.HatoholRestApi.define_arguments(parser)
    parser.add_argument("amqp_broker_url", help="A ULR of the AMQP broker")
    parser.add_argument("-g", "--num-generators", default=1, type=int,
                        help="The number of event generators working via HAPI2.0")
    parser.add_argument("--hap-base-name", default="events-generator")
    parser.add_argument("--amqp-user", default="guest")
    parser.add_argument("--amqp-password", default="guest")
    parser.add_argument("-s", "--dont-generate", action="store_true",
                        help="Don't generate events althought receiver works.")
    parser.add_argument("-m", "--only-main-loop", action="store_true",
                        help="Run generation loop only.")
    parser.add_argument("-r", "--ignore-result-failure", action="store_true",
                        help="Continue if the result is FALURE.")
    parser.add_argument("-c", "--chunk-size", type=int, default=1,
                        help="The number of events in one putEvents call.")
    parser.add_argument("-n", "--num-total-events", type=int,
                        default=libchocoload.NUM_EVENTS_UNLIMITED,
                        help="The number of events to be generated. 0 means unlimited.")
    parser.add_argument("-p", "--pattern", type=str,
                        default="simple", choices=libchocoload.PATTERNS.keys())
    parser.add_argument("-f", "--parameter-file", type=str,
                        default=libchocoload.DEFAULT_PARAMETER_FILE)
    parser.add_argument("-q", "--queuing-level", type=int, default=100,
                        help="The number of messages queued in advance.")

    args = parser.parse_args()
    mgr = Manager(args)
    try:
        if args.only_main_loop:
            logger.info("Run main loop only.")
            mgr.main_loop()
        else:
            mgr()
    except KeyboardInterrupt:
        logger.info("Exit: KeyboardInterrupt")

    elapsed_time = mgr.get_elapsed_time()
    logger.info("Elapsed time: %.3f [s], rate: %.1f [events/s]" %
                (elapsed_time, float(args.num_total_events)/elapsed_time))
    mgr.save_paramter_file()
def main():
    libchocoload.setup_logger(logger)

    parser = argparse.ArgumentParser()
    libchocoload.HatoholRestApi.define_arguments(parser)
    parser.add_argument("amqp_broker_url", help="A ULR of the AMQP broker")
    parser.add_argument(
        "-g",
        "--num-generators",
        default=1,
        type=int,
        help="The number of event generators working via HAPI2.0")
    parser.add_argument("--hap-base-name", default="events-generator")
    parser.add_argument("--amqp-user", default="guest")
    parser.add_argument("--amqp-password", default="guest")
    parser.add_argument("-s",
                        "--dont-generate",
                        action="store_true",
                        help="Don't generate events althought receiver works.")
    parser.add_argument("-m",
                        "--only-main-loop",
                        action="store_true",
                        help="Run generation loop only.")
    parser.add_argument("-r",
                        "--ignore-result-failure",
                        action="store_true",
                        help="Continue if the result is FALURE.")
    parser.add_argument("-c",
                        "--chunk-size",
                        type=int,
                        default=1,
                        help="The number of events in one putEvents call.")
    parser.add_argument(
        "-n",
        "--num-total-events",
        type=int,
        default=libchocoload.NUM_EVENTS_UNLIMITED,
        help="The number of events to be generated. 0 means unlimited.")
    parser.add_argument("-p",
                        "--pattern",
                        type=str,
                        default="simple",
                        choices=libchocoload.PATTERNS.keys())
    parser.add_argument("-f",
                        "--parameter-file",
                        type=str,
                        default=libchocoload.DEFAULT_PARAMETER_FILE)
    parser.add_argument("-q",
                        "--queuing-level",
                        type=int,
                        default=100,
                        help="The number of messages queued in advance.")

    args = parser.parse_args()
    mgr = Manager(args)
    try:
        if args.only_main_loop:
            logger.info("Run main loop only.")
            mgr.main_loop()
        else:
            mgr()
    except KeyboardInterrupt:
        logger.info("Exit: KeyboardInterrupt")

    elapsed_time = mgr.get_elapsed_time()
    logger.info("Elapsed time: %.3f [s], rate: %.1f [events/s]" %
                (elapsed_time, float(args.num_total_events) / elapsed_time))
    mgr.save_paramter_file()
        logger.info("Checked %d events" % count)

        for worker in self.__workers.values():
            worker.checkProcessedCount()

    def __is_num_events_unlimited(self):
        return self.__args.max_num_events == libchocoload.NUM_EVENTS_UNLIMITED

    def __parseEvents(self, events):
        for event in events:
            sv_id = event["serverId"]
            self.__workers[sv_id].parseEvent(event)


if __name__ == "__main__":
    libchocoload.setup_logger(logger)
    parser = argparse.ArgumentParser()

    libchocoload.HatoholRestApi.define_arguments(parser)
    parser.add_argument(
        "-m",
        "--max-num-events",
        type=int,
        default=libchocoload.NUM_EVENTS_UNLIMITED,
        help="The number of events to be generated. 0 means unlimited.",
    )
    parser.add_argument("-f", "--parameter-file", type=file, default=libchocoload.DEFAULT_PARAMETER_FILE)

    args = parser.parse_args()
    mgr = Manager(args)
    try:
        logger.info("Checked %d events" % count)

        for worker in self.__workers.values():
            worker.checkProcessedCount()

    def __is_num_events_unlimited(self):
        return self.__args.max_num_events == libchocoload.NUM_EVENTS_UNLIMITED

    def __parseEvents(self, events):
        for event in events:
            sv_id = event["serverId"]
            self.__workers[sv_id].parseEvent(event)


if __name__ == "__main__":
    libchocoload.setup_logger(logger)
    parser = argparse.ArgumentParser()

    libchocoload.HatoholRestApi.define_arguments(parser)
    parser.add_argument(
        "-m",
        "--max-num-events",
        type=int,
        default=libchocoload.NUM_EVENTS_UNLIMITED,
        help="The number of events to be generated. 0 means unlimited.")
    parser.add_argument("-f",
                        "--parameter-file",
                        type=file,
                        default=libchocoload.DEFAULT_PARAMETER_FILE)

    args = parser.parse_args()