qmenta-core 4.1.dev712__tar.gz → 4.1.dev713__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.
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/PKG-INFO +1 -1
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/pyproject.toml +1 -1
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/core/auth.py +21 -13
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/README.md +0 -0
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/__init__.py +0 -0
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/core/.gitignore +0 -0
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/core/__init__.py +0 -0
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/core/errors.py +0 -0
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/core/platform.py +0 -0
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/core/upload/__init__.py +0 -0
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/core/upload/multi.py +0 -0
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/core/upload/prepare.py +0 -0
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/core/upload/single.py +0 -0
- {qmenta_core-4.1.dev712 → qmenta_core-4.1.dev713}/src/qmenta/py.typed +0 -0
|
@@ -4,7 +4,7 @@ import os
|
|
|
4
4
|
import requests
|
|
5
5
|
from getpass import getpass
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from typing import Optional, Dict
|
|
7
|
+
from typing import Optional, Dict
|
|
8
8
|
from urllib.parse import urljoin, urlparse
|
|
9
9
|
|
|
10
10
|
from xdg import xdg_data_home
|
|
@@ -149,7 +149,7 @@ class Auth:
|
|
|
149
149
|
------
|
|
150
150
|
ConnectionError
|
|
151
151
|
If there was a problem setting up the network connection with the
|
|
152
|
-
platform.
|
|
152
|
+
platform and for 404 and 5xx response status code.
|
|
153
153
|
InvalidResponseError
|
|
154
154
|
If the platform returned an invalid response.
|
|
155
155
|
InvalidLoginError
|
|
@@ -164,25 +164,33 @@ class Auth:
|
|
|
164
164
|
url: str = urljoin(base_url, '/login')
|
|
165
165
|
|
|
166
166
|
try:
|
|
167
|
-
|
|
167
|
+
response: requests.Response = requests.post(
|
|
168
168
|
url, data={
|
|
169
169
|
'username': username, 'password': password,
|
|
170
170
|
'code_2fa': code_2fa
|
|
171
171
|
}
|
|
172
172
|
)
|
|
173
|
+
# Raises an exception for 4xx and 5xx status codes
|
|
174
|
+
response.raise_for_status()
|
|
175
|
+
# Assuming the response contains JSON data
|
|
176
|
+
data: dict = response.json()
|
|
177
|
+
# Process the data here
|
|
178
|
+
except requests.exceptions.HTTPError as e:
|
|
179
|
+
if e.response.status_code == 404:
|
|
180
|
+
raise ConnectionError("API returned a 404 error: Not Found")
|
|
181
|
+
else:
|
|
182
|
+
raise ConnectionError("API returned an error:", e)
|
|
183
|
+
except InvalidResponseError as e:
|
|
184
|
+
raise InvalidResponseError("Invalid Response Error:", e)
|
|
173
185
|
except requests.RequestException as e:
|
|
174
186
|
raise ConnectionError(str(e))
|
|
187
|
+
except Exception as e:
|
|
188
|
+
raise Exception("An error occurred:", e)
|
|
175
189
|
|
|
176
190
|
try:
|
|
177
|
-
|
|
178
|
-
except ValueError:
|
|
179
|
-
raise InvalidResponseError(
|
|
180
|
-
f'Could not decode JSON for response {r}')
|
|
181
|
-
|
|
182
|
-
try:
|
|
183
|
-
if d["success"] != 1:
|
|
191
|
+
if data["success"] != 1:
|
|
184
192
|
# Login was not successful
|
|
185
|
-
if
|
|
193
|
+
if data.get("account_state", "") == '2fa_need':
|
|
186
194
|
if ask_for_2fa_input:
|
|
187
195
|
input_2fa = input("Please enter your 2FA code: ")
|
|
188
196
|
return Auth.login(
|
|
@@ -195,9 +203,9 @@ class Auth:
|
|
|
195
203
|
'or set the ask_for_2fa_input parameter'
|
|
196
204
|
)
|
|
197
205
|
else:
|
|
198
|
-
raise InvalidLoginError(
|
|
206
|
+
raise InvalidLoginError(data['error'])
|
|
199
207
|
|
|
200
|
-
token: str =
|
|
208
|
+
token: str = data['token']
|
|
201
209
|
except KeyError as e:
|
|
202
210
|
raise InvalidResponseError(f'Missing key: {e}')
|
|
203
211
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|