Skip to content

Commit 6a42640

Browse files
committed
attempt to fix TrueSkill update from api_game_result.php
1 parent 6360eb9 commit 6a42640

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

manager/add_maps_to_database.py

100644100755
File mode changed.

manager/manager.py

100644100755
+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22
from __future__ import print_function
33
import MySQLdb
44
from server_info import server_info
@@ -103,9 +103,6 @@ def reset_submissions(status):
103103
conn.commit()
104104

105105
def main():
106-
reset_submissions()
107-
108-
if __name__ == '__main__':
109106
parser = argparse.ArgumentParser()
110107
parser.add_argument("-g", "--game_id", type=int,
111108
help="game_id to update")
@@ -125,4 +122,8 @@ def main():
125122
elif args.reset:
126123
reset_submissions(args.reset)
127124
else:
128-
parser.print_usage()
125+
parser.print_usage()
126+
127+
if __name__ == '__main__':
128+
main()
129+

setup/server_info.php.template

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ $server_info = array(
99
"mailer_name" => "AI Contest",
1010
"mailer_password" => "",
1111
"submissions_open" => True,
12+
"repo_path" => "{repo_dir}",
1213
"uploads_path" => "{upload_dir}",
1314
"maps_path" => "{map_dir}",
1415
"replay_path" => "{replay_dir}",

setup/server_setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def setup_website(opts):
125125
si_template = si_file.read()
126126
si_contents = si_template.format(upload_dir=opts.upload_dir,
127127
map_dir=opts.map_dir, replay_dir=opts.replay_dir,
128-
log_dir=opts.log_dir,
128+
log_dir=opts.log_dir, repo_dir=opts.repo_dir,
129129
database_user=opts.database_user,
130130
database_password=opts.database_password,
131131
database_name=opts.database_name,

website/api_game_result.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,22 @@
8282
// create pathname to replay file
8383
$replay_dir = $server_info["replay_path"] . "/" . strval((int) ($game_id / 1000000)) . "/" . strval((int) (($game_id / 1000) % 1000));
8484
if (!file_exists($replay_dir)) {
85-
api_log($replay_dir);
85+
api_log("Replay dir: " . $replay_dir);
8686
mkdir($replay_dir, 0775, true);
8787
}
8888
$replay_filename = $replay_dir . "/" . $game_id . ".replay";
89-
api_log($replay_filename);
89+
api_log("Replay file: " . $replay_filename);
9090
try {
91-
api_log(getcwd());
91+
api_log("Cwd: " . getcwd());
9292
$replay_file = fopen($replay_filename, 'w') or api_log(json_encode(error_get_last()));
9393
fwrite($replay_file, json_encode($gamedata));
9494
fclose($replay_file);
9595
echo json_encode(array( "hash" => $json_hash ));
9696
// mysql_query("COMMIT;");
9797
// update trueskill
98-
exec(sprintf("python ../manager/manager.py -g %s", $game_id));
98+
$cmd = "python " . $server_info["repo_path"] . "/manager/manager.py -g " . $game_id;
99+
api_log("TrueSkill update cmd: " . $cmd);
100+
exec($cmd);
99101
// put game id in memcache for front page
100102
if ($memcache) {
101103
$memcache->set('last_game_id', $game_id);

0 commit comments

Comments
 (0)