plash-cli 0.3.1__tar.gz → 0.3.3__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.3}/PKG-INFO +1 -1
- plash_cli-0.3.3/plash_cli/__init__.py +1 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli/_modidx.py +2 -1
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli/cli.py +30 -33
- {plash_cli-0.3.1 → plash_cli-0.3.3/plash_cli.egg-info}/PKG-INFO +1 -1
- {plash_cli-0.3.1 → plash_cli-0.3.3}/settings.ini +1 -1
- plash_cli-0.3.1/plash_cli/__init__.py +0 -1
- {plash_cli-0.3.1 → plash_cli-0.3.3}/LICENSE +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/MANIFEST.in +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/README.md +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli/_bash_magic.py +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli/assets/es256_public_key.pem +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli/auth.py +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli.egg-info/SOURCES.txt +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli.egg-info/dependency_links.txt +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli.egg-info/entry_points.txt +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli.egg-info/not-zip-safe +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli.egg-info/requires.txt +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/plash_cli.egg-info/top_level.txt +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/pyproject.toml +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/setup.cfg +0 -0
- {plash_cli-0.3.1 → plash_cli-0.3.3}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.3"
|
|
@@ -10,7 +10,8 @@ d = { 'settings': { 'branch': 'main',
|
|
|
10
10
|
'plash_cli.auth._signin_url': ('auth.html#_signin_url', 'plash_cli/auth.py'),
|
|
11
11
|
'plash_cli.auth.goog_id_from_signin_reply': ('auth.html#goog_id_from_signin_reply', 'plash_cli/auth.py'),
|
|
12
12
|
'plash_cli.auth.mk_signin_url': ('auth.html#mk_signin_url', 'plash_cli/auth.py')},
|
|
13
|
-
'plash_cli.cli': { 'plash_cli.cli.
|
|
13
|
+
'plash_cli.cli': { 'plash_cli.cli.Path._is_dir_empty': ('cli.html#path._is_dir_empty', 'plash_cli/cli.py'),
|
|
14
|
+
'plash_cli.cli.PlashError': ('cli.html#plasherror', 'plash_cli/cli.py'),
|
|
14
15
|
'plash_cli.cli._deps': ('cli.html#_deps', 'plash_cli/cli.py'),
|
|
15
16
|
'plash_cli.cli._endpoint': ('cli.html#_endpoint', 'plash_cli/cli.py'),
|
|
16
17
|
'plash_cli.cli._gen_app_name': ('cli.html#_gen_app_name', 'plash_cli/cli.py'),
|
|
@@ -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', timeout=300., **kwargs):
|
|
36
|
+
r = getattr(_get_client(PLASH_CONFIG_HOME), method)(url, timeout=timeout, **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},
|
|
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,20 +232,19 @@ 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
|
-
# %% ../nbs/00_cli.ipynb
|
|
243
|
+
# %% ../nbs/00_cli.ipynb 44
|
|
244
|
+
@patch
|
|
245
|
+
def _is_dir_empty(self:Path): return next(self.iterdir(), None) is None
|
|
246
|
+
|
|
247
|
+
# %% ../nbs/00_cli.ipynb 47
|
|
250
248
|
@call_parse
|
|
251
249
|
def download(
|
|
252
250
|
path:Path=Path('.'), # Path to project
|
|
@@ -254,20 +252,19 @@ def download(
|
|
|
254
252
|
save_path:Path=Path("./download/")): # Save path (optional)
|
|
255
253
|
'Download your deployed app'
|
|
256
254
|
if not name: name = _get_app_name(path)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
with tarfile.open(fileobj=file_bytes, mode="r:gz") as tar: tar.extractall(path=save_path)
|
|
263
|
-
print(f"Downloaded your app to: {save_path}")
|
|
255
|
+
save_path.mkdir(exist_ok=True)
|
|
256
|
+
if not save_path._is_dir_empty(): return print(f'ERROR: Save path ({save_path}) is not empty.')
|
|
257
|
+
if r := _mk_auth_req(_endpoint(rt=f'/download?name={name}')):
|
|
258
|
+
with tarfile.open(fileobj=io.BytesIO(r.content), mode="r:gz") as tar: tar.extractall(path=save_path)
|
|
259
|
+
print(f"Downloaded your app to: {save_path}")
|
|
264
260
|
|
|
265
|
-
# %% ../nbs/00_cli.ipynb
|
|
261
|
+
# %% ../nbs/00_cli.ipynb 50
|
|
266
262
|
@call_parse
|
|
267
263
|
def apps(verbose:bool=False):
|
|
268
264
|
"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
|
-
|
|
265
|
+
r = _mk_auth_req(_endpoint(rt="/user_apps"))
|
|
266
|
+
if r:
|
|
267
|
+
apps = r.json()
|
|
268
|
+
if not apps: return "You don't have any deployed Plash apps."
|
|
269
|
+
if verbose: [print(f"{a['running']} {a['name']}") for a in apps]
|
|
270
|
+
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
|