def main(args): if args.out and args.filename: raise ValueError('out and filename can not be used together') mission = args.mission[0] filename = args.filename if not filename: filename = ( mission.replace('-', '_') + '.' + conf.default_domain_data['extension'] ) if not args.out: print('Requesting...') data = get_mission_info(mission) code = data['code'] description = data['description'] output = code_for_file(mission, code, None if args.without_info else description) if args.out: print(output) return init_code_file(filename, output) print('Done')
def main_check_cio(args): filename = get_filename(args) mission = args.mission[0] domain_data = conf.default_domain_data if main_run(args): return print() print('Start checking...') print() mission_info = get_mission_info(mission) mission_id = mission_info['id'] with open(filename, encoding="utf-8") as fh: data = check_solution(code_for_check(fh.read()), mission_id) while data: block = data.pop(0) com = block[0] if com == 'start_in': print('*** ' + block[1] + ' ***') elif com == 'in': print('->' + str(block[1])) elif com == 'out': print('<-' + str(block[1])) elif com == 'ext': res = block[1] if not res['result']: print('!!' + str(res['answer'])) elif com == 'check': if block[1]: print() print('!!! Congratulation !!!') print() print( 'Link for checking solution of other users: {}/mission/{}/publications/' .format(domain_data['url_main'], mission)) print() print( 'Link for sharing solution: {}/mission/{}/publications/add/' .format(domain_data['url_main'], mission)) print() else: print('!! Failed !!') elif com == 'wait': print('Waiting for the next piece of data...') time.sleep(block[2]) print('Restore checking...') data = restore(block[1]) else: print(block)
def main(args): mission = args.mission[0] filename = args.filename if filename: print('Requesting...') data = get_mission_info(mission) code = data['code'] description = data['description'] output = code_for_file(mission, code, None if args.without_info else description) if not filename: print(output) return init_code_file(filename, output) print('Done')
def main_check_cio(args): filename = get_filename(args) mission = args.mission[0].replace('_', '-') domain_data = conf.default_domain_data if main_run(args): return print() print('Start checking...') print() mission_info = get_mission_info(mission) mission_id = mission_info['id'] with open(filename, encoding="utf-8") as fh: data = check_solution(code_for_check(fh.read()), mission_id) while data: block = data.pop(0) com = block[0] if com == 'start_in': print('*** ' + block[1] + ' ***' ) elif com == 'in': print('->' + str(block[1])) elif com == 'out': print('<-' + str(block[1])) elif com == 'ext': res = block[1] if not res['result']: print('!!' + str(res['answer'])) elif com == 'check': if block[1]: system_data = { 'info': 'passed', 'solutions_link': '{}/mission/{}/publications/'.format( domain_data['url_main'], mission ), 'add_link': '{}/mission/{}/publications/add/'.format( domain_data['url_main'], mission ) } print() print('!!! Congratulation !!!') print() print('Link for checking solution of other users: ' + system_data['solutions_link']) print() print('Link for sharing solution: ' + system_data['add_link']) print() if args.sysinfo: print(SYSTEM_BLOCK_START) print(json.dumps(system_data, indent=1)) print(SYSTEM_BLOCK_END) else: print('!! Failed !!') elif com == 'wait': print('Waiting for the next piece of data...') time.sleep(block[2]) print('Restore checking...') data = restore(block[1]) else: print(block)