qmenta-core 4.1.dev708__py3-none-any.whl → 4.1.dev710__py3-none-any.whl
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 qmenta-core might be problematic. Click here for more details.
- qmenta/core/auth.py +24 -2
- qmenta/core/platform.py +2 -2
- {qmenta_core-4.1.dev708.dist-info → qmenta_core-4.1.dev710.dist-info}/METADATA +1 -1
- {qmenta_core-4.1.dev708.dist-info → qmenta_core-4.1.dev710.dist-info}/RECORD +6 -6
- {qmenta_core-4.1.dev708.dist-info → qmenta_core-4.1.dev710.dist-info}/WHEEL +0 -0
- {qmenta_core-4.1.dev708.dist-info → qmenta_core-4.1.dev710.dist-info}/entry_points.txt +0 -0
qmenta/core/auth.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import argparse
|
|
2
|
+
from enum import Enum, unique
|
|
2
3
|
import os
|
|
3
4
|
import requests
|
|
4
5
|
from getpass import getpass
|
|
@@ -32,6 +33,15 @@ class Needs2FAError(ActionFailedError):
|
|
|
32
33
|
pass
|
|
33
34
|
|
|
34
35
|
|
|
36
|
+
@unique
|
|
37
|
+
class PlatformURL(Enum):
|
|
38
|
+
platform = 'platform.qmenta.com'
|
|
39
|
+
staging = 'staging.qmenta.com'
|
|
40
|
+
test = 'test.qmenta.com'
|
|
41
|
+
local_ip = "127.0.0.1:8080"
|
|
42
|
+
localhost = "localhost:8080"
|
|
43
|
+
|
|
44
|
+
|
|
35
45
|
class Auth:
|
|
36
46
|
"""
|
|
37
47
|
Class for authenticating to the platform.
|
|
@@ -41,11 +51,13 @@ class Auth:
|
|
|
41
51
|
Attributes
|
|
42
52
|
----------
|
|
43
53
|
base_url : str
|
|
44
|
-
The
|
|
54
|
+
The URL of the platform to connect to.
|
|
55
|
+
Default value: 'https://platform.qmenta.com'
|
|
45
56
|
token : str
|
|
46
57
|
The authentication token, returned by the platform when logging in.
|
|
47
58
|
"""
|
|
48
59
|
def __init__(self, base_url: str, token: str) -> None:
|
|
60
|
+
validate_url(base_url)
|
|
49
61
|
self.base_url = base_url
|
|
50
62
|
self.token = token
|
|
51
63
|
self._session: Optional[requests.Session] = None
|
|
@@ -101,7 +113,7 @@ class Auth:
|
|
|
101
113
|
def login(cls, username: str, password: str,
|
|
102
114
|
code_2fa: Optional[str] = None,
|
|
103
115
|
ask_for_2fa_input: bool = False,
|
|
104
|
-
base_url: str =
|
|
116
|
+
base_url: str = PlatformURL.platform.value) -> 'Auth':
|
|
105
117
|
"""
|
|
106
118
|
Authenticate to the platform using username and password.
|
|
107
119
|
|
|
@@ -232,6 +244,8 @@ def write_dot_env_file(token: str, url: str,
|
|
|
232
244
|
OSError
|
|
233
245
|
When the output file could not be written
|
|
234
246
|
"""
|
|
247
|
+
validate_url(url)
|
|
248
|
+
|
|
235
249
|
filepath = filename or Auth.qmenta_auth_env_file()
|
|
236
250
|
os.makedirs(os.path.dirname(os.path.abspath(filepath)), exist_ok=True)
|
|
237
251
|
|
|
@@ -251,6 +265,7 @@ def validate_url(url: str) -> None:
|
|
|
251
265
|
ValueError
|
|
252
266
|
When the URL is not valid
|
|
253
267
|
"""
|
|
268
|
+
|
|
254
269
|
parsed_url = urlparse(url)
|
|
255
270
|
|
|
256
271
|
if parsed_url.scheme == 'http':
|
|
@@ -271,6 +286,13 @@ def validate_url(url: str) -> None:
|
|
|
271
286
|
'Example: https://platform.qmenta.com'
|
|
272
287
|
)
|
|
273
288
|
|
|
289
|
+
url_values = [p_url.value for p_url in PlatformURL]
|
|
290
|
+
if parsed_url.netloc not in url_values:
|
|
291
|
+
raise ValueError(
|
|
292
|
+
"base_url must be one of '{}', ".format("', '".join(url_values))
|
|
293
|
+
+ f"not '{parsed_url.netloc}'."
|
|
294
|
+
)
|
|
295
|
+
|
|
274
296
|
|
|
275
297
|
def main() -> None:
|
|
276
298
|
parser = argparse.ArgumentParser(
|
qmenta/core/platform.py
CHANGED
|
@@ -29,8 +29,8 @@ class ChooseDataError(ActionFailedError):
|
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
31
|
def __init__(
|
|
32
|
-
self, warning: str, data_to_choose: Dict[str, List[str]]
|
|
33
|
-
|
|
32
|
+
self, warning: str, data_to_choose: Dict[str, List[str]],
|
|
33
|
+
analysis_id: int
|
|
34
34
|
) -> None:
|
|
35
35
|
self.warning: str = warning
|
|
36
36
|
self.data_to_choose: dict = data_to_choose
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
qmenta/__init__.py,sha256=jv2YF__bseklT3OWEzlqJ5qE24c4aWd5F4r0TTjOrWQ,65
|
|
2
2
|
qmenta/core/.gitignore,sha256=T_6cEPGYAfQ6-gdGwpLCLe1SpRnTl4vwi4qfVM1QsYI,8
|
|
3
3
|
qmenta/core/__init__.py,sha256=J_Se74WI6plv-7tRufJDsXpgxG_WRX4pwLvK-Hhq4Ls,304
|
|
4
|
-
qmenta/core/auth.py,sha256=
|
|
4
|
+
qmenta/core/auth.py,sha256=4siYjRuoNgjYvpkBbiV-llkCdKMX-IS8S2h3kHdLPvs,10590
|
|
5
5
|
qmenta/core/errors.py,sha256=eu72sENP9YUVN1w9Urji1nH0V41pdg4UiSvxjun6ggE,1145
|
|
6
|
-
qmenta/core/platform.py,sha256=
|
|
6
|
+
qmenta/core/platform.py,sha256=5nKxE2xwvwMRgNAHcCPVscgX8LHdb5lAP-VTBzfKZcM,5503
|
|
7
7
|
qmenta/core/upload/__init__.py,sha256=-VHwhSQkdUmw697v4o59iDiqdU6kh-8_3BklGp4W864,182
|
|
8
8
|
qmenta/core/upload/multi.py,sha256=3XiGxguP7V2zrGyKsaQx6xarbsVr-wUINkgLZJFQbno,4963
|
|
9
9
|
qmenta/core/upload/prepare.py,sha256=JcFSl8RRCsNnzcNvn7-d7ARUfZvvEJhuCuW5VbMjmpI,8139
|
|
10
10
|
qmenta/core/upload/single.py,sha256=FE4ZucI3qIEfzqhZKQPOKremzez7CjMRS28t-tsep4E,19356
|
|
11
11
|
qmenta/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
qmenta_core-4.1.
|
|
13
|
-
qmenta_core-4.1.
|
|
14
|
-
qmenta_core-4.1.
|
|
15
|
-
qmenta_core-4.1.
|
|
12
|
+
qmenta_core-4.1.dev710.dist-info/METADATA,sha256=Xr5TlwfWApkknDvofPwmI_yztZEgs36EmPv_MZ8EZNE,1155
|
|
13
|
+
qmenta_core-4.1.dev710.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
14
|
+
qmenta_core-4.1.dev710.dist-info/entry_points.txt,sha256=8c0Nh22PxTp8Auui-k8qIinhdaotgc-wulDC3-PC92c,53
|
|
15
|
+
qmenta_core-4.1.dev710.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|