Пример #1
1
     print('Unknown task: {}.'.format(sub.task))
     continue
     
 if lang is None:
     print('Unknown language: {}.'.format(sub.lang))
     continue
 
 user_src = Paths.user_source.format(tmp_dir=config['tmp'], ext=lang.ext)
 with open(user_src, 'w') as f:
     f.write(sub.src)
     
 result = tester.OjojCodes.UnknownJudgeStatus
 cpu = []
 mem = []
 
 for event in tester.flow(lang, user_src, task, {'tmp_dir': config['tmp']}):
     if isinstance(event, events.Accepted):
         result = tester.OjojCodes.AC
     elif isinstance(event, events.Failure):
         result = event.code
     elif isinstance(event, events.TestResources):
         cpu.append(event.cpu)
         mem.append(event.mem)
 
 print('Finished testing solution. Result: {1} ({0})'.format(*result))
 if result is tester.OjojCodes.AC and cpu and mem:
     print('Submission cpu: {}'.format(str(cpu)))
     print('Submission mem: {}'.format(str(mem)))
     res = (int(1000*max(cpu)), max(mem))
     api.set(sub, result, res)
 else:
Пример #2
0
@event(events.TestOk)
def test_ok_handler(event):
    stdout.write('\b'*9 + '   {green}{:2s}{none}   |\n'.format(OjojCodes.short(OjojCodes.AC), **colors))
    stdout.write('+----------------------+-----------------+-----------------+--------+\n')
        
@event(events.Accepted)
def accepted_handler(event):
    stdout.write('|   Overall   |   {green}{:2s}{none}   |\n'.format(OjojCodes.short(OjojCodes.AC), **colors))
    stdout.write('+-------------+--------+\n')
    
def default_handler(event):
    print(event)

compiler = tester.languages[args.lang]
for event in tester.flow(compiler, args.source, task, {'tmp_dir': args.tmp, 'test_all': args.all}):
    handler = event_handlers.get(event.__class__, default_handler)
    handler(event)
     

"""
args.tests = map(lambda x : x.split(':'), args.tests)
args.tests = map(lambda x : (x[0], x[1] if len(x) > 1 else 15, x[2] if len(x) > 2 else 256), args.tests)
args.tests = map(lambda (path,cpu,mem) : (path,float(cpu), int(round(float(mem)*1024))), args.tests)

#	print args
try:
#		0.1s / 5s
#		print '+-------------+
    for event in Test(args):
        event = AttributeDict(event)