in between state before converting to pathlib
This commit is contained in:
17
app/init.py
17
app/init.py
@@ -10,7 +10,8 @@ import mariadb
|
||||
import logging
|
||||
|
||||
import schedule
|
||||
import time
|
||||
import time
|
||||
import pytz
|
||||
|
||||
CATEGORIES = [
|
||||
"Prüfungen",
|
||||
@@ -22,7 +23,7 @@ CATEGORIES = [
|
||||
"Multimedia",
|
||||
]
|
||||
SUBCAT_CATEGORIES = ["Klausuren", "Übungen", "Labore"]
|
||||
unizeug_path = os.environ.get("UNIZEUG_PATH","./unizeug")
|
||||
unizeug_path = os.environ.get("UNIZEUG_PATH", "./unizeug")
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
logging.basicConfig(
|
||||
@@ -39,7 +40,6 @@ db = mariadb.connect(
|
||||
user=os.environ.get("DB_USER", "user"),
|
||||
password=os.environ.get("DB_PASSWORD", "DBPASSWORD"),
|
||||
database=os.environ.get("DB_DATABASE", "unizeug"),
|
||||
|
||||
)
|
||||
c = db.cursor()
|
||||
try:
|
||||
@@ -71,7 +71,9 @@ c.execute(
|
||||
"CREATE TABLE SubCats(id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,LId BIGINT(20),PId BIGINT(20),cat TINYINT UNSIGNED,name VARCHAR(256), PRIMARY KEY(id))"
|
||||
)
|
||||
try:
|
||||
c.execute("CREATE TABLE FIP(id UUID DEFAULT(UUID()), filename VARCHAR(256), filetype VARCHAR(8),initTimeStamp DATETIME, PRIMARY KEY(id))")
|
||||
c.execute(
|
||||
"CREATE TABLE FIP(id UUID DEFAULT(UUID()), filename VARCHAR(256), filetype VARCHAR(8),initTimeStamp DATETIME, PRIMARY KEY(id))"
|
||||
)
|
||||
except mariadb.OperationalError:
|
||||
pass
|
||||
db.commit()
|
||||
@@ -79,7 +81,7 @@ db.commit()
|
||||
|
||||
def get_dirstruct():
|
||||
# with open("app/pwfile.json", "r") as f:
|
||||
# cred = json.load(f)
|
||||
# cred = json.load(f)
|
||||
# ssh = paramiko.SSHClient()
|
||||
# print(cred["sftpurl"])
|
||||
# ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
@@ -88,7 +90,7 @@ def get_dirstruct():
|
||||
# ssh.connect(cred["sftpurl"], username=cred["sftpuser"], password=cred["sftpPW"])
|
||||
# sftp = ssh.open_sftp()
|
||||
# folders = sftp.listdir_attr(unizeug_path)
|
||||
folders=pathlib.Path(unizeug_path)
|
||||
folders = pathlib.Path(unizeug_path)
|
||||
for entry in folders.iterdir():
|
||||
if entry is None:
|
||||
continue
|
||||
@@ -173,7 +175,8 @@ def link_prof(firstname, lastname, lid):
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_dirstruct()
|
||||
schedule.every.day.at("04:00","Europe/Vienna").do(get_dirstruct)
|
||||
info("Database updated")
|
||||
schedule.every().day.at("04:00", "Europe/Vienna").do(get_dirstruct)
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
time.sleep(1)
|
||||
|
||||
Reference in New Issue
Block a user