add tesseract, db to gitignore, update lockfile, change code, add web component
This commit is contained in:
@@ -3,9 +3,12 @@ import psutil
|
||||
import pygetwindow
|
||||
import pyautogui
|
||||
import time
|
||||
import clipboard
|
||||
from src.cursor import classify_cursor, get_current_hcursor
|
||||
import pyperclip as clipboard
|
||||
import getpixelcolor
|
||||
import pytesseract
|
||||
# from src.cursor import classify_cursor, get_current_hcursor
|
||||
|
||||
pytesseract.pytesseract.tesseract_cmd = r".\tesseract\tesseract.exe"
|
||||
|
||||
def is_adis_running():
|
||||
|
||||
@@ -173,6 +176,7 @@ def print_new_signature(catalogue_name:str, print_name:str, mednr:str):
|
||||
pyautogui.press('space') # Simulate pressing space to print
|
||||
|
||||
#sleep as long as the cursor is not arrow, ibeam or hand
|
||||
time.sleep(2)
|
||||
while True:
|
||||
cursor = get_current_hcursor()
|
||||
cursor_name = classify_cursor(cursor)
|
||||
@@ -201,9 +205,51 @@ def new_search():
|
||||
|
||||
|
||||
|
||||
def get_mednr_exempl():
|
||||
keyboard.wait("space")
|
||||
time.sleep(3)
|
||||
while (
|
||||
pyautogui.locateOnScreen(
|
||||
"images/exemplar_ident.png", confidence=0.6, minSearchTime=1
|
||||
)
|
||||
is None
|
||||
):
|
||||
print("waiting")
|
||||
time.sleep(1)
|
||||
|
||||
return pytesseract.image_to_string(pyautogui.screenshot(region=(509, 357, 250, 25)))
|
||||
|
||||
|
||||
def enter_print_mode():
|
||||
pyautogui.keyDown("alt")
|
||||
pyautogui.press("b") # Open the search dialog in Catalogue aDIS
|
||||
pyautogui.press("d")
|
||||
pyautogui.keyUp("alt")
|
||||
time.sleep(5)
|
||||
if pyautogui.locateOnScreen("images/print_btns.png", confidence=0.8):
|
||||
pyautogui.press("space")
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def exit_print_mode():
|
||||
print("Exiting print mode...")
|
||||
time.sleep(2)
|
||||
while getpixelcolor.pixel(1240, 971) != (192, 215, 242):
|
||||
print("Not found")
|
||||
time.sleep(1)
|
||||
# while getpixelcolor.pixel(1240, 971) == (202, 202, 202):
|
||||
# time.sleep(1)
|
||||
# print("Process locked")
|
||||
# time.sleep(1)
|
||||
pyautogui.click(1240, 971) # Click the print button
|
||||
|
||||
print("Exited print mode.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
time.sleep(5) # Wait for a few seconds before starting
|
||||
# print("press space")
|
||||
# commit_changes()
|
||||
#new_search()
|
||||
get_click_locations()
|
||||
get_click_locations()
|
||||
# print(get_mednr_exempl())
|
||||
56
src/adischeck_online.py
Normal file
56
src/adischeck_online.py
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
|
||||
|
||||
import re
|
||||
from playwright.sync_api import Playwright, sync_playwright, expect
|
||||
from src.database import Database
|
||||
import pyperclip as clipboard
|
||||
|
||||
import time
|
||||
def run():
|
||||
browser = sync_playwright().start().chromium.launch(headless=False)
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
page.goto("https://bsz.ibs-bw.de:22998/dap42")
|
||||
page.get_by_role("textbox", name="Benutzer").fill("phfr")
|
||||
page.get_by_role("textbox", name="Benutzer").press("Tab")
|
||||
page.get_by_role("textbox", name="Kennwort").fill("freiburg")
|
||||
page.get_by_role("textbox", name="Kennwort").press("Enter")
|
||||
page.get_by_role("button", name="Katalog").click()
|
||||
page.get_by_role("textbox", name="Mediennummer").click()
|
||||
return page
|
||||
|
||||
def work_on_page(page, mednr: str):
|
||||
db = Database()
|
||||
page.get_by_role("textbox", name="Mediennummer").fill(mednr)
|
||||
page.get_by_text("Suche starten").nth(1).click()
|
||||
page.get_by_text("Ändern").nth(1).click()
|
||||
page.get_by_role("link", name="Sacherschließung").click()
|
||||
page.get_by_role("link", name="Notation, Genre, Signatur").click()
|
||||
page.locator("input[name=\"cellEditValue\\$7\"]").click()
|
||||
page.locator("input[name=\"cellEditValue\\$7\"]").press("ControlOrMeta+a")
|
||||
page.locator("input[name=\"cellEditValue\\$7\"]").press("ControlOrMeta+c")
|
||||
signature = clipboard.paste()
|
||||
print(signature)
|
||||
|
||||
new_signature = db.insert(signature)
|
||||
clipboard.copy(new_signature)
|
||||
|
||||
page.locator("input[name=\"cellEditValue\\$7\"]").fill(new_signature)
|
||||
page.locator("span").filter(has_text="Speichern").click()
|
||||
page.locator("iframe").content_frame.get_by_role("cell", name="Bibliothek der Pädagogischen").get_by_role("checkbox").check()
|
||||
page.get_by_role("list").get_by_text("Gesamtinfo").click()
|
||||
page.get_by_role("button", name="Ändern").click()
|
||||
page.get_by_role("textbox", name="Signatur", exact=True).click()
|
||||
page.get_by_role("textbox", name="Signatur", exact=True).press("ControlOrMeta+a")
|
||||
page.get_by_role("textbox", name="Signatur", exact=True).fill(new_signature)
|
||||
page.locator("span").filter(has_text="Speichern").click()
|
||||
page.get_by_role("button", name="Zurück").click()
|
||||
page.get_by_role("link", name="Bearbeiten").click()
|
||||
page.get_by_role("link", name="Ansigeln/Absigeln").click()
|
||||
page.get_by_role("button", name="Ok").click()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,18 @@ class Database:
|
||||
count = cursor.fetchone()[0]
|
||||
return count > 0
|
||||
|
||||
def insert(self, old_signature: str) -> str | None:
|
||||
table = old_signature.split(" ")[0].lower()
|
||||
if table == "ma":
|
||||
return self.insert_ma(old_signature)
|
||||
elif table == "mb":
|
||||
return self.insert_mb(old_signature)
|
||||
elif table == "mc":
|
||||
return self.insert_mc(old_signature)
|
||||
else:
|
||||
# print(f"Error: Unknown signature type '{table}'. Please use 'ma', 'mb', or 'mc'.")
|
||||
return self.insert_ma(old_signature)
|
||||
|
||||
def insert_ma(self, old_signature: str) -> str|None:
|
||||
"""Insert an old signature into the ma table and return the new signature.
|
||||
New Signatures is generated by using 01 / as prefix, then incrementing the number by 1 for each new entry."""
|
||||
|
||||
Reference in New Issue
Block a user