Skip to content

Commit

Permalink
Remove Selenium, Yeeah!
Browse files Browse the repository at this point in the history
  • Loading branch information
KarimullinArthur committed Feb 6, 2025
1 parent afe676d commit fddf0bf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 91 deletions.
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@
pipx install bonchcli
```

> Это херня пока работает только с Селениумом, так что придётся поставить его, пока я не решил тикет [#5](https://github.com/KarimullinArthur/BonchAPI/issues/5)
~> Это херня пока работает только с Селениумом, так что придётся поставить его, пока я не решил тикет [#5](https://github.com/KarimullinArthur/BonchAPI/issues/5)~

### Selemium driver
Если сидишь на Харче можешь бахнуть

```
sudo pacman -S chromium
```

Я надеюсь как можно быстрее избавиться от этой фигни, так что подробно даже писать не хочу.
## Использование

```
Expand Down
31 changes: 0 additions & 31 deletions bonchcli/bonchcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from bonchapi import BonchAPI
from bonchapi.bonchapi import AuthError

from .get_token_from_browser import Brow
from .config_manager import cm, Config
from . import formatting

Expand Down Expand Up @@ -38,37 +37,7 @@ async def main():
args = parser.parse_args()

api = BonchAPI()

await api.login(config.mail, config.password)

api.cookies = {}

def write_brow_token():
browser = Brow(config)
token = browser.get_token()
setattr(api, "cookies", {})
with open("/tmp/bonch-token", "w") as file:
file.write(token)
api.cookies["miden"] = token

def read_token_from_cache():
with open("/tmp/bonch-token", "r") as file:
token = file.readline()
api.cookies["miden"] = token

write_brow_token()

try:
read_token_from_cache()
except FileNotFoundError:
write_brow_token()

try:
rsp = await api.get_timetable(week_offset=args.week_offset)
except AuthError:
write_brow_token()


rsp = await api.get_timetable(week_offset=args.week_offset)

formatting.render_timetable(rsp)
Expand Down
6 changes: 0 additions & 6 deletions bonchcli/config.toml

This file was deleted.

43 changes: 0 additions & 43 deletions bonchcli/get_token_from_browser.py

This file was deleted.

10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bonchcli"
version = "0.0.2"
version = "0.0.3"
description = "lk.sut.ru console client"
authors = ["Karimullin Arthur <[email protected]>"]
readme = "README.md"
Expand All @@ -12,12 +12,18 @@ packages = [
[tool.poetry.dependencies]
python = "^3.12"
selenium = "^4.28.0"
bonchapi = "0.0.4"
bonchapi = "0.0.5"
tomlkit = "^0.13.2"

[tool.poetry.scripts]
bonchcli = "bonchcli.bonchcli:sync_main"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.4"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[pytest]
pythonpath = "bonchcli"

0 comments on commit fddf0bf

Please sign in to comment.