qmenta-client 3.0.0.dev1529__tar.gz → 4.0.0.dev1531__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: qmenta-client
3
- Version: 3.0.0.dev1529
3
+ Version: 4.0.0.dev1531
4
4
  Summary: Python client lib to interact with the QMENTA platform.
5
5
  Author: QMENTA
6
6
  Author-email: dev@qmenta.com
@@ -14,5 +14,5 @@ Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Requires-Dist: future (>=0.18.2,<0.19.0)
16
16
  Requires-Dist: pytest-cov (>=6.1.1,<7.0.0)
17
- Requires-Dist: qmenta-core (==5.0.0.dev723)
17
+ Requires-Dist: qmenta-core (==6.0.0.dev729)
18
18
  Project-URL: Homepage, https://www.qmenta.com/
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "qmenta-client"
3
- version = "3.0.0.dev1529"
3
+ version = "4.0.0.dev1531"
4
4
  description = "Python client lib to interact with the QMENTA platform."
5
5
  authors = ["QMENTA <dev@qmenta.com>"]
6
6
  homepage = "https://www.qmenta.com/"
@@ -15,7 +15,7 @@ packages = [
15
15
  [tool.poetry.dependencies]
16
16
  python = "^3.10"
17
17
  future = "^0.18.2"
18
- qmenta-core = "5.0.0.dev723"
18
+ qmenta-core = "6.0.0.dev729"
19
19
  pytest-cov = "^6.1.1"
20
20
 
21
21
  [tool.poetry.group.dev.dependencies]
@@ -3,7 +3,7 @@ from __future__ import print_function
3
3
  import logging
4
4
  from qmenta.core import errors
5
5
  from qmenta.core import platform
6
- from qmenta.core.auth import InvalidLoginError
6
+ from qmenta.core.auth import InvalidLoginError, Needs2FAError
7
7
  from urllib3.exceptions import HTTPError
8
8
 
9
9
  from .Project import Project
@@ -34,8 +34,8 @@ class Account:
34
34
  Valid credential combinations
35
35
  -----------------------------
36
36
  username + password
37
- Classic login. If two-factor authentication (2FA) is enabled on the
38
- account, the user is prompted for the code interactively.
37
+ Classic login. Not supported for accounts with two-factor
38
+ authentication (2FA) enabled; use ``api_key`` instead.
39
39
  api_key
40
40
  API-key login. 2FA is not required.
41
41
  username + password + api_key
@@ -77,8 +77,8 @@ class Account:
77
77
  Uses the credentials set on the instance (``username``/``password``
78
78
  and/or ``api_key``). Valid combinations:
79
79
 
80
- - ``username`` + ``password``: classic login. If 2FA is enabled on
81
- the account, the user is prompted for the code interactively.
80
+ - ``username`` + ``password``: classic login. Not supported for
81
+ accounts with 2FA enabled; use ``api_key`` instead.
82
82
  - ``api_key``: API-key login. 2FA is not required.
83
83
  - ``username`` + ``password`` + ``api_key``: all values are forwarded
84
84
  to the authentication layer, which decides which credential to use.
@@ -87,6 +87,9 @@ class Account:
87
87
  ------
88
88
  qmenta.core.auth.InvalidLoginError
89
89
  When the provided credentials are invalid.
90
+ qmenta.core.auth.Needs2FAError
91
+ When the account has two-factor authentication enabled.
92
+ Generate an API key and log in with ``api_key`` instead.
90
93
  qmenta.core.platform.ConnectionError
91
94
  When the connection to the platform fails.
92
95
  qmenta.core.errors.PlatformError
@@ -99,12 +102,21 @@ class Account:
99
102
  password=self.password,
100
103
  api_key=self.api_key,
101
104
  base_url=self.baseurl,
102
- ask_for_2fa_input=True,
103
105
  )
104
106
  except InvalidLoginError as e:
105
107
  logger.error("Failed to log in: {}".format(e))
106
108
  self.auth = None
107
109
  raise
110
+ except Needs2FAError:
111
+ logger.error(
112
+ "Failed to log in: this account has two-factor "
113
+ "authentication enabled, which is not supported for "
114
+ "username/password login. Generate an API key in the "
115
+ "platform (My profile -> Credentials) and pass it as the "
116
+ "api_key argument of Account instead."
117
+ )
118
+ self.auth = None
119
+ raise
108
120
  except errors.PlatformError as e:
109
121
  logger.error("Failed to log in: {}".format(e))
110
122
  self.auth = None