plash-cli 0.3.1__tar.gz → 0.3.2__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.
- {plash_cli-0.3.1/plash_cli.egg-info → plash_cli-0.3.2}/PKG-INFO +1 -1
- plash_cli-0.3.2/plash_cli/__init__.py +1 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli/cli.py +23 -28
- {plash_cli-0.3.1 → plash_cli-0.3.2/plash_cli.egg-info}/PKG-INFO +1 -1
- {plash_cli-0.3.1 → plash_cli-0.3.2}/settings.ini +1 -1
- plash_cli-0.3.1/plash_cli/__init__.py +0 -1
- {plash_cli-0.3.1 → plash_cli-0.3.2}/LICENSE +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/MANIFEST.in +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/README.md +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli/_bash_magic.py +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli/_modidx.py +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli/assets/es256_public_key.pem +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli/auth.py +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli.egg-info/SOURCES.txt +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli.egg-info/dependency_links.txt +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli.egg-info/entry_points.txt +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli.egg-info/not-zip-safe +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli.egg-info/requires.txt +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/plash_cli.egg-info/top_level.txt +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/pyproject.toml +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/setup.cfg +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.2}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.2"
|
|
@@ -32,7 +32,10 @@ def _get_client(cookie_file):
|
|
|
32
32
|
return client
|
|
33
33
|
|
|
34
34
|
# %% ../nbs/00_cli.ipynb 8
|
|
35
|
-
def _mk_auth_req(url:str, method:str='get', **kwargs):
|
|
35
|
+
def _mk_auth_req(url:str, method:str='get', **kwargs):
|
|
36
|
+
r = getattr(_get_client(PLASH_CONFIG_HOME), method)(url, **kwargs)
|
|
37
|
+
if r.status_code == 200: return r
|
|
38
|
+
else: print(f'Failure: {r.headers["X-Plash-Error"]}')
|
|
36
39
|
|
|
37
40
|
# %% ../nbs/00_cli.ipynb 9
|
|
38
41
|
def _get_app_name(path:Path):
|
|
@@ -164,12 +167,11 @@ def deploy(
|
|
|
164
167
|
plash_app.write_text(f'export PLASH_APP_NAME={name}')
|
|
165
168
|
|
|
166
169
|
tarz, _ = create_tar_archive(path, force_data)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if
|
|
170
|
+
r = _mk_auth_req(_endpoint(rt="/upload"), "post", files={'file': tarz}, timeout=300.0,
|
|
171
|
+
data={'name': name, 'force_data': force_data})
|
|
172
|
+
if r:
|
|
170
173
|
print('✅ Upload complete! Your app is currently being built.')
|
|
171
174
|
print(f'It will be live at {name if "." in name else _endpoint(sub=name)}')
|
|
172
|
-
else: print(f'Failure: {resp.status_code}\n{resp.text}')
|
|
173
175
|
|
|
174
176
|
# %% ../nbs/00_cli.ipynb 27
|
|
175
177
|
@call_parse
|
|
@@ -198,24 +200,21 @@ def delete(
|
|
|
198
200
|
return
|
|
199
201
|
|
|
200
202
|
print(f"Deleting app '{name}'...")
|
|
201
|
-
r
|
|
202
|
-
return r.text
|
|
203
|
+
if r := _mk_auth_req(_endpoint(rt=f"/delete?name={name}"), "delete"): return r.text
|
|
203
204
|
|
|
204
205
|
# %% ../nbs/00_cli.ipynb 33
|
|
205
206
|
@call_parse
|
|
206
207
|
def start(path:Path=Path('.'), name:str=None):
|
|
207
208
|
"Start your deployed app"
|
|
208
209
|
if not name: name = _get_app_name(path)
|
|
209
|
-
r
|
|
210
|
-
return r.text
|
|
210
|
+
if r := _mk_auth_req(_endpoint(rt=f"/start?name={name}")): return r.text
|
|
211
211
|
|
|
212
212
|
# %% ../nbs/00_cli.ipynb 36
|
|
213
213
|
@call_parse
|
|
214
214
|
def stop(path:Path=Path('.'), name:str=None):
|
|
215
215
|
"Stop your deployed app"
|
|
216
216
|
if not name: name = _get_app_name(path)
|
|
217
|
-
r
|
|
218
|
-
return r.text
|
|
217
|
+
if r := _mk_auth_req(_endpoint(rt=f"/stop?name={name}")): return r.text
|
|
219
218
|
|
|
220
219
|
# %% ../nbs/00_cli.ipynb 39
|
|
221
220
|
log_modes = str_enum('log_modes', 'build', 'app')
|
|
@@ -233,18 +232,13 @@ def logs(
|
|
|
233
232
|
text = ''
|
|
234
233
|
while True:
|
|
235
234
|
try:
|
|
236
|
-
r
|
|
237
|
-
if r.status_code == 200:
|
|
235
|
+
if r := _mk_auth_req(_endpoint(rt=f"/logs?name={name}&mode={mode}")):
|
|
238
236
|
print(r.text[len(text):], end='') # Only print updates
|
|
239
237
|
text = r.text
|
|
240
238
|
if mode == 'build' and 'Build End Time:' in r.text: break
|
|
241
239
|
sleep(1)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
except KeyboardInterrupt:
|
|
245
|
-
return "\nExiting"
|
|
246
|
-
r = _mk_auth_req(endpoint(rt=f"/logs?name={name}&mode={mode}"))
|
|
247
|
-
return r.text
|
|
240
|
+
except KeyboardInterrupt: return "\nExiting"
|
|
241
|
+
if r := _mk_auth_req(_endpoint(rt=f"/logs?name={name}&mode={mode}")): return r.text
|
|
248
242
|
|
|
249
243
|
# %% ../nbs/00_cli.ipynb 43
|
|
250
244
|
@call_parse
|
|
@@ -257,17 +251,18 @@ def download(
|
|
|
257
251
|
try: save_path.mkdir(exist_ok=False)
|
|
258
252
|
except: print(f"ERROR: Save path ({save_path}) already exists. Please rename or delete this folder to avoid accidental overwrites.")
|
|
259
253
|
else:
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
254
|
+
if r := _mk_auth_req(_endpoint(rt=f'/download?name={name}')):
|
|
255
|
+
file_bytes = io.BytesIO(r.content)
|
|
256
|
+
with tarfile.open(fileobj=file_bytes, mode="r:gz") as tar: tar.extractall(path=save_path)
|
|
257
|
+
print(f"Downloaded your app to: {save_path}")
|
|
264
258
|
|
|
265
259
|
# %% ../nbs/00_cli.ipynb 46
|
|
266
260
|
@call_parse
|
|
267
261
|
def apps(verbose:bool=False):
|
|
268
262
|
"List your deployed apps (verbose shows status table: 1=running, 0=stopped)"
|
|
269
|
-
r = _mk_auth_req(_endpoint(rt="/user_apps"))
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
263
|
+
r = _mk_auth_req(_endpoint(rt="/user_apps"))
|
|
264
|
+
if r:
|
|
265
|
+
apps = r.json()
|
|
266
|
+
if not apps: return "You don't have any deployed Plash apps."
|
|
267
|
+
if verbose: [print(f"{a['running']} {a['name']}") for a in apps]
|
|
268
|
+
else: [print(a['name']) for a in apps]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|