made to kill fip entrys when 1d passes
This commit is contained in:
18
app/init.py
18
app/init.py
@@ -8,7 +8,7 @@ import os
|
|||||||
import json
|
import json
|
||||||
import mariadb
|
import mariadb
|
||||||
import logging
|
import logging
|
||||||
|
from pathlib import Path
|
||||||
import schedule
|
import schedule
|
||||||
import time
|
import time
|
||||||
import pytz
|
import pytz
|
||||||
@@ -24,7 +24,8 @@ CATEGORIES = [
|
|||||||
]
|
]
|
||||||
SUBCAT_CATEGORIES = ["Klausuren", "Übungen", "Labore"]
|
SUBCAT_CATEGORIES = ["Klausuren", "Übungen", "Labore"]
|
||||||
unizeug_path = os.environ.get("UNIZEUG_PATH", "./unizeug")
|
unizeug_path = os.environ.get("UNIZEUG_PATH", "./unizeug")
|
||||||
|
APP_ROOT_PATH = Path(os.environ.get("APP_ROOT_PATH", "./app"))
|
||||||
|
FILES_IN_PROGRESS = APP_ROOT_PATH / "files/"
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
filename="init.log",
|
filename="init.log",
|
||||||
@@ -78,6 +79,18 @@ except mariadb.OperationalError:
|
|||||||
pass
|
pass
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
def remove_old_FIP_entrys():
|
||||||
|
cur=db.cursor(dictionary=True)
|
||||||
|
cur.execute(
|
||||||
|
"SELECT id,filename FROM FIP WHERE HOUR(TIMEDIFF(NOW(),initTimeStamp)) > 24 "
|
||||||
|
)
|
||||||
|
files=cur.fetchall()
|
||||||
|
info(f"Remove Files: {files}")
|
||||||
|
for file in files:
|
||||||
|
c.execute("DELETE FROM FIP WHERE id=?", (file["id"]))
|
||||||
|
os.remove(FILES_IN_PROGRESS / file["filename"])
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
def get_dirstruct():
|
def get_dirstruct():
|
||||||
# with open("app/pwfile.json", "r") as f:
|
# with open("app/pwfile.json", "r") as f:
|
||||||
@@ -149,6 +162,7 @@ def get_dirstruct():
|
|||||||
(lid, pid, idx, subcat.name),
|
(lid, pid, idx, subcat.name),
|
||||||
)
|
)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
remove_old_FIP_entrys()
|
||||||
|
|
||||||
|
|
||||||
def link_prof(firstname, lastname, lid):
|
def link_prof(firstname, lastname, lid):
|
||||||
|
|||||||
Reference in New Issue
Block a user