'-v', action='store_true', help='Verbose output. Changes log level from INFO to DEBUG.') parser.add_argument( '--config', help='Specify a configuration file (defaults to ./config.yml)') parser.add_argument('-l', '--logfile', help="Log file to append logs to.", default=None) args = parser.parse_args() logging.basicConfig(level=logging.DEBUG if args.v else logging.INFO, filename=args.logfile, format="%(asctime)-15s: %(message)s") enable_color_logging(debug_lvl=logging.DEBUG if args.v else logging.INFO) logger.info(intro()) CONFIG = load_config(args.config or "./config.yml") li = lichess.Lichess(CONFIG["token"], CONFIG["url"], __version__) user_profile = li.get_profile() username = user_profile["username"] is_bot = user_profile.get("title") == "BOT" logger.info("Welcome {}!".format(username)) if args.u is True and is_bot is False: is_bot = upgrade_account(li) if is_bot: engine_factory = partial(engine_wrapper.create_engine, CONFIG) start(li, user_profile, engine_factory, CONFIG)
def listener_configurer(level, filename): logging.basicConfig(level=level, filename=filename, format="%(asctime)-15s: %(message)s") enable_color_logging(level)
def update_board(board, move): uci_move = chess.Move.from_uci(move) board.push(uci_move) return board def intro(): return r""" . _/| . // o\ . || ._) lichess-bot %s . //__\ . )___( Play on Lichess with a bot """ % __version__ if __name__ == "__main__": enable_color_logging(logging.INFO) parser = argparse.ArgumentParser(description='Play on Lichess with a bot') parser.add_argument('-u', action='store_true', help='Add this flag to upgrade your account to a bot account.') parser.add_argument('-v', action='store_true', help='Verbose output. Changes log level from INFO to DEBUG.') parser.add_argument('--config', help='Specify a configuration file (defaults to ./config.yml)') parser.add_argument('-l', '--logfile', help="Log file to append logs to.", default=None) args = parser.parse_args() logging.basicConfig(level=logging.DEBUG if args.v else logging.INFO, filename=args.logfile, format="%(asctime)-15s: %(message)s") logger.info(intro()) CONFIG = load_config(args.config or "./config.yml") li = lichess.Lichess(CONFIG["token"], CONFIG["url"], __version__) user_profile = li.get_profile() username = user_profile["username"]
action='store_true', help='Verbose output. Changes log level from INFO to DEBUG.') parser.add_argument( '--config', help='Specify a configuration file (defaults to ./config.yml)') parser.add_argument('-l', '--logfile', help="Log file to append logs to.", default=None) args = parser.parse_args() logging_level = logging.DEBUG if args.v else logging.INFO logging.basicConfig(level=logging_level, filename=args.logfile, format="%(asctime)-15s: %(message)s") enable_color_logging(debug_lvl=logging_level) logger.info(intro()) CONFIG = load_config(args.config or "./config.yml") li = lishogi.Lishogi(CONFIG["token"], CONFIG["url"], __version__) user_profile = li.get_profile() username = user_profile["username"] is_bot = user_profile.get("title") == "BOT" logger.info("Welcome {}!".format(username)) if args.u and not is_bot: is_bot = upgrade_account(li) if is_bot: engine_factory = partial(engine_wrapper.create_engine, CONFIG) start(li, user_profile, engine_factory, CONFIG, logging_level,
def test_enable_color_logging(): assert enable_color_logging() == None