kleinkram 0.0.115__tar.gz → 0.0.117__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.0.115 → kleinkram-0.0.117}/PKG-INFO +1 -1
- {kleinkram-0.0.115 → kleinkram-0.0.117}/pyproject.toml +1 -1
- {kleinkram-0.0.115 → kleinkram-0.0.117}/src/kleinkram/auth.py +51 -15
- kleinkram-0.0.117/src/kleinkram/consts.py +1 -0
- {kleinkram-0.0.115 → kleinkram-0.0.117}/src/kleinkram/main.py +8 -4
- kleinkram-0.0.115/src/kleinkram/consts.py +0 -2
- {kleinkram-0.0.115 → kleinkram-0.0.117}/.gitignore +0 -0
- {kleinkram-0.0.115 → kleinkram-0.0.117}/LICENSE +0 -0
- {kleinkram-0.0.115 → kleinkram-0.0.117}/README.md +0 -0
- {kleinkram-0.0.115 → kleinkram-0.0.117}/deploy.sh +0 -0
- {kleinkram-0.0.115 → kleinkram-0.0.117}/dev.sh +0 -0
- {kleinkram-0.0.115 → kleinkram-0.0.117}/requirements.txt +0 -0
- {kleinkram-0.0.115 → kleinkram-0.0.117}/src/kleinkram/__init__.py +0 -0
- {kleinkram-0.0.115 → kleinkram-0.0.117}/src/kleinkram/helper.py +0 -0
|
@@ -72,6 +72,7 @@ class OAuthCallbackHandler(BaseHTTPRequestHandler):
|
|
|
72
72
|
self.end_headers()
|
|
73
73
|
self.wfile.write(b"Authentication successful. You can close this window.")
|
|
74
74
|
return
|
|
75
|
+
print("here")
|
|
75
76
|
|
|
76
77
|
def log_message(self, format, *args):
|
|
77
78
|
pass
|
|
@@ -90,8 +91,8 @@ class AuthenticatedClient(httpx.Client):
|
|
|
90
91
|
try:
|
|
91
92
|
self.tokenfile = TokenFile()
|
|
92
93
|
self._load_cookies()
|
|
93
|
-
except:
|
|
94
|
-
print("
|
|
94
|
+
except Exception as e:
|
|
95
|
+
print(f"{self.tokenfile.endpoint} is not authenticated. Please run 'klein login'.")
|
|
95
96
|
|
|
96
97
|
def _load_cookies(self):
|
|
97
98
|
if self.tokenfile.isCliToken():
|
|
@@ -107,7 +108,7 @@ class AuthenticatedClient(httpx.Client):
|
|
|
107
108
|
if not refresh_token:
|
|
108
109
|
print("No refresh token found. Please login again.")
|
|
109
110
|
raise Exception("No refresh token found.")
|
|
110
|
-
self.cookies.set(REFRESH_TOKEN, refresh_token,)
|
|
111
|
+
self.cookies.set(REFRESH_TOKEN, refresh_token, )
|
|
111
112
|
response = self.post(
|
|
112
113
|
"/auth/refresh-token",
|
|
113
114
|
)
|
|
@@ -122,7 +123,7 @@ class AuthenticatedClient(httpx.Client):
|
|
|
122
123
|
method, self.tokenfile.endpoint + url, *args, **kwargs
|
|
123
124
|
)
|
|
124
125
|
if (
|
|
125
|
-
|
|
126
|
+
url == "/auth/refresh-token"
|
|
126
127
|
) and response.status_code == 401:
|
|
127
128
|
print("Refresh token expired. Please login again.")
|
|
128
129
|
response.status_code = 403
|
|
@@ -137,30 +138,65 @@ class AuthenticatedClient(httpx.Client):
|
|
|
137
138
|
client = AuthenticatedClient()
|
|
138
139
|
|
|
139
140
|
|
|
140
|
-
def login(
|
|
141
|
+
def login(
|
|
142
|
+
key: Annotated[str, typer.Option()] = None,
|
|
143
|
+
open_browser: Annotated[bool, typer.Option()] = True,
|
|
144
|
+
):
|
|
141
145
|
tokenfile = TokenFile()
|
|
142
146
|
if key:
|
|
143
147
|
tokenfile.saveTokens(key)
|
|
144
148
|
else:
|
|
145
|
-
|
|
146
|
-
webbrowser.open(tokenfile.endpoint + "/auth/google?state=cli")
|
|
149
|
+
url = tokenfile.endpoint + "/auth/google?state=cli"
|
|
147
150
|
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
has_browser = True
|
|
152
|
+
try:
|
|
153
|
+
browser_available = webbrowser.get()
|
|
154
|
+
if not browser_available:
|
|
155
|
+
raise Exception("No web browser available.")
|
|
156
|
+
except Exception as e:
|
|
157
|
+
has_browser = False
|
|
150
158
|
|
|
151
|
-
if
|
|
152
|
-
|
|
153
|
-
|
|
159
|
+
if has_browser and open_browser:
|
|
160
|
+
webbrowser.open(url)
|
|
161
|
+
auth_tokens = get_auth_tokens()
|
|
162
|
+
|
|
163
|
+
if not auth_tokens:
|
|
164
|
+
print("Failed to get authentication tokens.")
|
|
165
|
+
return
|
|
154
166
|
|
|
155
|
-
|
|
167
|
+
tokenfile.saveTokens(auth_tokens)
|
|
168
|
+
print("Authentication complete. Tokens saved to ~/.kleinkram.json.")
|
|
169
|
+
|
|
170
|
+
return
|
|
156
171
|
|
|
157
|
-
print("
|
|
172
|
+
print(f"Please open the following URL manually in your browser to authenticate: {url + '-no-redirect'}")
|
|
173
|
+
print("Enter the authentication token provided after logging in:")
|
|
174
|
+
manual_auth_token = input("Authentication Token: ")
|
|
175
|
+
manual_refresh_token = input("Refresh Token: ")
|
|
176
|
+
if manual_auth_token:
|
|
177
|
+
tokenfile.saveTokens({AUTH_TOKEN: manual_auth_token, REFRESH_TOKEN: manual_refresh_token})
|
|
178
|
+
print("Authentication complete. Tokens saved to tokens.json.")
|
|
179
|
+
else:
|
|
180
|
+
print("No authentication token provided.")
|
|
181
|
+
return
|
|
158
182
|
|
|
159
183
|
|
|
160
|
-
def
|
|
184
|
+
def setEndpoint(endpoint: Annotated[str, typer.Argument()]):
|
|
161
185
|
tokenfile = TokenFile()
|
|
162
186
|
tokenfile.endpoint = endpoint
|
|
163
187
|
tokenfile.writeToFile()
|
|
188
|
+
print("Endpoint set to: " + endpoint)
|
|
189
|
+
if tokenfile.endpoint not in tokenfile.tokens:
|
|
190
|
+
print("No tokens found for this endpoint.")
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def endpoint():
|
|
194
|
+
tokenfile = TokenFile()
|
|
195
|
+
print("Current: " + tokenfile.endpoint)
|
|
196
|
+
print("Saved Tokens found for:")
|
|
197
|
+
for _endpoint, _ in tokenfile.tokens.items():
|
|
198
|
+
print(_endpoint)
|
|
199
|
+
|
|
164
200
|
|
|
165
201
|
def setCliKey(key: Annotated[str, typer.Argument()]):
|
|
166
202
|
tokenfile = TokenFile()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
API_URL='https://api.datasets.leggedrobotics.com'
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import sys
|
|
1
2
|
from datetime import datetime, timedelta
|
|
2
3
|
import os
|
|
3
4
|
|
|
@@ -10,7 +11,7 @@ from rich.table import Table
|
|
|
10
11
|
|
|
11
12
|
from .helper import uploadFiles, expand_and_match
|
|
12
13
|
|
|
13
|
-
from .auth import login, client, endpoint, setCliKey
|
|
14
|
+
from .auth import login, client, endpoint, setCliKey, setEndpoint
|
|
14
15
|
|
|
15
16
|
app = typer.Typer()
|
|
16
17
|
projects = typer.Typer(name="projects")
|
|
@@ -33,6 +34,7 @@ app.add_typer(tagtypes)
|
|
|
33
34
|
app.add_typer(tag)
|
|
34
35
|
app.command()(login)
|
|
35
36
|
app.command()(endpoint)
|
|
37
|
+
app.command()(setEndpoint)
|
|
36
38
|
app.command()(setCliKey)
|
|
37
39
|
|
|
38
40
|
|
|
@@ -424,9 +426,11 @@ def addTag(
|
|
|
424
426
|
else:
|
|
425
427
|
print(response.json())
|
|
426
428
|
print("Failed to tag mission")
|
|
427
|
-
except:
|
|
428
|
-
print(
|
|
429
|
-
)
|
|
429
|
+
except httpx.HTTPError as e:
|
|
430
|
+
print(e)
|
|
431
|
+
print("Failed to tag mission")
|
|
432
|
+
sys.exit(1)
|
|
433
|
+
|
|
430
434
|
|
|
431
435
|
@tagtypes.command('list')
|
|
432
436
|
def tagTypes(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|