Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nbs/00_cli.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"#| export\n",
"from fastcore.all import *\n",
"from fastcore.xdg import *\n",
"import secrets, webbrowser, json, httpx, io, tarfile, random, string\n",
"import secrets, webbrowser, httpx, io, tarfile, random, string\n",
"from pathlib import Path\n",
"from uuid import uuid4\n",
"from time import time, sleep\n",
Expand Down Expand Up @@ -222,7 +222,7 @@
" if not PLASH_CONFIG_HOME.exists(): return print(\"No config found.\")\n",
" return print(PLASH_CONFIG_HOME.read_json().get(\"session_\", \"\"), end='')\n",
" if token:\n",
" PLASH_CONFIG_HOME.write_text(json.dumps({\"session_\": token.strip()}))\n",
" PLASH_CONFIG_HOME.write_json({\"session_\": token.strip()})\n",
" return f\"Token saved to {PLASH_CONFIG_HOME}\"\n",
" paircode = secrets.token_urlsafe(16)\n",
" login_url = httpx.get(_endpoint(rt=f\"/cli_login?paircode={paircode}\")).text\n",
Expand All @@ -231,7 +231,7 @@
" \n",
" cookies = _poll_cookies(paircode)\n",
" if cookies:\n",
" PLASH_CONFIG_HOME.write_text(json.dumps(cookies))\n",
" PLASH_CONFIG_HOME.write_json(cookies)\n",
" print(f\"Authentication successful! Config saved to {PLASH_CONFIG_HOME}\")\n",
" else: print(\"Authentication timed out.\")"
]
Expand Down
6 changes: 3 additions & 3 deletions plash_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# %% ../nbs/00_cli.ipynb 3
from fastcore.all import *
from fastcore.xdg import *
import secrets, webbrowser, json, httpx, io, tarfile, random, string
import secrets, webbrowser, httpx, io, tarfile, random, string
from pathlib import Path
from uuid import uuid4
from time import time, sleep
Expand Down Expand Up @@ -92,7 +92,7 @@ def login(
if not PLASH_CONFIG_HOME.exists(): return print("No config found.")
return print(PLASH_CONFIG_HOME.read_json().get("session_", ""), end='')
if token:
PLASH_CONFIG_HOME.write_text(json.dumps({"session_": token.strip()}))
PLASH_CONFIG_HOME.write_json({"session_": token.strip()})
return f"Token saved to {PLASH_CONFIG_HOME}"
paircode = secrets.token_urlsafe(16)
login_url = httpx.get(_endpoint(rt=f"/cli_login?paircode={paircode}")).text
Expand All @@ -101,7 +101,7 @@ def login(

cookies = _poll_cookies(paircode)
if cookies:
PLASH_CONFIG_HOME.write_text(json.dumps(cookies))
PLASH_CONFIG_HOME.write_json(cookies)
print(f"Authentication successful! Config saved to {PLASH_CONFIG_HOME}")
else: print("Authentication timed out.")

Expand Down