From 127c4906d0c9380f1db102c68b71a671a7bb46fb Mon Sep 17 00:00:00 2001 From: Andreas Domanowski <andreas@domanowski.net> Date: Wed, 1 Mar 2023 12:54:19 +0100 Subject: [PATCH] Add instructions in stdout --- common.py | 12 ++++++++++-- md-import-export.py | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/common.py b/common.py index cd26bcd..95bb270 100644 --- a/common.py +++ b/common.py @@ -7,9 +7,17 @@ else: getpass = input -def get_sessionid(cookie_key): +def get_sessionid(service_name, cookie_key): """Ask the user for the session id, if it's not configured as an envvar.""" - sid = getpass(f"Please provide your CodiMD session id ({cookie_key} cookie): ") + print(f"You now will be asked for your session cookie for {service_name}") + print(f"To extract this cookie, you need to open your browser with an active and logged-in {service_name} session") + print(f"In Firefox or Chrome, you can do this by following the following steps:") + print(f"\t1. Open the developer tools (Shortcut: F12") + print(f"\t2. Select \"Storage -> Cookies\" (Firefox) or \"Application -> Cookies\"") + print(f"\t3. Copy the value for the cookie named {cookie_key}") + print(f"\t4. Input it in the prompt") + + sid = getpass(f"Please provide your {service_name} session id ({cookie_key} cookie): ") if sid.startswith("s%3A"): return sid raise SystemExit(f"error: the supplied session id seems to be malformed") diff --git a/md-import-export.py b/md-import-export.py index 0467a36..5ef7654 100644 --- a/md-import-export.py +++ b/md-import-export.py @@ -4,5 +4,5 @@ from hedgedoc_import import import_into_hedgedoc if __name__ == "__main__": export_folder = "codimd-documents" - export_from_codimd("http://localhost:3001", get_sessionid("connect.sid"), export_folder) - import_into_hedgedoc("http://hedgedoc:3000", get_sessionid("connect.hedgeDoc.sid"), export_folder, "archive.zip") + export_from_codimd("http://localhost:3001", get_sessionid("CodiMD", "connect.sid"), export_folder) + import_into_hedgedoc("http://hedgedoc:3000", get_sessionid("HedgeDoc", "connect.hedgeDoc.sid"), export_folder, "archive.zip") -- GitLab