remotivelabs-cli 0.0.27__tar.gz → 0.0.28__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.
Files changed (44) hide show
  1. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/PKG-INFO +1 -1
  2. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/auth_tokens.py +10 -9
  3. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/filestorage.py +20 -5
  4. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/resumable_upload.py +24 -1
  5. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/pyproject.toml +1 -1
  6. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/LICENSE +0 -0
  7. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/README.md +0 -0
  8. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/__about__.py +0 -0
  9. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/__init__.py +0 -0
  10. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/brokers.py +0 -0
  11. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/export.py +0 -0
  12. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/files.py +0 -0
  13. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/lib/__about__.py +0 -0
  14. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/lib/broker.py +0 -0
  15. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/license_flows.py +0 -0
  16. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/licenses.py +0 -0
  17. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/playback.py +0 -0
  18. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/record.py +0 -0
  19. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/scripting.py +0 -0
  20. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/broker/signals.py +0 -0
  21. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/__init__.py +0 -0
  22. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/auth.py +0 -0
  23. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/brokers.py +0 -0
  24. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/cloud_cli.py +0 -0
  25. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/configs.py +0 -0
  26. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/organisations.py +0 -0
  27. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/projects.py +0 -0
  28. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/recordings.py +0 -0
  29. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/recordings_playback.py +0 -0
  30. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/rest_helper.py +0 -0
  31. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/sample_recordings.py +0 -0
  32. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/service_account_tokens.py +0 -0
  33. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/cloud/service_accounts.py +0 -0
  34. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/connect/__init__.py +0 -0
  35. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/connect/connect.py +0 -0
  36. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/connect/protopie/protopie.py +0 -0
  37. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/errors.py +0 -0
  38. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/remotive.py +0 -0
  39. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/requirements.txt +0 -0
  40. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/settings.py +0 -0
  41. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/tools/__init__.py +0 -0
  42. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/tools/can/__init__.py +0 -0
  43. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/tools/can/can.py +0 -0
  44. {remotivelabs_cli-0.0.27 → remotivelabs_cli-0.0.28}/cli/tools/tools.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: remotivelabs-cli
3
- Version: 0.0.27
3
+ Version: 0.0.28
4
4
  Summary: CLI for operating RemotiveCloud and RemotiveBroker
5
5
  Author: Johan Rask
6
6
  Author-email: johan.rask@remotivelabs.com
@@ -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
- 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"
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:
@@ -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
- __copy_to_remote(source=source, dest=dest, project=project)
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
- json = res.json()
115
- url = json["url"]
116
- content_type = json["contentType"]
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, content_type)
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
 
@@ -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 upload_signed_url(signed_url: str, source_file_name: str, content_type: str) -> None:
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.")
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "remotivelabs-cli"
3
- version = "0.0.27"
3
+ version = "0.0.28"
4
4
  description = "CLI for operating RemotiveCloud and RemotiveBroker"
5
5
  authors = ["Johan Rask <johan.rask@remotivelabs.com>"]
6
6
  readme = "README.md"