webdav funkcije

master
Jan Kostanjevec 2022-05-02 14:15:51 +02:00
parent 7a0109916e
commit 2266189a6d
2 changed files with 47 additions and 0 deletions

17
get_files.py 100644
View File

@ -0,0 +1,17 @@
#!/usr/bin/python3
from webdav3.client import Client
options = {
#'webdav_login': 'gia',
#'webdav_password': 'gia0000!',
'webdav_token': '2WmQL-G7Jbg-6t7sN-JBRSe-eBGy5',
'webdav_hostname': 'https://obzorje.kompot.si/remote.php/dav/files/dab82616-284e-103c-9287-6de9b1978576/'
#'webdav_hostname': 'https://obzorje.kompot.si',
#'webdav_root': '/remote.php/dav/files/'
}
client = Client(options)
def get_file_list():
return client.list("/GIA CLOUD")

30
search_cloud.py 100644
View File

@ -0,0 +1,30 @@
"""from newxtloud get a list of titles to populate DB"""
import imp
from requests import session
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from config import CONFIG
from create_db import Base, Card
from get_files import get_file_list
engine = create_engine(CONFIG['DB_CONNECTION'])
Base.metadata.bind = engine
DBSsession = sessionmaker(bind=engine)
session = DBSsession()
l = get_file_list()
id = 0 #TODO
for title in l:
if title[-4:] == ".pdf":
card = Card(
id=id,
title=title[:-4],
interest_rate=-1,
owner_id = 1
)
session.add(card)
session.commit()
id = id+1