Пример #1
0
def do_stat():
    log.initialize(
        co.logname(__file__, instance=str(args.sex)),
        file_level="debug",
        console_level="info",
    )
    try:
        log.info(__file__ + " started sex: " + str(args.sex))
        start_datetime = datetime.datetime.now()
        dba.open_connect()
        ratings_std.initialize(sex=args.sex)
        qual_seeds.initialize()
        oncourt_players.initialize(yearsnum=18)

        matchstat_process(sex=args.sex)

        process(
            (
                WinFavoriteProcessor(args.sex),
                TourAverageSetProcessor(args.sex),
            ),
            args.sex
        )

        dba.close_connect()
        log.info(
            "{} finished within {}".format(
                __file__, str(datetime.datetime.now() - start_datetime)
            )
        )
        return 0
    except Exception as err:
        log.error("{0} [{1}]".format(err, err.__class__.__name__), exc_info=True)
        return 1
Пример #2
0
def main():
    try:
        args = parse_command_line_args()
        log.initialize(
            co.logname(__file__, instance=args.instance),
            file_level="debug",
            console_level="info",
        )
        log.info(
            "\n--------------------------------------------------------\nstarted"
        )
        dba.open_connect()
        oncourt_players.initialize()
        ratings.initialize("wta", rtg_names=("elo", ))
        ratings.initialize("atp", rtg_names=("elo", ))
        ratings.Rating.register_rtg_name("elo_alt")
        app = Application(
            wta_players=oncourt_players.players("wta"),
            atp_players=oncourt_players.players("atp"),
        )
        app.master.title("Live")
        app.mainloop()
        log.info("sex: " + app.sex())
        log.info("left_player: " + app.left_player_name())
        log.info("right_player: " + app.right_player_name())
        log.info("score: {}".format(app.score()))
        log.info("level: {}".format(app.level()))
        log.info("surface: {}".format(app.surface()))
        dba.close_connect()
        return 0
    except Exception as err:
        log.error("{0} [{1}]".format(err, err.__class__.__name__),
                  exc_info=True)
        return 1
Пример #3
0
def do_stat(sex=None):
    try:
        dba.open_connect()
        oncourt_players.initialize()

        log.info(__file__ + " begining for stat with sex: " + str(sex))
        start_datetime = datetime.datetime.now()

        if sex is None:
            process_sex("wta")
            process_sex("atp")
        else:
            process_sex(sex)

        dba.close_connect()
        log.info("{} finished within {}".format(
            __file__, str(datetime.datetime.now() - start_datetime)))
        return 0
    except Exception as err:
        log.error("{0} [{1}]".format(err, err.__class__.__name__),
                  exc_info=True)
        return 1
def do_stat():
    log.initialize(
        co.logname(__file__, instance=str(args.sex)),
        file_level="debug",
        console_level="info",
    )
    try:
        msg = "sex: {} min_size: {} max_size: {} max_rtg: {}  max_rtg_dif: {}".format(
            args.sex, args.min_size, args.max_size, args.max_rating,
            args.max_rating_dif)
        log.info(__file__ + " started {}".format(msg))
        dba.open_connect()
        oncourt_players.initialize(yearsnum=8)
        min_date = tt.now_minus_history_days(history_days_personal(args.sex))
        ratings_std.initialize(sex=args.sex,
                               min_date=min_date - datetime.timedelta(days=7))
        initialize_results(
            args.sex,
            max_rating=args.max_rating,
            max_rating_dif=args.max_rating_dif,
            min_date=min_date,
        )

        maker = StatMaker(args.sex,
                          min_size=args.min_size,
                          max_size=args.max_size)
        maker.process_all(aspect=RECOVERY_ASPECT)
        log.info(__file__ + " done {}".format(RECOVERY_ASPECT))
        maker.process_all(aspect=KEEP_ASPECT)
        log.info(__file__ + " done {}".format(KEEP_ASPECT))

        dba.close_connect()
        log.info(__file__ + " finished sex: {}".format(args.sex))
        return 0
    except Exception as err:
        log.error("{0} [{1}]".format(err, err.__class__.__name__),
                  exc_info=True)
        return 1
def fetch_initialize(sex=None, yearsnum=2):
    dba.open_connect()
    oncourt_players.initialize(yearsnum=yearsnum)
    now_date = datetime.datetime.now().date()
    cur_week_monday = tt.past_monday_date(now_date)
    if sex in (None, "wta"):
        weeked_tours.initialize_sex(
            "wta",
            min_date=cur_week_monday - datetime.timedelta(days=14),
            max_date=None,
            with_today=True,
        )
    if sex in (None, "atp"):
        weeked_tours.initialize_sex(
            "atp",
            min_date=cur_week_monday - datetime.timedelta(days=14),
            max_date=None,
            with_today=True,
        )

    fsdrv = common_wdriver.wdriver(company_name="FS")
    fsdrv.start()
    time.sleep(5)
    return fsdrv
 def setUpClass(cls):
     dba.open_connect()
     initialize(yearsnum=8)
        )


class SplitOntwoEnclosedTest(unittest.TestCase):
    def test_split_ontwo_enclosed(self):
        text = "ab(c)-d(ef)"
        p1, p2 = split_ontwo_enclosed(text, delim_op="(", delim_cl=")")
        self.assertTrue(p1 == "ab(c)-d" and p2 == "ef")


if __name__ == "__main__":
    log.initialize(co.logname(__file__, test=True),
                   file_level="info",
                   console_level="info")
    dba.open_connect()
    oncourt_players.initialize(yearsnum=1.2)
    min_date = tt.past_monday_date(
        datetime.date.today()) - datetime.timedelta(days=7)
    weeked_tours.initialize_sex("wta",
                                min_date=min_date,
                                max_date=None,
                                with_today=True,
                                with_bets=True)
    weeked_tours.initialize_sex("atp",
                                min_date=min_date,
                                max_date=None,
                                with_today=True,
                                with_bets=True)
    initialize()

    unittest.main()
def setUpModule():
    if not dba.initialized():
        dba.open_connect()
    oncourt_players.initialize()