mirror of
https://github.com/szymon-jozef/zutui.git
synced 2026-09-07 12:10:43 +02:00
Compare commits
2 Commits
pkg/pkgbui
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79baa5f1c6 | ||
| b4066e0c47 |
31
PKGBUILD
31
PKGBUILD
@@ -1,31 +0,0 @@
|
||||
# Maintainer: <szymon_jozef@proton.me>
|
||||
_pkgname="zutui"
|
||||
pkgname="$_pkgname-git"
|
||||
pkgver=1.0.0
|
||||
pkgrel=1
|
||||
pkgdesc="TUI for accessing edziekanat of ZUT university"
|
||||
arch=("any")
|
||||
url="https://github.com/shv187/zutui"
|
||||
license=("MIT")
|
||||
depends=("python" "python-keyring" "python-textual")
|
||||
makedepends=("git" "python-build" "python-installer" "python-wheel" "python-setuptools")
|
||||
provides=("zutui")
|
||||
conflicts=("zutui")
|
||||
source=("$_pkgname::git+${url}.git")
|
||||
sha256sums=("SKIP")
|
||||
|
||||
pkgver() {
|
||||
cd "$_pkgname"
|
||||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "$_pkgname"
|
||||
python -m build --wheel --no-isolation
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$_pkgname"
|
||||
python -m installer --destdir="$pkgdir" dist/*.whl
|
||||
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
}
|
||||
35
README.md
35
README.md
@@ -10,31 +10,15 @@
|
||||
<img width="100%" height="auto" alt="Grades Page" src="https://github.com/user-attachments/assets/6536c74d-13a5-436e-af3d-5522216ce8c1" />
|
||||
|
||||
# Usage
|
||||
## 1. Download:
|
||||
### On Windows:
|
||||
### 1. Download:
|
||||
```
|
||||
pip install git+https://github.com/shv187/zutui.git
|
||||
```
|
||||
### Arch Linux:
|
||||
You can use PKGBUILD. Just run:
|
||||
```bash
|
||||
makepkg -si
|
||||
```
|
||||
or if you want to, you can use AUR helper of your choice. For example:
|
||||
```bash
|
||||
yay -S zutui-git
|
||||
```
|
||||
### MacOs and other Linux distros:
|
||||
Most distros environments are externally managed by the system package manager, so the most straightforward way would be using something like `pipx`.
|
||||
```bash
|
||||
pipx install git+https://github.com/shv187/zutui.git
|
||||
```
|
||||
|
||||
## 2. Start:
|
||||
### 2. Start:
|
||||
```
|
||||
zutui
|
||||
```
|
||||
## 3. Enjoy :)
|
||||
### 3. Enjoy :)
|
||||
|
||||
# Bindings
|
||||
`j` - Down
|
||||
@@ -46,12 +30,17 @@ zutui
|
||||
`ctrl`+`q` - Quit
|
||||
|
||||
# Sidenotes
|
||||
## Config
|
||||
- On Unix like is stored @ `~/.config/zutui/config.json`
|
||||
- On Windows is stored @ `~/zutui/config.json`
|
||||
- config is stored @ `~/zutui/config.json`
|
||||
- so are `grades_cache.json`
|
||||
- in plaintext.....
|
||||
|
||||
##### Feel free to pull request if you're smarter :)
|
||||
##### As of right now I don't see any MUCH better way.
|
||||
|
||||
##### I mean we could simply encrypt and decrypt it during runtime, but... does it really make it any more secure?
|
||||
|
||||
##### And we can't really store it in any form of a _hash_ as we have to log in everytime with plain text anyways...
|
||||
|
||||
##### However feel free to pull request if you're smarter :)
|
||||
|
||||
# TODO:
|
||||
- [x] **Nothing**
|
||||
|
||||
4
setup.py
4
setup.py
@@ -8,12 +8,10 @@ setup(
|
||||
"requests",
|
||||
"beautifulsoup4",
|
||||
"textual",
|
||||
"keyring",
|
||||
"pywin32; sys_platform == 'win32'"
|
||||
],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'zutui=zut_app.zutui:main',
|
||||
],
|
||||
},
|
||||
)
|
||||
)
|
||||
@@ -1,19 +0,0 @@
|
||||
import os
|
||||
import platform
|
||||
|
||||
USER_HOME = os.path.expanduser("~")
|
||||
WINDOWS_PATH = "zutui" # probably should be in %AppData% or something, but I'm not sure, so I won't change it
|
||||
LINUX_PATH = ".config/zutui"
|
||||
|
||||
def get_config_path():
|
||||
system = platform.system()
|
||||
if system == "Windows":
|
||||
APP_DIR = os.path.join(USER_HOME, WINDOWS_PATH)
|
||||
elif system in ["Linux", "Darwin"]:
|
||||
APP_DIR = os.path.join(USER_HOME, LINUX_PATH)
|
||||
else:
|
||||
print(f"System {system} not supported, aborting...")
|
||||
exit(1)
|
||||
if not os.path.exists(APP_DIR):
|
||||
os.makedirs(APP_DIR)
|
||||
return APP_DIR
|
||||
@@ -1,14 +1,16 @@
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import json
|
||||
import os
|
||||
|
||||
from .config import get_config_path
|
||||
|
||||
APP_DIR = get_config_path()
|
||||
USER_HOME = os.path.expanduser("~")
|
||||
APP_DIR = os.path.join(USER_HOME, "zutui")
|
||||
if not os.path.exists(APP_DIR):
|
||||
os.makedirs(APP_DIR)
|
||||
|
||||
CACHE_FILE = os.path.join(APP_DIR, "grades_cache.json")
|
||||
TIMEOUT = 10
|
||||
TIMEOUT = 10
|
||||
|
||||
class ZUT:
|
||||
URLS = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
import json
|
||||
import os
|
||||
import keyring
|
||||
from keyring.errors import KeyringError
|
||||
import time
|
||||
from datetime import datetime
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Container
|
||||
@@ -10,9 +10,11 @@ from textual.screen import Screen
|
||||
from textual.binding import Binding
|
||||
|
||||
from .zut_client import ZUT
|
||||
from .config import get_config_path
|
||||
|
||||
APP_DIR = get_config_path()
|
||||
USER_HOME = os.path.expanduser("~")
|
||||
APP_DIR = os.path.join(USER_HOME, "zutui")
|
||||
if not os.path.exists(APP_DIR):
|
||||
os.makedirs(APP_DIR)
|
||||
|
||||
CONFIG_FILE = os.path.join(APP_DIR, "config.json")
|
||||
REFRESH_INTERVAL = 1800
|
||||
@@ -56,20 +58,9 @@ class LoginScreen(Screen):
|
||||
if success:
|
||||
try:
|
||||
with open(CONFIG_FILE, "w") as f:
|
||||
json.dump({"username": user}, f)
|
||||
keyring.set_password("zutui", user, password)
|
||||
except KeyringError as e:
|
||||
error = e
|
||||
self.app.call_from_thread(
|
||||
lambda:
|
||||
self.app.notify(
|
||||
f"Błąd: {str(error)}",
|
||||
title="Błąd zapisu hasła do systemowego menedżera haseł",
|
||||
severity="warning",
|
||||
timeout=5
|
||||
)
|
||||
)
|
||||
json.dump({"username": user, "password": password}, f)
|
||||
except: pass
|
||||
|
||||
def do_switch():
|
||||
self.app.switch_screen(DashboardScreen())
|
||||
self.app.call_from_thread(do_switch)
|
||||
@@ -419,10 +410,7 @@ class ZutApp(App):
|
||||
try:
|
||||
with open(CONFIG_FILE, "r") as f:
|
||||
creds = json.load(f)
|
||||
password = keyring.get_password("zutui", creds["username"])
|
||||
if password is None:
|
||||
raise ValueError("Hasło nie zostało znalezione")
|
||||
self.zut_client = ZUT(creds["username"], password)
|
||||
self.zut_client = ZUT(creds["username"], creds["password"])
|
||||
self.push_screen(DashboardScreen())
|
||||
except:
|
||||
self.push_screen(LoginScreen())
|
||||
|
||||
Reference in New Issue
Block a user