notebook
This commit is contained in:
52
Functions.py
52
Functions.py
@@ -5,6 +5,46 @@ import pymysql
|
||||
from pymysql.cursors import DictCursor
|
||||
import socket
|
||||
|
||||
import socket
|
||||
import unicodedata
|
||||
|
||||
def get_reports_folder():
|
||||
hostname = socket.gethostname().strip().upper()
|
||||
if hostname in ("NTBVBHP470G10", "Z230"):
|
||||
return r"u:\Dropbox\!!!Days\Downloads Z230"
|
||||
elif hostname in ["SESTRA","POHODA","LEKAR"]:
|
||||
return r"z:\Dropbox\Ordinace\Reporty"
|
||||
else:
|
||||
print(f"Unknown host: {hostname}")
|
||||
return None
|
||||
|
||||
|
||||
def get_dropbox_path(cesta):
|
||||
hostname = socket.gethostname().strip().upper()
|
||||
if hostname not in ("SESTRA", "LEKAR", "POHODA", "NTBVBHP470G10", "Z230"):
|
||||
print(f"Unknown host: {hostname}")
|
||||
return None
|
||||
|
||||
# Choose root path based on hostname
|
||||
if hostname in ("NTBVBHP470G10", "Z230"):
|
||||
zacatek = r"U:\Dropbox"
|
||||
else:
|
||||
zacatek = r"Z:\Dropbox"
|
||||
|
||||
# Normalize text (optional, safer for diacritics)
|
||||
cesta_norm = unicodedata.normalize("NFC", cesta).upper().strip()
|
||||
|
||||
if cesta_norm == "PŘIJATÁ":
|
||||
return rf"{zacatek}\ordinace\Dokumentace_přijatá"
|
||||
elif cesta_norm == "ZPRACOVANÁ":
|
||||
return rf"{zacatek}\ordinace\Dokumentace_zpracovaná"
|
||||
elif cesta_norm == "REPORTY":
|
||||
return rf"{zacatek}\ordinace\reporty"
|
||||
else:
|
||||
print(f"Unknown cesta: {cesta}")
|
||||
return None
|
||||
|
||||
|
||||
def get_path_ciselniky():
|
||||
hostname = socket.gethostname().strip()
|
||||
if hostname in ("NTBVBHP470G10", "Z230"):
|
||||
@@ -35,7 +75,7 @@ def get_mysql_connection(cursor_mode=None):
|
||||
database="medevio",
|
||||
autocommit=True,
|
||||
)
|
||||
elif hostname == "SESTRA":
|
||||
elif hostname== "SESTRA":
|
||||
MYSQL_CFG = dict(
|
||||
host="127.0.0.1",
|
||||
port=3307,
|
||||
@@ -73,14 +113,20 @@ def get_medicus_connection():
|
||||
password="masterkey",
|
||||
charset="win1250",
|
||||
)
|
||||
elif socket.gethostname().strip()=="SESTRA":
|
||||
elif socket.gethostname().strip() in ("SESTRA","POHODA"):
|
||||
MEDICUS_CFG = dict(
|
||||
dsn=r"192.168.1.10:m:\medicus\data\medicus.fdb",
|
||||
user="SYSDBA",
|
||||
password="masterkey",
|
||||
charset="win1250",
|
||||
)
|
||||
|
||||
elif socket.gethostname().strip()=="LEKAR":
|
||||
MEDICUS_CFG = dict(
|
||||
dsn=r"localhost:m:\medicus\data\medicus.fdb",
|
||||
user="SYSDBA",
|
||||
password="masterkey",
|
||||
charset="win1250",
|
||||
)
|
||||
try:
|
||||
return fdb.connect(**MEDICUS_CFG)
|
||||
except fdb.fbcore.DatabaseError as e:
|
||||
|
||||
Reference in New Issue
Block a user