From 3c6f8d86a7e6149e5a7e5ed6aa9b7f44b1c39407 Mon Sep 17 00:00:00 2001 From: Dastan-glitch Date: Fri, 27 Oct 2023 18:34:24 +0300 Subject: [PATCH] bin/tau: add export and import --- bin/tau/tau-python/api.py | 6 ++++++ bin/tau/tau-python/main.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/bin/tau/tau-python/api.py b/bin/tau/tau-python/api.py index be4156487c8e..322d13a32eb8 100644 --- a/bin/tau/tau-python/api.py +++ b/bin/tau/tau-python/api.py @@ -76,3 +76,9 @@ async def fetch_archive_task(task_refid, month_ts, server_name, port): async def add_task_comment(refid, comment, server_name, port): await query("set_comment", [refid, comment], server_name, int(port)) return True + +async def export_to(path, server_name, port): + return await query("export", [path], server_name, int(port)) + +async def import_from(path, server_name, port): + return await query("import", [path], server_name, int(port)) diff --git a/bin/tau/tau-python/main.py b/bin/tau/tau-python/main.py index 7bf2d3083ca4..1f75cf264583 100644 --- a/bin/tau/tau-python/main.py +++ b/bin/tau/tau-python/main.py @@ -615,6 +615,22 @@ async def main(): else: print(f"You are now on \"{sys.argv[2]}\" workspace.") return 0 + elif sys.argv[1] == "export": + if len(sys.argv) == 2: + path = "~/.local/darkfi" + else: + path = sys.argv[2] + if await api.export_to(path, server_name, port): + print(f"Exported tasks successfuly to {path}") + return 0 + elif sys.argv[1] == "import": + if len(sys.argv) == 2: + path = "~/.local/darkfi" + else: + path = sys.argv[2] + if await api.import_from(path, server_name, port): + print(f"Imported tasks successfuly from {path}") + return 0 try: id = int(sys.argv[1])