From ab86aa7480698928e85b55d669edcec2a960a265 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 2 Oct 2018 13:11:15 +0200 Subject: test_task.py: fix loading parameters from web for older Pythons --- kpov_judge/test_task.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py index d79c0e5..3fad962 100755 --- a/kpov_judge/test_task.py +++ b/kpov_judge/test_task.py @@ -1,10 +1,10 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import io import yaml import json import urllib.request, urllib.parse, urllib.error -import urllib.request, urllib.error, urllib.parse try: from dialog import Dialog except: @@ -192,8 +192,8 @@ if __name__ == '__main__': task_params.update(gen_params(params['username'], task_params_meta)) # print ("params after: {} {}".format(params, task_params)) if task_url.startswith('http'): - req = urllib.request.Request("{task_url}/{task_name}/params.json".format(**params)) - web_task_params = json.load(urllib.request.urlopen(req)) + response = urllib.request.urlopen('{task_url}/{task_name}/params.json'.format(**params)) + web_task_params = json.load(io.TextIOWrapper(response)) task_params.update(web_task_params) params_argparser = argparse.ArgumentParser(parents=[argparser], conflict_handler='resolve', add_help=True) params_argparser = add_meta_to_argparser(params_argparser, task_params_meta, defaults=task_params) -- cgit v1.2.1