Skip to content

Commit

Permalink
Catching 502 error (#19)
Browse files Browse the repository at this point in the history
* Catching 502 response from server

* Updated all dependencies.

* Updated lxml to 4.6.3 to resolve security issues.
  • Loading branch information
VadVergasov authored Mar 25, 2021
1 parent a5ab427 commit 38fde98
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
python-version: "3.9"
- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ jobs:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- name: Print Github refs
run: echo ${{github.ref}}
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
Expand All @@ -51,7 +49,7 @@ jobs:
with:
python-version: 3.9
- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
Expand Down
7 changes: 2 additions & 5 deletions codeforces_api/api_request_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

class CodeforcesApiRequestMaker:

_api_key = ""
_secret = ""
_api_key = None
_secret = None
_rand = 0
assigned_rand = False
anonimus = False
Expand Down Expand Up @@ -55,11 +55,8 @@ def generate_request(self, method_name, **fields):
"""
Generates request URL and data for API.
"""

request_url = "https://codeforces.com/api/" + str(method_name)

if not self.anonimus:

# Renew Rand
if not self.assigned_rand:
self.renew_rand()
Expand Down
2 changes: 2 additions & 0 deletions codeforces_api/api_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def _make_request(self, method, **payload):
request = self.session.request(
self.method, request_data["request_url"], data=request_data["data"]
)
if request.status_code == 502:
raise SystemError("Codeforces is unavailable now.")
return self.get_response(request)

def __init__(self, api_key=None, secret=None, random_number=1000000, method="POST"):
Expand Down
2 changes: 1 addition & 1 deletion codeforces_api/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.7"
__version__ = "2.0.8"
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ importlib-metadata==3.7.3
iniconfig==1.1.1
isort==5.8.0
keyring==23.0.0
lazy-object-proxy==1.5.2
lxml==4.6.2
lazy-object-proxy==1.6.0
lxml==4.6.3
mccabe==0.6.1
mypy-extensions==0.4.3
packaging==20.9
Expand Down

0 comments on commit 38fde98

Please sign in to comment.