Skip to content

Commit

Permalink
fix: problem with validation error if login expired (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanato12 authored Dec 13, 2024
1 parent 992a709 commit f5fc9d6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint_python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ on:
branches:
- develop
pull_request:
paths:
- "**.py"
- pyproject.toml
- requirements-dev.txt
- requirements.txt
- setup.cfg

jobs:
setup:
Expand Down Expand Up @@ -61,7 +67,7 @@ jobs:
password: ${{ secrets.PYPI_TOKEN }}

test-pypi:
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
needs: setup
runs-on: ubuntu-latest
environment:
Expand Down
16 changes: 8 additions & 8 deletions line_works/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from os import makedirs
from os.path import exists
from os.path import join as path_join
from typing import Any, Optional
from typing import Any

from pydantic import BaseModel, Field
from requests import HTTPError, JSONDecodeError, Response, Session
from pydantic import BaseModel, Field, ValidationError
from requests import HTTPError, JSONDecodeError, Session

from line_works import config
from line_works.decorator import save_cookie
Expand Down Expand Up @@ -46,19 +46,19 @@ def model_post_init(self, __context: Any) -> None:
makedirs(self.session_dir, exist_ok=True)
self.session.headers.update(config.HEADERS)

r: Optional[Response] = None

if exists(self.cookie_path):
# login with cookie
with open(self.cookie_path) as j:
c = json.load(j)
self.session.cookies.update(c)
r = self.session.get(TalkURL.HOST, allow_redirects=False)

if not r or r.status_code != 200:
try:
my_info = self.get_my_info()
except ValidationError as _:
self.session.cookies.clear()
self.login_with_id()
my_info = self.get_my_info()

my_info = self.get_my_info()
self.tenant_id = my_info.tenant_id
self.domain_id = my_info.domain_id
self.contact_no = my_info.contact_no
Expand Down

0 comments on commit f5fc9d6

Please sign in to comment.