2016-11-17 02:08:31 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import sys, json, random, os
|
|
|
|
|
|
|
|
def translate(filename, target, tab):
|
|
|
|
with open(filename, 'r') as f:
|
|
|
|
content = f.read()
|
|
|
|
for k, v in tab.items():
|
|
|
|
content = content.replace('__' + k + '__', v)
|
|
|
|
with open(target, 'w') as f:
|
|
|
|
f.write(content)
|
|
|
|
|
|
|
|
cid = raw_input('uoj container id: ')
|
|
|
|
ip = raw_input('uoj ip: ')
|
|
|
|
name = raw_input('judger name: ')
|
|
|
|
|
2017-09-07 05:16:13 +00:00
|
|
|
os.system("docker cp " + cid + ":/home/local_main_judger/judge_client/.conf.json conf.json")
|
2016-11-17 02:08:31 +00:00
|
|
|
|
2017-09-07 05:16:13 +00:00
|
|
|
with open('conf.json', 'r') as f:
|
2016-11-17 02:08:31 +00:00
|
|
|
conf = json.load(f)
|
|
|
|
|
|
|
|
conf['uoj_host'] = ip
|
|
|
|
conf['judger_name'] = name
|
|
|
|
conf['judger_password'] = ''.join(random.choice('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') for i in range(32))
|
|
|
|
|
2017-09-07 05:16:13 +00:00
|
|
|
with open('conf.json', 'w') as f:
|
2016-11-17 02:08:31 +00:00
|
|
|
json.dump(conf, f, indent=4, separators=(',', ': '))
|
|
|
|
print >>f
|
|
|
|
|
|
|
|
translate_table = {
|
|
|
|
'svn_cert': '--username %s --password %s' % (conf['svn_username'], conf['svn_password']),
|
|
|
|
'uoj_host': ip
|
|
|
|
}
|
|
|
|
|
2017-09-07 05:16:13 +00:00
|
|
|
translate('install', 'cur_install', translate_table)
|
2016-11-17 02:08:31 +00:00
|
|
|
|
|
|
|
print "please modify the database after getting the judger server ready:"
|
|
|
|
print "insert into judger_info (judger_name, password, ip) values ('%s', '%s', '__judger_ip_here__');" % (name, conf['judger_password'])
|