def main(): host = "localhost" port = 8000 rootlogger = logging.getLogger("") ch = logging.StreamHandler() ch.setFormatter(logging.Formatter("%(asctime)s:%(name)s:%(levelname)s %(message)s")) rootlogger.addHandler(ch) try: opts, _ = getopt.getopt(sys.argv[1:], "b:f:p:hvd") except getopt.GetoptError: usage() for opt, val in opts: if opt == "-b": host = val if opt == "-p": port = int(val) if opt == "-f": CheatHandler.mappings = cheatbt.load_mappings(val) if opt == "-v": rootlogger.setLevel(logging.INFO) if opt == "-d": rootlogger.setLevel(logging.DEBUG) if opt == "-h": usage() httpd = CheatProxy(host, port) logger = logging.getLogger("cheatproxy") logger.info("listening on %s:%d" % (host, port)) httpd.serve_forever()
def setUp(self): self.parsing = cheatbt.load_mappings("test/parsing") self.nodefault = cheatbt.load_mappings("test/nodefault")