-def make_turn_tester(turn_to_compare, world_db):
- """Return tester whether world_db["turn"] greater/equal turn_to_compare."""
- def turn_tester():
- return world_db["turn"] >= turn_to_compare
- return turn_tester
+def parse_command_line_arguments():
+ """Return settings values read from command line arguments."""
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-s', nargs='?', type=int, dest='replay', const=1,
+ action='store')
+ opts, unknown = parser.parse_known_args()
+ return opts
+
+
+def server_test(io_db):
+ """Ensure valid server out file belonging to current process.
+
+ On failure, set io_db["kicked_by_rival"] and raise SystemExit.
+ """
+ if not os.access(io_db["path_out"], os.F_OK):
+ raise SystemExit("Server output file has disappeared.")
+ file = open(io_db["path_out"], "r")
+ test = file.readline().rstrip("\n")
+ file.close()
+ if test != io_db["teststring"]:
+ io_db["kicked_by_rival"] = True
+ msg = "Server test string in server output file does not match. This" \
+ " indicates that the current server process has been " \
+ "superseded by another one."
+ raise SystemExit(msg)
+
+
+def io_loop ():
+ return False