Skip to content

Commit 38fde98

Browse files
authored
Catching 502 error (#19)
* Catching 502 response from server * Updated all dependencies. * Updated lxml to 4.6.3 to resolve security issues.
1 parent a5ab427 commit 38fde98

File tree

6 files changed

+10
-13
lines changed

6 files changed

+10
-13
lines changed

.github/workflows/codestyle.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
python-version: "3.9"
2222
- name: Cache pip
23-
uses: actions/cache@v2
23+
uses: actions/cache@v2.1.4
2424
with:
2525
path: ~/.cache/pip
2626
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}

.github/workflows/publish.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ jobs:
1919
matrix:
2020
python-version: [3.6, 3.7, 3.8, 3.9]
2121
steps:
22-
- name: Print Github refs
23-
run: echo ${{github.ref}}
2422
- uses: actions/checkout@v2
2523
- name: Set up Python ${{ matrix.python-version }}
2624
uses: actions/setup-python@v2
2725
with:
2826
python-version: ${{ matrix.python-version }}
2927
- name: Cache pip
30-
uses: actions/cache@v2
28+
uses: actions/cache@v2.1.4
3129
with:
3230
path: ~/.cache/pip
3331
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
@@ -51,7 +49,7 @@ jobs:
5149
with:
5250
python-version: 3.9
5351
- name: Cache pip
54-
uses: actions/cache@v2
52+
uses: actions/cache@v2.1.4
5553
with:
5654
path: ~/.cache/pip
5755
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}

codeforces_api/api_request_maker.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
class CodeforcesApiRequestMaker:
2525

26-
_api_key = ""
27-
_secret = ""
26+
_api_key = None
27+
_secret = None
2828
_rand = 0
2929
assigned_rand = False
3030
anonimus = False
@@ -55,11 +55,8 @@ def generate_request(self, method_name, **fields):
5555
"""
5656
Generates request URL and data for API.
5757
"""
58-
5958
request_url = "https://codeforces.com/api/" + str(method_name)
60-
6159
if not self.anonimus:
62-
6360
# Renew Rand
6461
if not self.assigned_rand:
6562
self.renew_rand()

codeforces_api/api_requests.py

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def _make_request(self, method, **payload):
5050
request = self.session.request(
5151
self.method, request_data["request_url"], data=request_data["data"]
5252
)
53+
if request.status_code == 502:
54+
raise SystemError("Codeforces is unavailable now.")
5355
return self.get_response(request)
5456

5557
def __init__(self, api_key=None, secret=None, random_number=1000000, method="POST"):

codeforces_api/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.0.7"
1+
__version__ = "2.0.8"

requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ importlib-metadata==3.7.3
1414
iniconfig==1.1.1
1515
isort==5.8.0
1616
keyring==23.0.0
17-
lazy-object-proxy==1.5.2
18-
lxml==4.6.2
17+
lazy-object-proxy==1.6.0
18+
lxml==4.6.3
1919
mccabe==0.6.1
2020
mypy-extensions==0.4.3
2121
packaging==20.9

0 commit comments

Comments
 (0)