kleinkram 0.26.1.dev20241008115122__tar.gz → 0.28.0__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.

Potentially problematic release.


This version of kleinkram might be problematic. Click here for more details.

Files changed (24) hide show
  1. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/PKG-INFO +1 -1
  2. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/pyproject.toml +1 -1
  3. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/file/file.py +56 -1
  4. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/mission/mission.py +1 -1
  5. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/.gitignore +0 -0
  6. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/LICENSE +0 -0
  7. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/README.md +0 -0
  8. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/deploy.sh +0 -0
  9. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/dev.sh +0 -0
  10. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/requirements.txt +0 -0
  11. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/klein.py +0 -0
  12. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/__init__.py +0 -0
  13. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/api_client.py +0 -0
  14. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/auth/auth.py +0 -0
  15. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/consts.py +0 -0
  16. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/endpoint/endpoint.py +0 -0
  17. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/error_handling.py +0 -0
  18. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/helper.py +0 -0
  19. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/main.py +0 -0
  20. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/project/project.py +0 -0
  21. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/queue/queue.py +0 -0
  22. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/tag/tag.py +0 -0
  23. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/topic/topic.py +0 -0
  24. {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0}/src/kleinkram/user/user.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: kleinkram
3
- Version: 0.26.1.dev20241008115122
3
+ Version: 0.28.0
4
4
  Summary: A CLI for the ETH project kleinkram
5
5
  Project-URL: Homepage, https://github.com/leggedrobotics/kleinkram
6
6
  Project-URL: Issues, https://github.com/leggedrobotics/kleinkram/issues
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "kleinkram"
7
- version = "0.26.1-dev20241008115122"
7
+ version = "0.28.0"
8
8
  description = "A CLI for the ETH project kleinkram"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -1,5 +1,5 @@
1
1
  import os
2
- from typing_extensions import Optional, Annotated
2
+ from typing_extensions import Optional, Annotated, List
3
3
 
4
4
  import httpx
5
5
  import requests
@@ -16,6 +16,61 @@ file = typer.Typer(
16
16
  )
17
17
 
18
18
 
19
+ @file.command("download")
20
+ def download_file(
21
+ file_uuid: Annotated[List[str], typer.Option(help="UUIDs of the files")],
22
+ local_path: Annotated[
23
+ str,
24
+ typer.Option(
25
+ prompt=True,
26
+ help="Local path to save the file",
27
+ ),
28
+ ],
29
+ ):
30
+ """
31
+ Download files by UUIDs to a local path.\n
32
+ Examples:\n
33
+ klein file download --file-uuid="9d5a9..." --file-uuid="9833f..." --local-path="~/Downloads" \n
34
+ klein file download --file-uuid="9d5a9..." --local-path="~/Downloads/example.bag"
35
+
36
+ """
37
+ client = AuthenticatedClient()
38
+ url = f"/file/download"
39
+
40
+ fixed_local_path = os.path.expanduser(local_path)
41
+
42
+ isDir = os.path.isdir(fixed_local_path)
43
+ chunk_size = 1024 * 100 # 100 KB chunks, adjust size if needed
44
+
45
+ for file in file_uuid:
46
+ response = client.get(
47
+ url,
48
+ params={"uuid": file, "expires": True},
49
+ )
50
+ if response.status_code >= 400:
51
+ raise AccessDeniedException(
52
+ f"Failed to download file: {response.json()['message']}",
53
+ "Status Code: " + str(response.status_code),
54
+ )
55
+ download_url = response.text
56
+ if isDir:
57
+ filename = download_url.split("/")[6].split("?")[0] # Trust me bro
58
+ filepath = os.path.join(fixed_local_path, filename)
59
+ elif not isDir and len(file_uuid) == 1:
60
+ filepath = fixed_local_path
61
+ else:
62
+ raise ValueError("Multiple files can only be downloaded to a directory")
63
+ if os.path.exists(filepath):
64
+ raise FileExistsError(f"File already exists: {filepath}")
65
+ print(f"Downloading to: {filepath}")
66
+ filestream = requests.get(download_url, stream=True)
67
+ with open(filepath, "wb") as f:
68
+ for chunk in filestream.iter_content(chunk_size=chunk_size):
69
+ if chunk: # Filter out keep-alive new chunks
70
+ f.write(chunk)
71
+ print(f"Completed")
72
+
73
+
19
74
  @file.command("list")
20
75
  def list_files(
21
76
  project: Optional[str] = typer.Option(None, help="Name of Project"),
@@ -192,7 +192,7 @@ def download(
192
192
  print(f" - {filename}")
193
193
 
194
194
  response = requests.get(path, stream=True) # Enable streaming mode
195
- chunk_size = 1024 # 1 KB chunks, adjust size if needed
195
+ chunk_size = 1024 * 100 # 100 KB chunks, adjust size if needed
196
196
 
197
197
  # Open the file for writing in binary mode
198
198
  with open(os.path.join(local_path, filename), "wb") as f: