commit b087828458c84139b461186d1c7cf338c919d73f
parent a2460e6094c4040f4ea93106e70c2a4e31933b54
Author: Pr0fiTX <uventik999@gmail.com>
Date: Wed, 9 Jul 2025 14:56:31 +0300
[ADD]: Auth method for Dropbox
Diffstat:
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/cloud.py b/src/cloud.py
@@ -1,4 +1,5 @@
import dropbox as dbx
+from dropbox.dropbox_client import BadInputException
from dropbox.exceptions import AuthError
@@ -6,7 +7,18 @@ class Cloud:
def __init__(self):
pass
- def dbx_auth(self, key):
+ @classmethod
+ def dbx_auth(cls, key):
if key is None:
print("!=> The KEY field is empty")
return
+
+ try:
+ drbx = dbx.Dropbox(key)
+ drbx_acc_info = drbx.users_get_current_account()
+ except (AuthError, BadInputException) as e:
+ print(f"!=> Can't log in into your Dropbox acccount: {e}")
+ return
+
+ print(f"Good Day, {drbx_acc_info.name.display_name}!")
+ return drbx
diff --git a/src/parser.py b/src/parser.py
@@ -50,6 +50,19 @@ def parseit():
action="store_true",
help="Prints all tasks ID (including DELETED)",
)
+ parser.add_argument(
+ "-S",
+ "--cloud-save",
+ action="store_true",
+ help="Save .conf & .json files into your Cloud method, provided in .conf",
+ )
+ parser.add_argument(
+ "-L",
+ "--cloud-load",
+ action="store_true",
+ help="Load .conf & .json files from your Cloud method, provided in .conf",
+ )
+
args = parser.parse_args()
return args
diff --git a/src/pydoto.py b/src/pydoto.py
@@ -1,5 +1,6 @@
import parser as ps
import tasksmanage as tm
+import cloud as cd
def main():
@@ -38,6 +39,12 @@ def main():
if args.all_id: # -I
tm.Task.print_id_all()
return
+ if args.cloud_save: # -S
+ cd.Cloud.dbx_auth(0)
+ return
+ if args.cloud_load: # -L
+ cd.Cloud.dbx_auth(0)
+ return
else:
# Execute without any flags
# Prints only ACTIVE tasks