def executeGameTask(width, height, users, backend): """Downloads compiled bots, runs a game, and posts the results of the game""" print("Running game with width %d, height %d, and users %s" % (width, height, str(users))) downloadUsers(users) replayPath, users = parseGameOutput(runGame(width, height, users), users) backend.gameResult(width, height, users, replayPath) os.remove(replayPath)
def executeGameTask(width, height, users, backend): """Downloads compiled bots, runs a game, and posts the results of the game""" print("Running game with width %d, height %d, and users %s" % (width, height, str(users))) downloadUsers(users) users, replayPath, errorPaths = parseGameOutput(runGame(width, height, users), users) backend.gameResult(width, height, users, replayPath, errorPaths) filelist = glob.glob("*.log") for f in filelist: os.remove(f) os.remove(replayPath)
def executeGameTask(width, height, users, backend): """Downloads compiled bots, runs a game, and posts the results of the game""" logging.debug("Running game with width %d, height %d\n" % (width, height)) logging.debug("Users objects %s\n" % (str(users))) raw_output = '\n'.join(runGame(width, height, users)) users, parsed_output = parseGameOutput(raw_output, users) backend.gameResult(users, parsed_output) # Clean up game logs and replays filelist = glob.glob("*.log") for f in filelist: os.remove(f) os.remove(parsed_output["replay"]) # Make sure game processes exit subprocess.run(["pkill", "--signal", "9", "-f", "cgexec"])
def executeGameTask(width, height, users, backend): """Downloads compiled bots, runs a game, and posts the results of the game""" print("Running game with width %d, height %d, and users %s" % (width, height, str(users))) downloadUsers(users) users, replayPath, errorPaths = parseGameOutput(runGame(width, height, users), users) replayArchivePath = "ar"+replayPath fIn = open(replayPath, 'rb') fOut = gzip.open(replayArchivePath, 'wb') shutil.copyfileobj(fIn, fOut) fIn.close() fOut.close() backend.gameResult(width, height, users, replayArchivePath, errorPaths) filelist = glob.glob("*.log") for f in filelist: os.remove(f) os.remove(replayPath) os.remove(replayArchivePath)