meerschaum 1.7.1__py3-none-any.whl → 1.7.3__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.
- meerschaum/_internal/arguments/_parser.py +1 -1
- meerschaum/actions/api.py +3 -2
- meerschaum/actions/stack.py +5 -9
- meerschaum/api/dash/components.py +2 -2
- meerschaum/api/routes/_misc.py +27 -1
- meerschaum/config/__init__.py +4 -4
- meerschaum/config/_edit.py +10 -20
- meerschaum/config/_read_config.py +11 -12
- meerschaum/config/_sync.py +44 -75
- meerschaum/config/_version.py +1 -1
- meerschaum/config/stack/__init__.py +31 -21
- meerschaum/config/static/__init__.py +7 -2
- meerschaum/connectors/api/_actions.py +2 -2
- meerschaum/connectors/api/_login.py +2 -2
- meerschaum/connectors/api/_misc.py +6 -26
- meerschaum/connectors/api/_plugins.py +4 -5
- meerschaum/connectors/api/_users.py +14 -14
- meerschaum/connectors/parse.py +2 -2
- meerschaum/connectors/sql/_users.py +1 -1
- meerschaum/core/User/_User.py +7 -3
- meerschaum/utils/venv/_Venv.py +2 -0
- meerschaum/utils/venv/__init__.py +14 -9
- meerschaum-1.7.3.dist-info/METADATA +500 -0
- {meerschaum-1.7.1.dist-info → meerschaum-1.7.3.dist-info}/RECORD +30 -30
- {meerschaum-1.7.1.dist-info → meerschaum-1.7.3.dist-info}/WHEEL +1 -1
- meerschaum-1.7.1.dist-info/METADATA +0 -499
- {meerschaum-1.7.1.dist-info → meerschaum-1.7.3.dist-info}/LICENSE +0 -0
- {meerschaum-1.7.1.dist-info → meerschaum-1.7.3.dist-info}/NOTICE +0 -0
- {meerschaum-1.7.1.dist-info → meerschaum-1.7.3.dist-info}/entry_points.txt +0 -0
- {meerschaum-1.7.1.dist-info → meerschaum-1.7.3.dist-info}/top_level.txt +0 -0
- {meerschaum-1.7.1.dist-info → meerschaum-1.7.3.dist-info}/zip-safe +0 -0
@@ -11,22 +11,12 @@ from meerschaum.utils.typing import Optional
|
|
11
11
|
|
12
12
|
def get_mrsm_version(self, **kw) -> Optional[str]:
|
13
13
|
"""
|
14
|
-
|
15
|
-
Parameters
|
16
|
-
----------
|
17
|
-
**kw :
|
18
|
-
|
19
|
-
|
20
|
-
Returns
|
21
|
-
-------
|
22
|
-
type
|
23
|
-
|
24
|
-
|
14
|
+
Return the Meerschaum version of the API instance.
|
25
15
|
"""
|
26
|
-
from meerschaum.config.static import
|
16
|
+
from meerschaum.config.static import STATIC_CONFIG
|
27
17
|
try:
|
28
18
|
j = self.get(
|
29
|
-
|
19
|
+
STATIC_CONFIG['api']['endpoints']['version'] + '/mrsm',
|
30
20
|
use_token = True,
|
31
21
|
**kw
|
32
22
|
).json()
|
@@ -38,22 +28,12 @@ def get_mrsm_version(self, **kw) -> Optional[str]:
|
|
38
28
|
|
39
29
|
def get_chaining_status(self, **kw) -> Optional[bool]:
|
40
30
|
"""
|
41
|
-
|
42
|
-
Parameters
|
43
|
-
----------
|
44
|
-
**kw :
|
45
|
-
|
46
|
-
|
47
|
-
Returns
|
48
|
-
-------
|
49
|
-
type
|
50
|
-
|
51
|
-
|
31
|
+
Fetch the chaining status of the API instance.
|
52
32
|
"""
|
53
|
-
from meerschaum.config.static import
|
33
|
+
from meerschaum.config.static import STATIC_CONFIG
|
54
34
|
try:
|
55
35
|
response = self.get(
|
56
|
-
|
36
|
+
STATIC_CONFIG['api']['endpoints']['chaining'],
|
57
37
|
use_token = True,
|
58
38
|
**kw
|
59
39
|
)
|
@@ -13,8 +13,8 @@ def plugin_r_url(
|
|
13
13
|
plugin: Union[meerschaum.core.Plugin, str]
|
14
14
|
) -> str:
|
15
15
|
"""Generate a relative URL path from a Plugin."""
|
16
|
-
from meerschaum.config.static import
|
17
|
-
return f"{
|
16
|
+
from meerschaum.config.static import STATIC_CONFIG
|
17
|
+
return f"{STATIC_CONFIG['api']['endpoints']['plugins']}/{plugin}"
|
18
18
|
|
19
19
|
def register_plugin(
|
20
20
|
self,
|
@@ -105,9 +105,9 @@ def get_plugins(
|
|
105
105
|
"""
|
106
106
|
import json
|
107
107
|
from meerschaum.utils.warnings import warn, error
|
108
|
-
from meerschaum.config.static import
|
108
|
+
from meerschaum.config.static import STATIC_CONFIG
|
109
109
|
response = self.get(
|
110
|
-
|
110
|
+
STATIC_CONFIG['api']['endpoints']['plugins'],
|
111
111
|
params = {'user_id' : user_id, 'search_term' : search_term},
|
112
112
|
use_token = True,
|
113
113
|
debug = debug
|
@@ -129,7 +129,6 @@ def get_plugin_attributes(
|
|
129
129
|
"""
|
130
130
|
import json
|
131
131
|
from meerschaum.utils.warnings import warn, error
|
132
|
-
from meerschaum.config.static import _static_config
|
133
132
|
r_url = plugin_r_url(plugin) + '/attributes'
|
134
133
|
response = self.get(r_url, use_token=True, debug=debug)
|
135
134
|
attributes = response.json()
|
@@ -17,10 +17,10 @@ def get_users(
|
|
17
17
|
"""
|
18
18
|
Return a list of registered usernames.
|
19
19
|
"""
|
20
|
-
from meerschaum.config.static import
|
20
|
+
from meerschaum.config.static import STATIC_CONFIG
|
21
21
|
import json
|
22
22
|
response = self.get(
|
23
|
-
f"{
|
23
|
+
f"{STATIC_CONFIG['api']['endpoints']['users']}",
|
24
24
|
debug = debug,
|
25
25
|
use_token = True,
|
26
26
|
)
|
@@ -69,8 +69,8 @@ def register_user(
|
|
69
69
|
) -> SuccessTuple:
|
70
70
|
"""Register a new user."""
|
71
71
|
import json
|
72
|
-
from meerschaum.config.static import
|
73
|
-
r_url = f"{
|
72
|
+
from meerschaum.config.static import STATIC_CONFIG
|
73
|
+
r_url = f"{STATIC_CONFIG['api']['endpoints']['users']}/register"
|
74
74
|
data = {
|
75
75
|
'username': user.username,
|
76
76
|
'password': user.password,
|
@@ -100,9 +100,9 @@ def get_user_id(
|
|
100
100
|
**kw: Any
|
101
101
|
) -> Optional[int]:
|
102
102
|
"""Get a user's ID."""
|
103
|
-
from meerschaum.config.static import
|
103
|
+
from meerschaum.config.static import STATIC_CONFIG
|
104
104
|
import json
|
105
|
-
r_url = f"{
|
105
|
+
r_url = f"{STATIC_CONFIG['api']['endpoints']['users']}/{user.username}/id"
|
106
106
|
response = self.get(r_url, debug=debug, **kw)
|
107
107
|
try:
|
108
108
|
user_id = int(json.loads(response.text))
|
@@ -117,9 +117,9 @@ def delete_user(
|
|
117
117
|
**kw: Any
|
118
118
|
) -> SuccessTuple:
|
119
119
|
"""Delete a user."""
|
120
|
-
from meerschaum.config.static import
|
120
|
+
from meerschaum.config.static import STATIC_CONFIG
|
121
121
|
import json
|
122
|
-
r_url = f"{
|
122
|
+
r_url = f"{STATIC_CONFIG['api']['endpoints']['users']}/{user.username}"
|
123
123
|
response = self.delete(r_url, debug=debug)
|
124
124
|
try:
|
125
125
|
_json = json.loads(response.text)
|
@@ -137,9 +137,9 @@ def get_user_attributes(
|
|
137
137
|
**kw
|
138
138
|
) -> int:
|
139
139
|
"""Get a user's attributes."""
|
140
|
-
from meerschaum.config.static import
|
140
|
+
from meerschaum.config.static import STATIC_CONFIG
|
141
141
|
import json
|
142
|
-
r_url = f"{
|
142
|
+
r_url = f"{STATIC_CONFIG['api']['endpoints']['users']}/{user.username}/attributes"
|
143
143
|
response = self.get(r_url, debug=debug, **kw)
|
144
144
|
try:
|
145
145
|
attributes = json.loads(response.text)
|
@@ -158,8 +158,8 @@ def get_user_password_hash(
|
|
158
158
|
**kw: Any
|
159
159
|
) -> Optional[str]:
|
160
160
|
"""If configured, get a user's password hash."""
|
161
|
-
from meerschaum.config.static import
|
162
|
-
r_url =
|
161
|
+
from meerschaum.config.static import STATIC_CONFIG
|
162
|
+
r_url = STATIC_CONFIG['api']['endpoints']['users'] + '/' + user.username + '/password_hash'
|
163
163
|
response = self.get(r_url, debug=debug, **kw)
|
164
164
|
if not response:
|
165
165
|
return None
|
@@ -172,8 +172,8 @@ def get_user_type(
|
|
172
172
|
**kw: Any
|
173
173
|
) -> Optional[str]:
|
174
174
|
"""If configured, get a user's type."""
|
175
|
-
from meerschaum.config.static import
|
176
|
-
r_url =
|
175
|
+
from meerschaum.config.static import STATIC_CONFIG
|
176
|
+
r_url = STATIC_CONFIG['api']['endpoints']['users'] + '/' + user.username + '/type'
|
177
177
|
response = self.get(r_url, debug=debug, **kw)
|
178
178
|
if not response:
|
179
179
|
return None
|
meerschaum/connectors/parse.py
CHANGED
@@ -53,14 +53,14 @@ def parse_connector_keys(
|
|
53
53
|
import copy
|
54
54
|
from meerschaum.connectors import get_connector
|
55
55
|
from meerschaum.config import get_config
|
56
|
-
from meerschaum.config.static import
|
56
|
+
from meerschaum.config.static import STATIC_CONFIG
|
57
57
|
from meerschaum.utils.warnings import error
|
58
58
|
|
59
59
|
### `get_connector()` handles the logic for falling back to 'main',
|
60
60
|
### so don't make any decisions here.
|
61
61
|
vals = str(keys).split(':')
|
62
62
|
_type = vals[0]
|
63
|
-
_label = vals[1] if len(vals) > 1 else
|
63
|
+
_label = vals[1] if len(vals) > 1 else STATIC_CONFIG['connectors']['default_label']
|
64
64
|
_get_connector_kw = {'type': _type, 'label': _label}
|
65
65
|
_get_connector_kw.update(kw)
|
66
66
|
|
@@ -70,7 +70,7 @@ def valid_username(username: str) -> SuccessTuple:
|
|
70
70
|
if len(username) > max_length:
|
71
71
|
fail_reasons.append(f"Usernames must contain {max_length} or fewer characters.")
|
72
72
|
|
73
|
-
acceptable_chars = {'_', '-'}
|
73
|
+
acceptable_chars = {'_', '-', '.', '@'}
|
74
74
|
for c in username:
|
75
75
|
if not c.isalnum() and c not in acceptable_chars:
|
76
76
|
fail_reasons.append(
|
meerschaum/core/User/_User.py
CHANGED
@@ -13,9 +13,9 @@ pwd_context = None
|
|
13
13
|
def get_pwd_context():
|
14
14
|
global pwd_context
|
15
15
|
if pwd_context is None:
|
16
|
-
from meerschaum.config.static import
|
16
|
+
from meerschaum.config.static import STATIC_CONFIG
|
17
17
|
from meerschaum.utils.packages import attempt_import
|
18
|
-
hash_config =
|
18
|
+
hash_config = STATIC_CONFIG['users']['password_hash']
|
19
19
|
passlib_context = attempt_import('passlib.context')
|
20
20
|
pwd_context = passlib_context.CryptContext(
|
21
21
|
schemes = hash_config['schemes'],
|
@@ -24,7 +24,11 @@ def get_pwd_context():
|
|
24
24
|
)
|
25
25
|
return pwd_context
|
26
26
|
|
27
|
-
class User
|
27
|
+
class User:
|
28
|
+
"""
|
29
|
+
The Meerschaum User object manages authentication to a given instance.
|
30
|
+
"""
|
31
|
+
|
28
32
|
def __init__(
|
29
33
|
self,
|
30
34
|
username: str,
|
meerschaum/utils/venv/_Venv.py
CHANGED
@@ -579,16 +579,21 @@ def venv_target_path(
|
|
579
579
|
|
580
580
|
if not inside_venv():
|
581
581
|
site_path = pathlib.Path(site.getusersitepackages())
|
582
|
-
### Allow for dist-level paths (running as root).
|
583
582
|
if not site_path.exists():
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
583
|
+
|
584
|
+
### Windows does not have `os.geteuid()`.
|
585
|
+
if platform.system() == 'Windows' or os.geteuid() != 0:
|
586
|
+
site_path.mkdir(parents=True, exist_ok=True)
|
587
|
+
return site_path
|
588
|
+
|
589
|
+
### Allow for dist-level paths (running as root).
|
590
|
+
for possible_dist in reversed(site.getsitepackages()):
|
591
|
+
dist_path = pathlib.Path(possible_dist)
|
592
|
+
if not dist_path.exists():
|
593
|
+
continue
|
594
|
+
return dist_path
|
595
|
+
|
596
|
+
raise EnvironmentError("Could not determine the dist-packages directory.")
|
592
597
|
|
593
598
|
return site_path
|
594
599
|
|