kleinkram 0.26.1.dev20241008115122__tar.gz → 0.28.0.dev20241008161920__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.
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/PKG-INFO +1 -1
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/pyproject.toml +1 -1
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/file/file.py +49 -1
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/mission/mission.py +1 -1
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/.gitignore +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/LICENSE +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/README.md +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/deploy.sh +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/dev.sh +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/requirements.txt +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/klein.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/__init__.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/api_client.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/auth/auth.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/consts.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/endpoint/endpoint.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/error_handling.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/helper.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/main.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/project/project.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/queue/queue.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/tag/tag.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/topic/topic.py +0 -0
- {kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/user/user.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: kleinkram
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.28.0.dev20241008161920
|
|
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
|
{kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/file/file.py
RENAMED
|
@@ -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
|
|
@@ -15,6 +15,54 @@ file = typer.Typer(
|
|
|
15
15
|
context_settings={"help_option_names": ["-h", "--help"]},
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
+
@file.command('download')
|
|
19
|
+
def download_file(
|
|
20
|
+
file_uuid: Annotated[List[str], typer.Option( help="UUIDs of the files")],
|
|
21
|
+
local_path: Annotated[str, typer.Option( prompt=True, help="Local path to save the file",)],
|
|
22
|
+
):
|
|
23
|
+
"""
|
|
24
|
+
Download files by UUIDs to a local path.\n
|
|
25
|
+
Examples:\n
|
|
26
|
+
klein file download --file-uuid="9d5a9..." --file-uuid="9833f..." --local-path="~/Downloads" \n
|
|
27
|
+
klein file download --file-uuid="9d5a9..." --local-path="~/Downloads/example.bag"
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
client = AuthenticatedClient()
|
|
31
|
+
url = f"/file/download"
|
|
32
|
+
|
|
33
|
+
fixed_local_path = os.path.expanduser(local_path)
|
|
34
|
+
|
|
35
|
+
isDir = os.path.isdir(fixed_local_path)
|
|
36
|
+
chunk_size = 1024 * 100 # 100 KB chunks, adjust size if needed
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
for file in file_uuid:
|
|
40
|
+
response = client.get(
|
|
41
|
+
url,
|
|
42
|
+
params={"uuid": file, "expires": True},
|
|
43
|
+
)
|
|
44
|
+
if response.status_code >= 400:
|
|
45
|
+
raise AccessDeniedException(
|
|
46
|
+
f"Failed to download file: {response.json()['message']}",
|
|
47
|
+
"Status Code: " + str(response.status_code),
|
|
48
|
+
)
|
|
49
|
+
download_url = response.text
|
|
50
|
+
if isDir:
|
|
51
|
+
filename = download_url.split("/")[6].split("?")[0] # Trust me bro
|
|
52
|
+
filepath = os.path.join(fixed_local_path, filename)
|
|
53
|
+
elif not isDir and len(file_uuid) == 1:
|
|
54
|
+
filepath = fixed_local_path
|
|
55
|
+
else:
|
|
56
|
+
raise ValueError("Multiple files can only be downloaded to a directory")
|
|
57
|
+
if os.path.exists(filepath):
|
|
58
|
+
raise FileExistsError(f"File already exists: {filepath}")
|
|
59
|
+
print(f"Downloading to: {filepath}")
|
|
60
|
+
filestream = requests.get(download_url, stream=True)
|
|
61
|
+
with open(filepath, "wb") as f:
|
|
62
|
+
for chunk in filestream.iter_content(chunk_size=chunk_size):
|
|
63
|
+
if chunk: # Filter out keep-alive new chunks
|
|
64
|
+
f.write(chunk)
|
|
65
|
+
print(f"Completed")
|
|
18
66
|
|
|
19
67
|
@file.command("list")
|
|
20
68
|
def list_files(
|
|
@@ -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 #
|
|
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:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/auth/auth.py
RENAMED
|
File without changes
|
{kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/consts.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/helper.py
RENAMED
|
File without changes
|
{kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/main.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/tag/tag.py
RENAMED
|
File without changes
|
|
File without changes
|
{kleinkram-0.26.1.dev20241008115122 → kleinkram-0.28.0.dev20241008161920}/src/kleinkram/user/user.py
RENAMED
|
File without changes
|