"""Server for v20/v21. Not compatible with earlier versions of the script.Modified by @elpekenin, some incompatibilities (even with original v20/21)are to be expected."""from__future__importannotationsimportargparseimportloggingimportsys# TODO(elpekenin): specify class somehow? eg an argument via CLI + getattr(config, name)fromcable_clubimportconstantsfromcable_club.configimportPyFileConfigfromcable_club.networkimportServer_logger=logging.getLogger(__name__)
[docs]defmain()->int:"""Entrypoint of the server."""config=PyFileConfig()logging.basicConfig(level=config.log_level,format=constants.LOG_FORMAT,handlers=[logging.StreamHandler(sys.stdout),logging.FileHandler(filename=config.log_dir/constants.LOG_FILE,mode="w",),],)parser=argparse.ArgumentParser()_=parser.parse_args()try:Server(config).run()# any unhandled error within the logic must be catched here to correctly shutdownexceptException:_logger.exception("Unhandled exception")exceptKeyboardInterrupt:return0return1