diff --git a/.gitignore b/.gitignore index 5fef0ad4ba17340a65a8297f59364a3bba4582d4..751bf491cc198c553399655d2031e9af4861e16c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ fingerhuete_*/ __pycache__ .idea +.eudat-key diff --git a/b2drop-webdav.ipynb b/b2drop-webdav.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/fingerhuete.py b/fingerhuete.py index 705ab386db3450c6468d8d6f2e7a36b1e8289d9a..8fca95b8361b27f61ecfdb53f3cd3501dee9afa0 100644 --- a/fingerhuete.py +++ b/fingerhuete.py @@ -1,5 +1,5 @@ from rembg import remove -from webdavsync import pull, push, get_info, list_b2drop +from webdavsync import pull, push, get_info, list_b2drop, connect_webdav_b2drop from rembg import remove as remove_bg import os import threading @@ -60,11 +60,17 @@ def push_data(): time.sleep(60) # sleep for a minute - def main(): - # b2drop_list = list_b2drop() - # for el in b2drop_list: - # print(el["path"]) + username = "1686b184-4d7a-45ba-8cba-4c8aef619886" + try: + f = open(".eudat-key", "r") + except OSError as e: + print(e) + print("Make sure the file .eudat-key does exist and contains your B2DROP key") + webdav_pw = f.read() + f.close() + connect_webdav_b2drop(username, webdav_pw) + t1 = threading.Thread(target=pull_data) t2 = threading.Thread(target=process, args=(local_path_in, local_path_out)) t3 = threading.Thread(target=push_data) diff --git a/webdavsync.py b/webdavsync.py index 6f775118ff69e45b9a63182c4736d823816ffc3a..2c6b392a2364a29e752e2f294b8e377e913de72f 100644 --- a/webdavsync.py +++ b/webdavsync.py @@ -1,16 +1,19 @@ from webdav3.client import Client -username = "1686b184-4d7a-45ba-8cba-4c8aef619886" +client: Client -options = { - 'webdav_hostname': f"https://b2drop.eudat.eu/remote.php/dav/files/{username}", - 'webdav_login': username, - 'webdav_password': "CYFfS-Ff7FG-yke27-XkjTe-dWJrw", - 'verbose': True, - 'webdav_timeout': 60*4, # 10 minutes -} -client = Client(options) +def connect_webdav_b2drop(username, webdav_pw): + global client + + options = { + 'webdav_hostname': f"https://b2drop.eudat.eu/remote.php/dav/files/{username}", + 'webdav_login': username, + 'webdav_password': webdav_pw, + 'verbose': True, + 'webdav_timeout': 60 * 4, # 10 minutes + } + client = Client(options) def list_b2drop():