Compare commits
1 Commits
dev
...
renovate/c
| Author | SHA1 | Date | |
|---|---|---|---|
| f7b52104c7 |
@@ -4,8 +4,4 @@ version = "0.1.0"
|
|||||||
description = "Add your description here"
|
description = "Add your description here"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.13"
|
requires-python = ">=3.13"
|
||||||
dependencies = [
|
dependencies = []
|
||||||
"cryptography>=44.0.2",
|
|
||||||
"loguru>=0.7.3",
|
|
||||||
"playwright>=1.50.0",
|
|
||||||
]
|
|
||||||
|
|||||||
3
renovate.json
Normal file
3
renovate.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||||
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import sqlite3
|
|
||||||
|
|
||||||
|
|
||||||
class Database:
|
|
||||||
def __init__(self):
|
|
||||||
self.conn = sqlite3.connect("database.db")
|
|
||||||
self.cursor = self.conn.cursor()
|
|
||||||
self.create_table()
|
|
||||||
|
|
||||||
def create_table(self):
|
|
||||||
self.cursor.execute(
|
|
||||||
"CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username TEXT, password TEXT)"
|
|
||||||
)
|
|
||||||
self.conn.commit()
|
|
||||||
|
|
||||||
def add_user(self, username, password):
|
|
||||||
self.cursor.execute(
|
|
||||||
"INSERT INTO users (username, password) VALUES (?, ?)", (username, password)
|
|
||||||
)
|
|
||||||
self.conn.commit()
|
|
||||||
|
|
||||||
def get_password(self, username):
|
|
||||||
self.cursor.execute(
|
|
||||||
"SELECT password FROM users WHERE username = ?", (username,)
|
|
||||||
)
|
|
||||||
return self.cursor.fetchone()
|
|
||||||
|
|
||||||
def change_password(self, username, password):
|
|
||||||
self.cursor.execute(
|
|
||||||
"UPDATE users SET password = ? WHERE username = ?", (password, username)
|
|
||||||
)
|
|
||||||
self.conn.commit()
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
from mfrc522 import SimpleMFRC522
|
|
||||||
from RPLCD.i2c import CharLCD
|
|
||||||
from RPi import GPIO
|
|
||||||
|
|
||||||
|
|
||||||
class Display:
|
|
||||||
def __init__(self, i2c_address=0x27, cols=16, rows=2):
|
|
||||||
self.lcd = CharLCD(
|
|
||||||
i2c_expander="PCF8574",
|
|
||||||
address=i2c_address,
|
|
||||||
port=1,
|
|
||||||
cols=cols,
|
|
||||||
rows=rows,
|
|
||||||
backlight_enabled=True,
|
|
||||||
)
|
|
||||||
GPIO.setmode(GPIO.BCM)
|
|
||||||
|
|
||||||
def display_message(self, message1, message2=None):
|
|
||||||
"""Display a message on the LCD."""
|
|
||||||
self.lcd.clear()
|
|
||||||
self.lcd.write_string(message1)
|
|
||||||
if message2:
|
|
||||||
self.lcd.crlf() # Move to the second line
|
|
||||||
self.lcd.write_string(message2)
|
|
||||||
|
|
||||||
def cleanup(self):
|
|
||||||
GPIO.cleanup()
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
import re
|
|
||||||
from playwright.sync_api import Playwright, sync_playwright, expect
|
|
||||||
import time
|
|
||||||
|
|
||||||
import loguru
|
|
||||||
import sys
|
|
||||||
|
|
||||||
log = loguru.logger
|
|
||||||
log.remove()
|
|
||||||
log.add("management.log", rotation="1 week", retention="1 month")
|
|
||||||
log.add(sys.stdout)
|
|
||||||
|
|
||||||
|
|
||||||
def run(playwright: Playwright) -> None:
|
|
||||||
browser = playwright.chromium.launch(headless=False)
|
|
||||||
context = browser.new_context()
|
|
||||||
page = context.new_page()
|
|
||||||
page.goto("https://lsf.ph-freiburg.de/qisfsvfr/rds?state=user&type=0")
|
|
||||||
page.get_by_label("Benutzerkennung").click()
|
|
||||||
page.get_by_label("Benutzerkennung").fill(USER)
|
|
||||||
page.get_by_label("Passwort").click()
|
|
||||||
page.get_by_label("Passwort").fill(PASSWORD)
|
|
||||||
page.get_by_role("button", name="Anmelden").click()
|
|
||||||
page.get_by_role("link", name="Zeiterfassung").click()
|
|
||||||
page.locator("#makronavigation").get_by_role("link", name="Zeiterfassung").click()
|
|
||||||
time.sleep(1)
|
|
||||||
get_overtime(page)
|
|
||||||
|
|
||||||
context.close()
|
|
||||||
browser.close()
|
|
||||||
|
|
||||||
|
|
||||||
def get_overtime(page):
|
|
||||||
table = (
|
|
||||||
page.get_by_role("cell", name="Überstunden:", exact=False)
|
|
||||||
.get_by_role("table")
|
|
||||||
.first
|
|
||||||
)
|
|
||||||
rows = table.locator("tr").all()
|
|
||||||
|
|
||||||
# Extract data from each row
|
|
||||||
for row in rows:
|
|
||||||
cells = row.locator("td").all_text_contents()
|
|
||||||
celltext = " ".join(cells)
|
|
||||||
if "Aktuell" in celltext and "Stunden" in celltext:
|
|
||||||
continue
|
|
||||||
elif "Aktuell" in celltext:
|
|
||||||
# get the time, can be negative or positive with : for hh:mm
|
|
||||||
# regex to find the time in the string
|
|
||||||
match = re.search(r"[-+]?\d{1,3}:\d{2}", celltext)
|
|
||||||
if match:
|
|
||||||
# Extract the time string
|
|
||||||
time_str = match.group()
|
|
||||||
return time_str
|
|
||||||
else:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
with sync_playwright() as playwright:
|
|
||||||
run(playwright)
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import cryptography
|
|
||||||
from cryptography.fernet import Fernet
|
|
||||||
from .database import Database
|
|
||||||
|
|
||||||
# import library to create a random key
|
|
||||||
import random
|
|
||||||
|
|
||||||
|
|
||||||
def set_data():
|
|
||||||
user = input("Enter username: ")
|
|
||||||
fernet_key = Fernet.generate_key()
|
|
||||||
with open("key.key", "w") as key_file:
|
|
||||||
key = f"{user}|{fernet_key.decode()}"
|
|
||||||
key_file.write(key)
|
|
||||||
|
|
||||||
# ask for password, do not show the password
|
|
||||||
password = input("Enter password: ")
|
|
||||||
# encrypt the password
|
|
||||||
cipher_suite = Fernet(fernet_key)
|
|
||||||
ciphered_text = cipher_suite.encrypt(password.encode())
|
|
||||||
db = Database()
|
|
||||||
db.add_user(user, ciphered_text)
|
|
||||||
|
|
||||||
|
|
||||||
def get_data():
|
|
||||||
with open("key.key", "r") as key_file:
|
|
||||||
key = key_file.read()
|
|
||||||
|
|
||||||
user = key.split("|")[0]
|
|
||||||
key = key.split("|")[1]
|
|
||||||
db = Database()
|
|
||||||
password = db.get_password(user)
|
|
||||||
cipher_suite = Fernet(key)
|
|
||||||
# decrypt the password
|
|
||||||
plain_text = cipher_suite.decrypt(password[0])
|
|
||||||
print(plain_text.decode())
|
|
||||||
Reference in New Issue
Block a user