plash-cli 0.3.4__tar.gz → 0.3.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plash_cli
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: CLI for the Plash hosting service
5
5
  Home-page: https://github.com/AnswerDotAI/plash_cli
6
6
  Author: Jeremy Howard
@@ -0,0 +1,2 @@
1
+ __version__ = "0.3.6"
2
+ from .cli import *
@@ -77,7 +77,6 @@ def _poll_cookies(paircode, interval=1, timeout=180):
77
77
  resp = client.get(url).raise_for_status()
78
78
  if resp.text.strip(): return dict(client.cookies)
79
79
  sleep(interval)
80
-
81
80
 
82
81
  # %% ../nbs/00_cli.ipynb 14
83
82
  @call_parse
@@ -91,7 +90,7 @@ def login(
91
90
  return print(PLASH_CONFIG_HOME.read_json().get("session_", ""), end='')
92
91
  if token:
93
92
  PLASH_CONFIG_HOME.write_text(json.dumps({"session_": token.strip()}))
94
- return print(f"Token saved to {PLASH_CONFIG_HOME}")
93
+ return f"Token saved to {PLASH_CONFIG_HOME}"
95
94
  paircode = secrets.token_urlsafe(16)
96
95
  login_url = httpx.get(_endpoint(rt=f"/cli_login?paircode={paircode}")).text
97
96
  print(f"Opening browser for authentication:\n{login_url}\n")
@@ -100,13 +99,13 @@ def login(
100
99
  cookies = _poll_cookies(paircode)
101
100
  if cookies:
102
101
  PLASH_CONFIG_HOME.write_text(json.dumps(cookies))
103
- print(f"Authentication successful! Config saved to {PLASH_CONFIG_HOME}")
104
- else: print("Authentication timed out.")
102
+ return f"Authentication successful! Config saved to {PLASH_CONFIG_HOME}"
103
+ else: return "Authentication timed out."
105
104
 
106
105
  # %% ../nbs/00_cli.ipynb 17
107
106
  pat = r'(?m)^# /// (?P<type>[a-zA-Z0-9-]+)$\s(?P<content>(^#(| .*)$\s)+)^# ///$'
108
107
 
109
- def _deps(script: bytes | str) -> dict | None:
108
+ def _deps(script: bytes | str):
110
109
  'Get the dependencies from the script. From: https://peps.python.org/pep-0723/'
111
110
  name = 'script'
112
111
  if isinstance(script, bytes): script = script.decode('utf-8')
@@ -171,8 +170,9 @@ def deploy(
171
170
  r = _mk_auth_req(_endpoint(rt="/upload"), "post", files={'file': tarz},
172
171
  data={'name': name, 'force_data': force_data})
173
172
  if r:
174
- print('✅ Upload complete! Your app is currently being built.')
175
- print(f'It will be live at {name if "." in name else _endpoint(sub=name)}')
173
+ return ('✅ Upload complete! Your app is currently being built.\n' +
174
+ f'It will be live at {name if "." in name else _endpoint(sub=name)}')
175
+ else: return 'Unknown failure'
176
176
 
177
177
  # %% ../nbs/00_cli.ipynb 26
178
178
  @call_parse
@@ -233,11 +233,11 @@ def logs(
233
233
  text = ''
234
234
  while True:
235
235
  try:
236
- if r := _mk_auth_req(_endpoint(rt=f"/logs?name={name}&mode={mode}")):
237
- print(r.text[len(text):], end='') # Only print updates
238
- text = r.text
239
- if mode == 'build' and 'Build End Time:' in r.text: break
240
- sleep(1)
236
+ r = _mk_auth_req(_endpoint(rt=f"/logs?name={name}&mode={mode}"))
237
+ print(r.text[len(text):], end='') # Only print updates
238
+ text = r.text
239
+ if mode == 'build' and 'Build End Time:' in r.text: return
240
+ sleep(1)
241
241
  except KeyboardInterrupt: return "\nExiting"
242
242
  if r := _mk_auth_req(_endpoint(rt=f"/logs?name={name}&mode={mode}")): return r.text
243
243
 
@@ -256,7 +256,7 @@ def download(
256
256
  save_path.mkdir(exist_ok=True)
257
257
  if not save_path._is_dir_empty(): return print(f'ERROR: Save path ({save_path}) is not empty.')
258
258
  if r := _mk_auth_req(_endpoint(rt=f'/download?name={name}')):
259
- with tarfile.open(fileobj=io.BytesIO(r.content), mode="r:gz") as tar: tar.extractall(path=save_path)
259
+ with tarfile.open(fileobj=io.BytesIO(r.content), mode="r:gz") as tar: tar.extractall(path=save_path, filter='data')
260
260
  print(f"Downloaded your app to: {save_path}")
261
261
 
262
262
  # %% ../nbs/00_cli.ipynb 48
@@ -267,5 +267,5 @@ def apps(verbose:bool=False):
267
267
  if r:
268
268
  apps = r.json()
269
269
  if not apps: return "You don't have any deployed Plash apps."
270
- if verbose: [print(f"{a['running']} {a['name']}") for a in apps]
271
- else: [print(a['name']) for a in apps]
270
+ if verbose: return [(f"{a['running']} {a['name']}") for a in apps]
271
+ else: return [(a['name']) for a in apps]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plash_cli
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: CLI for the Plash hosting service
5
5
  Home-page: https://github.com/AnswerDotAI/plash_cli
6
6
  Author: Jeremy Howard
@@ -2,7 +2,7 @@
2
2
  jupyter_hooks = False
3
3
  repo = plash_cli
4
4
  lib_name = plash_cli
5
- version = 0.3.4
5
+ version = 0.3.6
6
6
  min_python = 3.11
7
7
  license = apache2
8
8
  black_formatting = False
@@ -1 +0,0 @@
1
- __version__ = "0.3.4"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes