From 230d8703ff937ee6ceca8538f51f96f9e8c164e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Mon, 5 Aug 2024 11:15:52 +0200 Subject: [PATCH] [fs2zammad] allow arbitrary source directory as CLI arg --- fs2zammad | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs2zammad b/fs2zammad index 8b590c7..dc08171 100755 --- a/fs2zammad +++ b/fs2zammad @@ -303,14 +303,21 @@ with open("rt2zammad.json") as handle: h2t = html2text.HTML2Text() zammad = get_zammad_session() +source_directory = "tickets/" +if len(sys.argv) >= 2: + source_directory = sys.argv[1] +if not os.path.isdir(source_directory): + print(f"Could not find source directory {source_directory}. Exiting.") + sys.exit(1) + os.makedirs("users", exist_ok=True) os.makedirs("tickets", exist_ok=True) os.makedirs("attachments", exist_ok=True) os.makedirs("failed", exist_ok=True) os.makedirs("processed", exist_ok=True) -ticket_ids = os.listdir("tickets/") -print(f"Found {len(ticket_ids)} tickets on filesystem.") +ticket_ids = os.listdir(source_directory) +print(f"Found {len(ticket_ids)} tickets on filesystem (source directory: {source_directory})") ticket_ids = list(map(int, ticket_ids)) ticket_ids.sort()