remotivelabs-cli 0.0.27__py3-none-any.whl → 0.0.28__py3-none-any.whl
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.
- cli/cloud/auth_tokens.py +10 -9
- cli/cloud/filestorage.py +20 -5
- cli/cloud/resumable_upload.py +24 -1
- {remotivelabs_cli-0.0.27.dist-info → remotivelabs_cli-0.0.28.dist-info}/METADATA +1 -1
- {remotivelabs_cli-0.0.27.dist-info → remotivelabs_cli-0.0.28.dist-info}/RECORD +8 -8
- {remotivelabs_cli-0.0.27.dist-info → remotivelabs_cli-0.0.28.dist-info}/LICENSE +0 -0
- {remotivelabs_cli-0.0.27.dist-info → remotivelabs_cli-0.0.28.dist-info}/WHEEL +0 -0
- {remotivelabs_cli-0.0.27.dist-info → remotivelabs_cli-0.0.28.dist-info}/entry_points.txt +0 -0
cli/cloud/auth_tokens.py
CHANGED
@@ -46,16 +46,17 @@ def list_personal_access_tokens() -> None:
|
|
46
46
|
@app.command(name="revoke")
|
47
47
|
def revoke(name_or_file: str = typer.Argument(help="Name or file path of the access token to revoke")) -> None:
|
48
48
|
"""
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
49
|
+
Revoke an access token by token name or path to a file containing that token
|
50
|
+
|
51
|
+
Name is found in the json file
|
52
|
+
```
|
53
|
+
{
|
54
|
+
"expires": "2034-07-31",
|
55
|
+
"token": "xxx",
|
56
|
+
"created": "2024-07-31T09:18:50.406+02:00",
|
57
|
+
"name": "token_name"
|
58
58
|
}
|
59
|
+
```
|
59
60
|
"""
|
60
61
|
name = name_or_file
|
61
62
|
if "." in name_or_file:
|
cli/cloud/filestorage.py
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import os.path
|
2
4
|
import sys
|
3
5
|
from pathlib import Path
|
@@ -96,11 +98,24 @@ def copy_file( # noqa: C901 # type: ignore[too-many-branches] # pylint: disabl
|
|
96
98
|
if source.startswith("rcs://"):
|
97
99
|
__copy_to_local(source=source, dest=dest, project=project)
|
98
100
|
else:
|
99
|
-
|
101
|
+
path = Path(source)
|
102
|
+
if path.is_dir():
|
103
|
+
print("is dir")
|
104
|
+
for file_path in path.rglob("*"):
|
105
|
+
if file_path.is_file():
|
106
|
+
print(file_path)
|
107
|
+
__copy_to_remote(source=source, dest=dest, project=project)
|
108
|
+
sys.exit(1)
|
109
|
+
else:
|
110
|
+
__copy_to_remote(source=source, dest=dest, project=project)
|
100
111
|
|
101
112
|
|
102
113
|
def __copy_to_remote(source: str, dest: str, project: str) -> None:
|
103
114
|
path = Path(source)
|
115
|
+
if path.is_dir():
|
116
|
+
print("is dir")
|
117
|
+
sys.exit(1)
|
118
|
+
|
104
119
|
if not path.exists():
|
105
120
|
ErrorPrinter.print_hint("Source file does not exist")
|
106
121
|
sys.exit(1)
|
@@ -111,11 +126,11 @@ def __copy_to_remote(source: str, dest: str, project: str) -> None:
|
|
111
126
|
res = Rest.handle_post(f"/api/project/{project}/files/storage{rcs_path}", return_response=True)
|
112
127
|
if res is None:
|
113
128
|
return
|
114
|
-
|
115
|
-
url =
|
116
|
-
|
129
|
+
json_res = res.json()
|
130
|
+
url = json_res["url"]
|
131
|
+
headers = json_res["headers"]
|
117
132
|
try:
|
118
|
-
upload.upload_signed_url(url, source,
|
133
|
+
upload.upload_signed_url(url, source, headers)
|
119
134
|
except IsADirectoryError:
|
120
135
|
ErrorPrinter.print_hint(f"Supplied source file '{source}' is a directory but must be a file")
|
121
136
|
|
cli/cloud/resumable_upload.py
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import os
|
2
4
|
import sys
|
5
|
+
from typing import Dict
|
3
6
|
|
4
7
|
import requests
|
5
8
|
from rich.progress import wrap_file
|
@@ -21,11 +24,12 @@ def __get_uploaded_bytes(upload_url: str) -> int:
|
|
21
24
|
return 0
|
22
25
|
|
23
26
|
|
24
|
-
def
|
27
|
+
def with_resumable_upload_signed_url(signed_url: str, source_file_name: str, content_type: str) -> None:
|
25
28
|
"""
|
26
29
|
Upload file to file storage with signed url and resumable upload.
|
27
30
|
Resumable upload will only work with the same URL and not if a new signed URL is requested with the
|
28
31
|
same object id.
|
32
|
+
:param content_type:
|
29
33
|
:param signed_url:
|
30
34
|
:param source_file_name:
|
31
35
|
:return:
|
@@ -60,3 +64,22 @@ def upload_signed_url(signed_url: str, source_file_name: str, content_type: str)
|
|
60
64
|
sys.exit(1)
|
61
65
|
|
62
66
|
print(f"File {source_file_name} uploaded successfully.")
|
67
|
+
|
68
|
+
|
69
|
+
def upload_signed_url(signed_url: str, source_file_name: str, headers: Dict[str, str]) -> None:
|
70
|
+
"""
|
71
|
+
Upload file to file storage with signed url and resumable upload.
|
72
|
+
Resumable upload will only work with the same URL and not if a new signed URL is requested with the
|
73
|
+
same object id.
|
74
|
+
:param headers:
|
75
|
+
:param signed_url:
|
76
|
+
:param source_file_name:
|
77
|
+
:return:
|
78
|
+
"""
|
79
|
+
with open(source_file_name, "rb") as f:
|
80
|
+
response = requests.put(signed_url, headers=headers, timeout=60, data=f)
|
81
|
+
if response.status_code not in (200, 201, 308):
|
82
|
+
ErrorPrinter.print_generic_error(f"Failed to upload file: {response.status_code} - {response.text}")
|
83
|
+
sys.exit(1)
|
84
|
+
|
85
|
+
print(f"File {source_file_name} uploaded successfully.")
|
@@ -13,17 +13,17 @@ cli/broker/scripting.py,sha256=8577_C6siOk90s4G1ItIfAoFIUAkS0ItUl5kqR0cD-k,3792
|
|
13
13
|
cli/broker/signals.py,sha256=G54RrCUP9vonLouWL7IG0j7YqszVyM5jPr1WKHGZK34,7073
|
14
14
|
cli/cloud/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
15
|
cli/cloud/auth.py,sha256=CgIg_y7oBbRmOHtWEsmUrNrbBDf-Req0R7i_laKt_z8,3907
|
16
|
-
cli/cloud/auth_tokens.py,sha256=
|
16
|
+
cli/cloud/auth_tokens.py,sha256=usNWUqsRW2whs7EV2_aTHPqViuUHIwnWYekd4erDrVo,4788
|
17
17
|
cli/cloud/brokers.py,sha256=56MX74axZUhULzXSPnDfiq5uB8bpS1DXWskxOF2_tcQ,3892
|
18
18
|
cli/cloud/cloud_cli.py,sha256=09YCHs8IivYsVJOsxlM5OMEqBdq3QUXtDsktcO8Kjyw,1263
|
19
19
|
cli/cloud/configs.py,sha256=xg3J-kaS-Pp0p9otV2cWl_oOWJzs_jZhXwFHz0gQxvc,4625
|
20
|
-
cli/cloud/filestorage.py,sha256=
|
20
|
+
cli/cloud/filestorage.py,sha256=cCPDYwCyJxP4V_qK1_Gnsg_T-zVsw6QaZdY_l4s4vC0,5445
|
21
21
|
cli/cloud/organisations.py,sha256=txKQmSQEpTmeqlqngai8pwgQQEvRgeDd0dT_VzZ7RNc,752
|
22
22
|
cli/cloud/projects.py,sha256=YrwPJClC2Sq_y1HjPd_tzaiv4GEnnsXSXHBhtQCPdK0,1431
|
23
23
|
cli/cloud/recordings.py,sha256=jnsc39CmIQQ3DUu5Mpe7wrr6aLCK870TRi6TcgGmiY0,24137
|
24
24
|
cli/cloud/recordings_playback.py,sha256=PRzftmvG2iePrL9f6qTEXVOnyJ-etcyzn5w9CCxcSto,11539
|
25
25
|
cli/cloud/rest_helper.py,sha256=Sky-Lc0YaKbSUdSy3O5AK2FffKAVjAeVMrZLHiUILyU,11294
|
26
|
-
cli/cloud/resumable_upload.py,sha256=
|
26
|
+
cli/cloud/resumable_upload.py,sha256=sYThyhseXRniOMbctbO5p4BGVb9b7BXVBcmcZXwnClM,3550
|
27
27
|
cli/cloud/sample_recordings.py,sha256=OVX32U1dkkkJZysbgr5Dy515oOQKnwBAbZYzV_QUu1g,690
|
28
28
|
cli/cloud/service_account_tokens.py,sha256=bchcyK0tRo-mTF312tZsvlHgNB2Azza_snbT2di1Oqg,2413
|
29
29
|
cli/cloud/service_accounts.py,sha256=XOIPobUamCLIaufjyvb33XJDwy6uRqW5ZljZx3GYEfo,1659
|
@@ -38,8 +38,8 @@ cli/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
38
|
cli/tools/can/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
39
|
cli/tools/can/can.py,sha256=8uATViSFlpkdSiIm4fzbuQi1_m7V9Pym-K17TaJQRHU,2262
|
40
40
|
cli/tools/tools.py,sha256=0KU-hXR1f9xHP4BOG9A9eXfmICLmNuQCOU8ueF6iGg0,198
|
41
|
-
remotivelabs_cli-0.0.
|
42
|
-
remotivelabs_cli-0.0.
|
43
|
-
remotivelabs_cli-0.0.
|
44
|
-
remotivelabs_cli-0.0.
|
45
|
-
remotivelabs_cli-0.0.
|
41
|
+
remotivelabs_cli-0.0.28.dist-info/LICENSE,sha256=qDPP_yfuv1fF-u7EfexN-cN3M8aFgGVndGhGLovLKz0,608
|
42
|
+
remotivelabs_cli-0.0.28.dist-info/METADATA,sha256=OrX8uX05_oDur8eFNmFBScQR-EJCh8ao72faNclpLAE,1318
|
43
|
+
remotivelabs_cli-0.0.28.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
44
|
+
remotivelabs_cli-0.0.28.dist-info/entry_points.txt,sha256=lvDhPgagLqW_KTnLPCwKSqfYlEp-1uYVosRiPjsVj10,45
|
45
|
+
remotivelabs_cli-0.0.28.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|