Skip to content

Commit

Permalink
rmatics-endpoint (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
shestimerov authored Aug 5, 2024
1 parent c622021 commit 321dac3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
9 changes: 5 additions & 4 deletions pynformatics/view/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def problem_submits(request):
if course_id > 0:
_data["context_source"] = CONTEXT_SHIFT + course_id

url = 'http://localhost:12346/problem/trusted/{}/submit_v2'.format(problem_id)
url = '{}/problem/trusted/{}/submit_v2'.format(request.registry.settings['rmatics.endpoint'], problem_id)
_resp = requests.post(url, files={'file': input_file}, data=_data)
return _resp.json()
except Exception as e:
Expand Down Expand Up @@ -235,11 +235,12 @@ def problem_runs_filter_proxy(request):
except Exception as exc:
pass

url = '{}/problem/{}/submissions/'.format(request.registry.settings['rmatics.endpoint'], problem_id)
try:
if user_ids:
resp = requests.post('http://localhost:12346/problem/{}/submissions/'.format(problem_id), json={"user_ids": user_ids}, params=params)
resp = requests.post(url, json={"user_ids": user_ids}, params=params)
else:
resp = requests.get('http://localhost:12346/problem/{}/submissions/'.format(problem_id), params=params)
resp = requests.get(url, params=params)
res = resp.json()

course_id = 0
Expand Down Expand Up @@ -268,7 +269,7 @@ def problem_get_run_source(request):
return {'result': 'error', 'message': 'Not authorized'}

try:
url = 'http://localhost:12346/problem/run/{}/source/'.format(run_id)
url = '{}/problem/run/{}/source/'.format(request.registry.settings['rmatics.endpoint'], run_id)
resp = requests.get(url, params=params)
return resp.json()
except (requests.RequestException, ValueError) as e:
Expand Down
6 changes: 3 additions & 3 deletions pynformatics/view/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_protocol(request):
return {'result': 'error', 'message': 'Not authorized'}

run_id = int(request.matchdict['run_id'])
url = 'http://localhost:12346/problem/run/{}/protocol'.format(run_id)
url = '{}/problem/run/{}/protocol'.format(request.registry.settings['rmatics.endpoint'], run_id)
response = requests.get(url, params=params)
content = response.json()

Expand Down Expand Up @@ -90,7 +90,7 @@ def protocol_get_full(request):
run_id = int(request.matchdict['run_id'])
user_id = RequestGetUserId(request)

url = 'http://localhost:12346/problem/run/{}/protocol'.format(run_id)
url = '{}/problem/run/{}/protocol'.format(request.registry.settings['rmatics.endpoint'], run_id)
response = requests.get(url, params={'user_id':user_id, 'is_admin': True})
content = response.json()

Expand Down Expand Up @@ -182,7 +182,7 @@ def get_submit_archive(request):

if request_source:
# Download source and info about run
url = 'http://localhost:12346/problem/run/{}/source/'.format(run_id)
url = '{}/problem/run/{}/source/'.format(request.registry.settings['rmatics.endpoint'], run_id)
try:
resp = requests.get(url, {'is_admin': True})
resp.raise_for_status()
Expand Down
4 changes: 2 additions & 2 deletions pynformatics/view/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def update_run(request):

# 99 is Перетестировать
if new_status and int(new_status) == 99:
url = 'http://localhost:12346/problem/run/{}/action/rejudge'.format(run_id)
url = '{}/problem/run/{}/action/rejudge'.format(request.registry.settings['rmatics.endpoint'], run_id)
request_func = requests.post
request_kwargs = {}
else:
url = 'http://localhost:12346/problem/run/{}'.format(run_id)
url = '{}/problem/run/{}'.format(request.registry.settings['rmatics.endpoint'], run_id)
request_func = requests.put
request_kwargs = {'json': body_params}

Expand Down
4 changes: 2 additions & 2 deletions pynformatics/view/team_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _get_contests_info(cls, problems: List[Dict]) -> Dict:

@classmethod
def _get_monitor(cls, internal_link) -> dict:
url = 'http://localhost:12346/monitor?{}'.format(internal_link)
url = '{}/monitor?{}'.format(request.registry.settings['rmatics.endpoint'], internal_link)

try:
resp = requests.get(url, timeout=30)
Expand All @@ -200,7 +200,7 @@ def _get_monitor(cls, internal_link) -> dict:

@classmethod
def _get_monitor_by_user_ids(cls, cmid, moodle_group_id, internal_link, request) -> dict:
url = 'http://localhost:12346/monitor?{}'.format(internal_link)
url = '{}/monitor?{}'.format(request.registry.settings['rmatics.endpoint'], internal_link)

try:
user_ids = GetUserIds(request, cmid, moodle_group_id)
Expand Down

0 comments on commit 321dac3

Please sign in to comment.