Skip to content

Commit 7aa6b5f

Browse files
committed
Added error handle
Added handle for http 414 error
1 parent d5e525f commit 7aa6b5f

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

codeforces_api/api_request_maker.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import time
33
import hashlib
44
import collections
5+
import json
56

67

78
class CodeforcesApiRequestMaker:
@@ -113,6 +114,9 @@ def renew_rand(self, random_number=1000000):
113114
)
114115

115116
def get_response(self, request):
116-
response = request.json()
117-
self.check_return_code(response)
118-
return response
117+
try:
118+
response = request.json()
119+
self.check_return_code(response)
120+
return response
121+
except json.decoder.JSONDecodeError as error:
122+
raise ValueError("A lot of users, try ")

codeforces_api/api_requests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def contest_standings(
7878
Get contest.standings for contest, contest_id required.
7979
From is replaced with a start, because from is reserved python word.
8080
Count defines how many submits will be returned.
81-
Handles should be a list of handles to get (max 10000).
81+
Handles should be a list of handles to get (max 10000) but it is recommended to use less then 500, because http request length is set to 8000.
8282
Room is the number of the room which is needed.
8383
Show_unofficial is used for adding or removing not official participants.
8484
Returns parsed response from codeforces.com.
@@ -207,7 +207,7 @@ def user_friends(self, only_online=False):
207207
def user_info(self, handles):
208208
"""
209209
Get user.info.
210-
Handles should be a list of users, up to 10000.
210+
Handles should be a list of users, up to 10000 but it is recommended to use less then 500, because http request length is set to 8000.
211211
Returns parsed response from codeforces.com.
212212
"""
213213
if not isinstance(handles, list):

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="CodeforcesApiPy",
8-
version="1.2.1",
8+
version="1.2.2",
99
description="Implementation of codeforces.com API",
1010
platforms="any",
1111
url="https://github.com/VadVergasov/CodeforcesApiPy",

tests/main.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Testing module work.
33
"""
44

5-
import conf
65
import codeforces_api
6+
import conf
77

88
MAIN = codeforces_api.CodeforcesApi(conf.API_KEY, conf.API_SECRET)
99

@@ -27,4 +27,3 @@
2727
USER_STATUS = MAIN.user_status("VadVergasov")
2828

2929
SOLUTION = PARSER.get_solution(1322, 72628149)
30-

0 commit comments

Comments
 (0)