remotivelabs-cli 0.0.30__py3-none-any.whl → 0.0.31__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/filestorage.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import json
3
4
  import os.path
4
5
  import sys
5
6
  from pathlib import Path
@@ -75,6 +76,7 @@ def delete_file(
75
76
  def copy_file( # noqa: C901 # type: ignore[too-many-branches] # pylint: disable=no-member
76
77
  source: str = typer.Argument(default=..., help="Remote or local path to source file"),
77
78
  dest: str = typer.Argument(default=..., help="Remote or local path to destination file"),
79
+ overwrite: bool = typer.Option(default=False, help="Overwrite existing file on RCS"),
78
80
  project: str = typer.Option(..., help="Project ID", envvar="REMOTIVE_CLOUD_PROJECT"),
79
81
  ) -> None:
80
82
  """
@@ -100,20 +102,17 @@ def copy_file( # noqa: C901 # type: ignore[too-many-branches] # pylint: disabl
100
102
  else:
101
103
  path = Path(source)
102
104
  if path.is_dir():
103
- print("is dir")
104
105
  for file_path in path.rglob("*"):
105
106
  if file_path.is_file():
106
- print(file_path)
107
- __copy_to_remote(source=source, dest=dest, project=project)
107
+ __copy_to_remote(source=source, dest=dest, project=project, overwrite=overwrite)
108
108
  sys.exit(1)
109
109
  else:
110
- __copy_to_remote(source=source, dest=dest, project=project)
110
+ __copy_to_remote(source=source, dest=dest, project=project, overwrite=overwrite)
111
111
 
112
112
 
113
- def __copy_to_remote(source: str, dest: str, project: str) -> None:
113
+ def __copy_to_remote(source: str, dest: str, project: str, overwrite: bool) -> None:
114
114
  path = Path(source)
115
115
  if path.is_dir():
116
- print("is dir")
117
116
  sys.exit(1)
118
117
 
119
118
  if not path.exists():
@@ -123,7 +122,8 @@ def __copy_to_remote(source: str, dest: str, project: str) -> None:
123
122
  rcs_path = __check_rcs_path(dest)
124
123
  if rcs_path.endswith("/"):
125
124
  rcs_path = rcs_path + filename
126
- res = Rest.handle_post(f"/api/project/{project}/files/storage{rcs_path}", return_response=True)
125
+ upload_options = {"overwrite": "always" if overwrite else "never"}
126
+ res = Rest.handle_post(f"/api/project/{project}/files/storage{rcs_path}", return_response=True, body=json.dumps(upload_options))
127
127
  if res is None:
128
128
  return
129
129
  json_res = res.json()
@@ -76,10 +76,12 @@ def upload_signed_url(signed_url: str, source_file_name: str, headers: Dict[str,
76
76
  :param source_file_name:
77
77
  :return:
78
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)
79
+
80
+ with open(source_file_name, "rb") as file:
81
+ with wrap_file(file, os.stat(source_file_name).st_size, description=f"Uploading {source_file_name}...") as f:
82
+ response = requests.put(signed_url, headers=headers, timeout=60, data=f)
83
+ if response.status_code not in (200, 201, 308):
84
+ ErrorPrinter.print_generic_error(f"Failed to upload file: {response.status_code} - {response.text}")
85
+ sys.exit(1)
84
86
 
85
87
  print(f"File {source_file_name} uploaded successfully.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: remotivelabs-cli
3
- Version: 0.0.30
3
+ Version: 0.0.31
4
4
  Summary: CLI for operating RemotiveCloud and RemotiveBroker
5
5
  Author: Johan Rask
6
6
  Author-email: johan.rask@remotivelabs.com
@@ -16,13 +16,13 @@ cli/cloud/auth_tokens.py,sha256=0U60Gk2-TnAUff5anZmTB1rOEninNvYy1o5ihCqgj8A,4525
16
16
  cli/cloud/brokers.py,sha256=DNj79MTkPylKUQbr-iPUhQgfNJLAW8UehnvgpEmNH_k,3890
17
17
  cli/cloud/cloud_cli.py,sha256=09YCHs8IivYsVJOsxlM5OMEqBdq3QUXtDsktcO8Kjyw,1263
18
18
  cli/cloud/configs.py,sha256=xg3J-kaS-Pp0p9otV2cWl_oOWJzs_jZhXwFHz0gQxvc,4625
19
- cli/cloud/filestorage.py,sha256=cCPDYwCyJxP4V_qK1_Gnsg_T-zVsw6QaZdY_l4s4vC0,5445
19
+ cli/cloud/filestorage.py,sha256=BZbSk9abuLYw9TjGsQpfYMobtE4VLgXFrWD1sVvGolY,5621
20
20
  cli/cloud/organisations.py,sha256=txKQmSQEpTmeqlqngai8pwgQQEvRgeDd0dT_VzZ7RNc,752
21
21
  cli/cloud/projects.py,sha256=YrwPJClC2Sq_y1HjPd_tzaiv4GEnnsXSXHBhtQCPdK0,1431
22
22
  cli/cloud/recordings.py,sha256=jai5Gim28UmZFGniUI9qKDwtLoi2Nllv4eyPeIk3OAc,25366
23
23
  cli/cloud/recordings_playback.py,sha256=PRzftmvG2iePrL9f6qTEXVOnyJ-etcyzn5w9CCxcSto,11539
24
24
  cli/cloud/rest_helper.py,sha256=lZp0NjQ8yOaggQGNiqNxHex_YFOmuq0rnLPtpLq3Z3Q,11470
25
- cli/cloud/resumable_upload.py,sha256=sYThyhseXRniOMbctbO5p4BGVb9b7BXVBcmcZXwnClM,3550
25
+ cli/cloud/resumable_upload.py,sha256=5R6TLq9j8h-qs5bgGFC-lVaEsTI4DoAiTsZcROVtqgw,3688
26
26
  cli/cloud/sample_recordings.py,sha256=OVX32U1dkkkJZysbgr5Dy515oOQKnwBAbZYzV_QUu1g,690
27
27
  cli/cloud/service_account_tokens.py,sha256=263u1bRmBKfYsxL6TV6YjReUBUaVHWc3ETCd7AS3DTU,2297
28
28
  cli/cloud/service_accounts.py,sha256=XOIPobUamCLIaufjyvb33XJDwy6uRqW5ZljZx3GYEfo,1659
@@ -36,8 +36,8 @@ cli/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
36
  cli/tools/can/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  cli/tools/can/can.py,sha256=8uATViSFlpkdSiIm4fzbuQi1_m7V9Pym-K17TaJQRHU,2262
38
38
  cli/tools/tools.py,sha256=0KU-hXR1f9xHP4BOG9A9eXfmICLmNuQCOU8ueF6iGg0,198
39
- remotivelabs_cli-0.0.30.dist-info/LICENSE,sha256=qDPP_yfuv1fF-u7EfexN-cN3M8aFgGVndGhGLovLKz0,608
40
- remotivelabs_cli-0.0.30.dist-info/METADATA,sha256=82x7il8xKpkWGgoxjahiE9bW3QBSiPC--YuUG2d-Prs,1318
41
- remotivelabs_cli-0.0.30.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
42
- remotivelabs_cli-0.0.30.dist-info/entry_points.txt,sha256=lvDhPgagLqW_KTnLPCwKSqfYlEp-1uYVosRiPjsVj10,45
43
- remotivelabs_cli-0.0.30.dist-info/RECORD,,
39
+ remotivelabs_cli-0.0.31.dist-info/LICENSE,sha256=qDPP_yfuv1fF-u7EfexN-cN3M8aFgGVndGhGLovLKz0,608
40
+ remotivelabs_cli-0.0.31.dist-info/METADATA,sha256=hXSuC1H53XacGz8LX3D4ySgdUIOncQG7iIWQEm5NdkI,1318
41
+ remotivelabs_cli-0.0.31.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
42
+ remotivelabs_cli-0.0.31.dist-info/entry_points.txt,sha256=lvDhPgagLqW_KTnLPCwKSqfYlEp-1uYVosRiPjsVj10,45
43
+ remotivelabs_cli-0.0.31.dist-info/RECORD,,