|
2 | 2 | import os
|
3 | 3 | import sys
|
4 | 4 | import random
|
5 |
| -import zipfile |
6 | 5 | import MySQLdb
|
7 | 6 | from server_info import server_info
|
8 | 7 |
|
9 |
| -def create_test_bot(name): |
10 |
| - bot_filename = os.path.join("../ants/bots/python", name + ".py") |
11 |
| - bot_support_filename = "../ants/bots/python/ants.py" |
12 |
| - if not os.path.exists(bot_filename): |
13 |
| - print("No bot named %s" % name) |
14 |
| - return False |
15 |
| - |
16 |
| - |
17 |
| - connection = MySQLdb.connect(host = server_info["db_host"], |
18 |
| - user = server_info["db_username"], |
19 |
| - passwd = server_info["db_password"], |
20 |
| - db = server_info["db_name"]) |
21 |
| - cursor = connection.cursor(MySQLdb.cursors.DictCursor) |
22 |
| - |
23 |
| - # get next bot name number |
24 |
| - cursor.execute(""" |
25 |
| - select username |
26 |
| - from user |
27 |
| - where username like '%s%%' |
28 |
| - """ % name) |
29 |
| - bot_id = max([int(row["username"][len(name):]) |
30 |
| - for row in cursor.fetchall()] or [0]) + 1 |
31 |
| - |
32 |
| - # create user database entry |
33 |
| - cursor.execute(""" |
34 |
| - insert into user |
35 |
| - values (null,'%s%s','$6$rounds=54321$hQd}`.j1e#X&PuN*$D8.wbEp6vwwLoC27GpiGVOFediuAWaGTQ2MPHD64i/bVGxtj0XNeRJeJRKVgDC/uTh.W2m5YoaoA6To1cJ7ZF/', |
36 |
| - '%s%[email protected]',1,'7b3f9842775fa9c9d489a3714e857580',0,'Test Account',11,current_timestamp(),0,0); |
37 |
| - """ % (name, bot_id, name, bot_id)) |
38 |
| - user_id = cursor.lastrowid |
39 |
| - print("user_id: %s" % user_id) |
40 |
| - |
41 |
| - # create submission entry |
42 |
| - cursor.execute(""" |
43 |
| - insert into submission (user_id, version, status, timestamp, language_id) |
44 |
| - values (%s, 1, 20, current_timestamp(), 6) |
45 |
| - """ % (user_id)) |
46 |
| - submission_id = cursor.lastrowid |
47 |
| - print("submission_id: %s" % submission_id) |
48 |
| - |
49 |
| - connection.commit() |
50 |
| - connection.close() |
51 |
| - |
52 |
| - # create submission file |
53 |
| - bot_dir = os.path.join(server_info['submissions_path'], str(submission_id)) |
54 |
| - os.mkdir(bot_dir) |
55 |
| - |
56 |
| - bot_zip_filename = os.path.join(bot_dir, "entry.zip") |
57 |
| - with zipfile.ZipFile(bot_zip_filename, 'w') as bot_zip: |
58 |
| - bot_zip.write(bot_filename, 'MyBot.py') |
59 |
| - bot_zip.write(bot_support_filename, 'ants.py') |
60 |
| - |
61 |
| - |
62 | 8 | def create_test_data(user_count=10000, map_count=1000, game_count=30000, matchup_count=10):
|
63 | 9 | connection = MySQLdb.connect(host = server_info["db_host"],
|
64 | 10 | user = server_info["db_username"],
|
|
0 commit comments