meerschaum 2.6.10__py3-none-any.whl → 2.6.12__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/api/routes/_actions.py +0 -22
- meerschaum/api/routes/_jobs.py +21 -0
- meerschaum/config/_version.py +1 -1
- meerschaum/connectors/api/_pipes.py +18 -8
- meerschaum/connectors/sql/_pipes.py +1 -1
- meerschaum/core/User/__init__.py +30 -0
- meerschaum/utils/formatting/__init__.py +4 -3
- {meerschaum-2.6.10.dist-info → meerschaum-2.6.12.dist-info}/METADATA +1 -1
- {meerschaum-2.6.10.dist-info → meerschaum-2.6.12.dist-info}/RECORD +15 -15
- {meerschaum-2.6.10.dist-info → meerschaum-2.6.12.dist-info}/WHEEL +1 -1
- {meerschaum-2.6.10.dist-info → meerschaum-2.6.12.dist-info}/LICENSE +0 -0
- {meerschaum-2.6.10.dist-info → meerschaum-2.6.12.dist-info}/NOTICE +0 -0
- {meerschaum-2.6.10.dist-info → meerschaum-2.6.12.dist-info}/entry_points.txt +0 -0
- {meerschaum-2.6.10.dist-info → meerschaum-2.6.12.dist-info}/top_level.txt +0 -0
- {meerschaum-2.6.10.dist-info → meerschaum-2.6.12.dist-info}/zip-safe +0 -0
@@ -17,28 +17,6 @@ from meerschaum.config import get_config
|
|
17
17
|
|
18
18
|
actions_endpoint = endpoints['actions']
|
19
19
|
|
20
|
-
def is_user_allowed_to_execute(user) -> SuccessTuple:
|
21
|
-
if user is None:
|
22
|
-
return False, "Could not load user."
|
23
|
-
|
24
|
-
if user.type == 'admin':
|
25
|
-
return True, "Success"
|
26
|
-
|
27
|
-
allow_non_admin = get_config(
|
28
|
-
'system', 'api', 'permissions', 'actions', 'non_admin', patch=True
|
29
|
-
)
|
30
|
-
if not allow_non_admin:
|
31
|
-
return False, (
|
32
|
-
"The administrator for this server has not allowed users to perform actions.\n\n"
|
33
|
-
+ "Please contact the system administrator, or if you are running this server, "
|
34
|
-
+ "open the configuration file with `edit config system` "
|
35
|
-
+ "and search for 'permissions'. "
|
36
|
-
+ "\nUnder the keys 'api:permissions:actions', "
|
37
|
-
+ "you can allow non-admin users to perform actions."
|
38
|
-
)
|
39
|
-
|
40
|
-
return True, "Success"
|
41
|
-
|
42
20
|
|
43
21
|
@app.get(actions_endpoint, tags=['Actions'])
|
44
22
|
def get_actions(
|
meerschaum/api/routes/_jobs.py
CHANGED
@@ -32,6 +32,8 @@ from meerschaum.api import (
|
|
32
32
|
no_auth,
|
33
33
|
)
|
34
34
|
from meerschaum.config.static import STATIC_CONFIG
|
35
|
+
from meerschaum.core.User import is_user_allowed_to_execute
|
36
|
+
|
35
37
|
|
36
38
|
JOBS_STDIN_MESSAGE: str = STATIC_CONFIG['api']['jobs']['stdin_message']
|
37
39
|
JOBS_STOP_MESSAGE: str = STATIC_CONFIG['api']['jobs']['stop_message']
|
@@ -141,6 +143,10 @@ def create_job(
|
|
141
143
|
"""
|
142
144
|
Create and start a new job.
|
143
145
|
"""
|
146
|
+
allowed_success, allowed_msg = is_user_allowed_to_execute(curr_user)
|
147
|
+
if not allowed_success:
|
148
|
+
return allowed_success, allowed_msg
|
149
|
+
|
144
150
|
sysargs = metadata if isinstance(metadata, list) else metadata['sysargs']
|
145
151
|
properties = metadata['properties'] if isinstance(metadata, dict) else None
|
146
152
|
job = Job(
|
@@ -172,6 +178,9 @@ def delete_job(
|
|
172
178
|
"""
|
173
179
|
Delete a job.
|
174
180
|
"""
|
181
|
+
allowed_success, allowed_msg = is_user_allowed_to_execute(curr_user)
|
182
|
+
if not allowed_success:
|
183
|
+
return allowed_success, allowed_msg
|
175
184
|
job = _get_job(name)
|
176
185
|
return job.delete()
|
177
186
|
|
@@ -221,6 +230,10 @@ def start_job(
|
|
221
230
|
"""
|
222
231
|
Start a job if stopped.
|
223
232
|
"""
|
233
|
+
allowed_success, allowed_msg = is_user_allowed_to_execute(curr_user)
|
234
|
+
if not allowed_success:
|
235
|
+
return allowed_success, allowed_msg
|
236
|
+
|
224
237
|
job = _get_job(name)
|
225
238
|
if not job.exists():
|
226
239
|
raise fastapi.HTTPException(
|
@@ -240,6 +253,10 @@ def stop_job(
|
|
240
253
|
"""
|
241
254
|
Stop a job if running.
|
242
255
|
"""
|
256
|
+
allowed_success, allowed_msg = is_user_allowed_to_execute(curr_user)
|
257
|
+
if not allowed_success:
|
258
|
+
return allowed_success, allowed_msg
|
259
|
+
|
243
260
|
job = _get_job(name)
|
244
261
|
if not job.exists():
|
245
262
|
raise fastapi.HTTPException(
|
@@ -259,6 +276,10 @@ def pause_job(
|
|
259
276
|
"""
|
260
277
|
Pause a job if running.
|
261
278
|
"""
|
279
|
+
allowed_success, allowed_msg = is_user_allowed_to_execute(curr_user)
|
280
|
+
if not allowed_success:
|
281
|
+
return allowed_success, allowed_msg
|
282
|
+
|
262
283
|
job = _get_job(name)
|
263
284
|
if not job.exists():
|
264
285
|
raise fastapi.HTTPException(
|
meerschaum/config/_version.py
CHANGED
@@ -50,10 +50,15 @@ def register_pipe(
|
|
50
50
|
)
|
51
51
|
if debug:
|
52
52
|
dprint(response.text)
|
53
|
-
|
54
|
-
|
53
|
+
|
54
|
+
if not response:
|
55
|
+
return False, response.text
|
56
|
+
|
57
|
+
response_data = response.json()
|
58
|
+
if isinstance(response_data, list):
|
59
|
+
response_tuple = response_data[0], response_data[1]
|
55
60
|
elif 'detail' in response.json():
|
56
|
-
response_tuple = response.__bool__(),
|
61
|
+
response_tuple = response.__bool__(), response_data['detail']
|
57
62
|
else:
|
58
63
|
response_tuple = response.__bool__(), response.text
|
59
64
|
return response_tuple
|
@@ -80,10 +85,13 @@ def edit_pipe(
|
|
80
85
|
)
|
81
86
|
if debug:
|
82
87
|
dprint(response.text)
|
88
|
+
|
89
|
+
response_data = response.json()
|
90
|
+
|
83
91
|
if isinstance(response.json(), list):
|
84
|
-
response_tuple =
|
92
|
+
response_tuple = response_data[0], response_data[1]
|
85
93
|
elif 'detail' in response.json():
|
86
|
-
response_tuple = response.__bool__(),
|
94
|
+
response_tuple = response.__bool__(), response_data['detail']
|
87
95
|
else:
|
88
96
|
response_tuple = response.__bool__(), response.text
|
89
97
|
return response_tuple
|
@@ -318,10 +326,12 @@ def delete_pipe(
|
|
318
326
|
)
|
319
327
|
if debug:
|
320
328
|
dprint(response.text)
|
329
|
+
|
330
|
+
response_data = response.json()
|
321
331
|
if isinstance(response.json(), list):
|
322
|
-
response_tuple =
|
332
|
+
response_tuple = response_data[0], response_data[1]
|
323
333
|
elif 'detail' in response.json():
|
324
|
-
response_tuple = response.__bool__(),
|
334
|
+
response_tuple = response.__bool__(), response_data['detail']
|
325
335
|
else:
|
326
336
|
response_tuple = response.__bool__(), response.text
|
327
337
|
return response_tuple
|
@@ -637,7 +647,7 @@ def drop_pipe(
|
|
637
647
|
return False, f"Failed to drop {pipe}."
|
638
648
|
|
639
649
|
if isinstance(data, list):
|
640
|
-
response_tuple =
|
650
|
+
response_tuple = data[0], data[1]
|
641
651
|
elif 'detail' in response.json():
|
642
652
|
response_tuple = response.__bool__(), data['detail']
|
643
653
|
else:
|
@@ -1664,7 +1664,7 @@ def sync_pipe(
|
|
1664
1664
|
|
1665
1665
|
if update_df is not None and len(update_df) > 0:
|
1666
1666
|
transact_id = generate_password(3)
|
1667
|
-
temp_prefix = '##' if self.flavor != 'oracle' else ''
|
1667
|
+
temp_prefix = '##' if self.flavor != 'oracle' else '_'
|
1668
1668
|
temp_target = temp_prefix + transact_id + '_' + pipe.target
|
1669
1669
|
self._log_temporary_tables_creation(temp_target, create=(not pipe.temporary), debug=debug)
|
1670
1670
|
temp_pipe = Pipe(
|
meerschaum/core/User/__init__.py
CHANGED
@@ -6,4 +6,34 @@
|
|
6
6
|
Manager users' metadata via the User class
|
7
7
|
"""
|
8
8
|
|
9
|
+
from typing import Optional
|
10
|
+
|
11
|
+
import meerschaum as mrsm
|
9
12
|
from meerschaum.core.User._User import User, hash_password, verify_password
|
13
|
+
|
14
|
+
|
15
|
+
def is_user_allowed_to_execute(user: Optional[User]) -> mrsm.SuccessTuple:
|
16
|
+
"""
|
17
|
+
Return a `SuccessTuple` indicating whether a given user is allowed to execute actions.
|
18
|
+
"""
|
19
|
+
if user is None:
|
20
|
+
return True, "Success"
|
21
|
+
|
22
|
+
if user.type == 'admin':
|
23
|
+
return True, "Success"
|
24
|
+
|
25
|
+
from meerschaum.config import get_config
|
26
|
+
|
27
|
+
allow_non_admin = get_config('system', 'api', 'permissions', 'actions', 'non_admin')
|
28
|
+
if not allow_non_admin:
|
29
|
+
return False, (
|
30
|
+
"The administrator for this server has not allowed users to perform actions.\n\n"
|
31
|
+
+ "Please contact the system administrator, or if you are running this server, "
|
32
|
+
+ "open the configuration file with `edit config system` "
|
33
|
+
+ "and search for 'permissions'. "
|
34
|
+
+ "\nUnder the keys 'api:permissions:actions', "
|
35
|
+
+ "you can allow non-admin users to perform actions."
|
36
|
+
)
|
37
|
+
|
38
|
+
return True, "Success"
|
39
|
+
|
@@ -501,11 +501,12 @@ def fill_ansi(string: str, style: str = '') -> str:
|
|
501
501
|
"""
|
502
502
|
from meerschaum.utils.packages import import_rich, attempt_import
|
503
503
|
from meerschaum.utils.misc import iterate_chunks
|
504
|
-
|
505
|
-
|
504
|
+
_ = import_rich()
|
505
|
+
rich_ansi, rich_text = attempt_import('rich.ansi', 'rich.text')
|
506
|
+
Text = rich_text.Text
|
506
507
|
try:
|
507
508
|
msg = Text.from_ansi(string)
|
508
|
-
except AttributeError
|
509
|
+
except AttributeError:
|
509
510
|
import traceback
|
510
511
|
traceback.print_stack()
|
511
512
|
msg = ''
|
@@ -118,10 +118,10 @@ meerschaum/api/resources/templates/old_index.html,sha256=BDeOlcXhSsBH3-NaRtuX4Z1
|
|
118
118
|
meerschaum/api/resources/templates/secret.html,sha256=0QWkm4ZoN81Aw1pd2-62rGCvx3nXPHfFUoegj3Iy8Ls,141
|
119
119
|
meerschaum/api/resources/templates/termpage.html,sha256=qspXRuOkzqOn2mXw9mmUldzsvOHq_LyaywQ29CUevp0,4527
|
120
120
|
meerschaum/api/routes/__init__.py,sha256=jbkeFNl51Tg8aT5gWe560ZLZLojFJsLMe5IENRjRkb0,606
|
121
|
-
meerschaum/api/routes/_actions.py,sha256
|
121
|
+
meerschaum/api/routes/_actions.py,sha256=-8ESo73_Fio94H5J5B7UfTlOFSoaoYqSkvPdzZO6amw,2243
|
122
122
|
meerschaum/api/routes/_connectors.py,sha256=NNbcn5xWhKqw2PqueSEaqRaZ95hFGDKazG5lE7gsssc,1849
|
123
123
|
meerschaum/api/routes/_index.py,sha256=QI6CBo6pI2Zi0a6fJHDjZfiLa9f4okb0BGe3A_JD0kM,578
|
124
|
-
meerschaum/api/routes/_jobs.py,sha256=
|
124
|
+
meerschaum/api/routes/_jobs.py,sha256=iPyxH7lckqCO1jSZxPKCIRealLkCNznZSv8NMquCHUY,12492
|
125
125
|
meerschaum/api/routes/_login.py,sha256=ti2onNOemOGLHLoPubAQOYtD7eq7FA1jOlbOSVSjXVo,2466
|
126
126
|
meerschaum/api/routes/_misc.py,sha256=05--9ZVFeaCgZrHER2kA3SYdK4TyfkEXOCjLvPbum-w,2469
|
127
127
|
meerschaum/api/routes/_pipes.py,sha256=li52WQUwZN8JEPyIuWN7s4wASWNV2BTVAUpQ_E1CKLg,21579
|
@@ -143,7 +143,7 @@ meerschaum/config/_preprocess.py,sha256=-AEA8m_--KivZwTQ1sWN6LTn5sio_fUr2XZ51BO6
|
|
143
143
|
meerschaum/config/_read_config.py,sha256=RLC3HHi_1ndj7ITVDKLD9_uULY3caGRwSz3ATYE-ixA,15014
|
144
144
|
meerschaum/config/_shell.py,sha256=46_m49Txc5q1rGfCgO49ca48BODx45DQJi8D0zz1R18,4245
|
145
145
|
meerschaum/config/_sync.py,sha256=jHcWRkxd82_BgX8Xo8agsWvf7BSbv3qHLWmYl6ehp_0,4242
|
146
|
-
meerschaum/config/_version.py,sha256=
|
146
|
+
meerschaum/config/_version.py,sha256=BZpL24-Hi0dYhLK6fctdzClZ2M2zhgZqTRSSVlRW8r0,72
|
147
147
|
meerschaum/config/paths.py,sha256=JjibeGN3YAdSNceRwsd42aNmeUrIgM6ndzC8qZAmNI0,621
|
148
148
|
meerschaum/config/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
149
149
|
meerschaum/config/stack/__init__.py,sha256=2UukC0Lmk-aVL1o1qXzumqmuIrw3vu9fD7iCuz4XD4I,10544
|
@@ -163,7 +163,7 @@ meerschaum/connectors/api/_fetch.py,sha256=Khq9AFr1nk8Dsmcedb77aWhAuHw0JGgVeahDG
|
|
163
163
|
meerschaum/connectors/api/_jobs.py,sha256=N5lpHFGG10jlVgaJeWAOTuLBQw3AdgjXsEPpp1YwZQE,11270
|
164
164
|
meerschaum/connectors/api/_login.py,sha256=5GsD-B214vr5EYfM3XrTUs1sTFApxZA-9dNxq8oNSyg,2050
|
165
165
|
meerschaum/connectors/api/_misc.py,sha256=OZRZBYOokKIEjmQaR8jUYgu6ZRn9VzXBChzR8CfDv_w,1092
|
166
|
-
meerschaum/connectors/api/_pipes.py,sha256=
|
166
|
+
meerschaum/connectors/api/_pipes.py,sha256=ceY-6wlmq73iPvYbvWz59xTUMkSoiiXCiz_BWjTZVMk,21443
|
167
167
|
meerschaum/connectors/api/_plugins.py,sha256=z04tPjfZZWwa7T60mogZH3X3wDmeLdnoN5Oh8m_YsU8,5217
|
168
168
|
meerschaum/connectors/api/_request.py,sha256=Wc4Y70t0VxEj3_ch5fAeeoSAeFMuRnyNLOV-aUFInjY,6996
|
169
169
|
meerschaum/connectors/api/_uri.py,sha256=HWxqGx4R1cHZ3ywy9Ro9ePbFxxusw4RLaC3hpGt9Z6I,1469
|
@@ -176,7 +176,7 @@ meerschaum/connectors/sql/_cli.py,sha256=1SgnWeMIAihoxp4FzbNrcq1npXf0dSOQnCntpU9
|
|
176
176
|
meerschaum/connectors/sql/_create_engine.py,sha256=zqeu1xHOw3n3Zgfjx-diy2aoynfdOlfOjwFuRrzB028,10452
|
177
177
|
meerschaum/connectors/sql/_fetch.py,sha256=A2R1aLgdEkiIet8P2BZ13OXy31I5e8BzWee74Bj_v4k,13141
|
178
178
|
meerschaum/connectors/sql/_instance.py,sha256=3KJI3ImwWAJkUfdZIrSL24pcW6Nic8wo5IUeGth9HP4,6459
|
179
|
-
meerschaum/connectors/sql/_pipes.py,sha256=
|
179
|
+
meerschaum/connectors/sql/_pipes.py,sha256=qfAgBT513vZUdBMbsS2O7XTQz-2S_pD02SsfTcfy9pw,117387
|
180
180
|
meerschaum/connectors/sql/_plugins.py,sha256=wbxcNxqTtjfDsxPvdVGTllasYf6NHHzODaQ72hEUSBQ,8135
|
181
181
|
meerschaum/connectors/sql/_sql.py,sha256=vdSslLKm8ftzIzfCs-0mL3q9zY2pmhZPTpzXSbKROag,37598
|
182
182
|
meerschaum/connectors/sql/_uri.py,sha256=0BrhQtqQdzg9mR04gWBZINs_BbPFtSlTECXT_TCUwik,3460
|
@@ -209,7 +209,7 @@ meerschaum/core/Pipe/_sync.py,sha256=E2egt63tqhVpB0ZteMO36HTF4EYEMtdevKOtN1aLd9o
|
|
209
209
|
meerschaum/core/Pipe/_verify.py,sha256=c3HvsZd4QPydqozaV6cDDRtwYiNz4V91b0IcnKvcimA,14158
|
210
210
|
meerschaum/core/Plugin/__init__.py,sha256=UXg64EvJPgI1PCxkY_KM02-ZmBm4FZpLPIQR_uSJJDc,137
|
211
211
|
meerschaum/core/User/_User.py,sha256=JZ9Y1tsjZe-cgD24m9YfZ6ZwSOKn_sHc4rbQ7KblBz8,6592
|
212
|
-
meerschaum/core/User/__init__.py,sha256=
|
212
|
+
meerschaum/core/User/__init__.py,sha256=JgfTpJc0BGBRPAxCq2679bIveszxy4LfLI-EgYve_E8,1204
|
213
213
|
meerschaum/jobs/_Executor.py,sha256=qM62BhFTM4tyJ7p90KOM0y3qyeRY9k3ZV_aTDJMHnO8,1682
|
214
214
|
meerschaum/jobs/_Job.py,sha256=hkjHqG5YPej5rC4nwdU7Ay_mjep9Fy4HO5B-eqdBdfo,31984
|
215
215
|
meerschaum/jobs/__init__.py,sha256=q0f_2zWw91sAyafP50IgMM06abe-BIYSR_SCWmI4W3E,12177
|
@@ -241,7 +241,7 @@ meerschaum/utils/daemon/__init__.py,sha256=o9jWb4lRTIyny4EPt7fPXFgV_vIf1mUofsTwo
|
|
241
241
|
meerschaum/utils/daemon/_names.py,sha256=d2ZwTxBoTAqXZkCfZ5LuX2XrkQmLNUq1OTlUqfoH5dA,4515
|
242
242
|
meerschaum/utils/dtypes/__init__.py,sha256=ZG1Ccy8QmTNuR0IP5NSMtgWj7Cseh_VU4wxSQDw2m94,8352
|
243
243
|
meerschaum/utils/dtypes/sql.py,sha256=IQihwQy4OKSbRjvJy6ky6SszFKR7W1iMs-ruZDsf2js,18701
|
244
|
-
meerschaum/utils/formatting/__init__.py,sha256=
|
244
|
+
meerschaum/utils/formatting/__init__.py,sha256=gN9UYYT68CQ-sQiqYaQyB64JUJkaaZ7pALDnTcaLUsY,16041
|
245
245
|
meerschaum/utils/formatting/_jobs.py,sha256=izsqPJhTtUkXUUtWnbXtReYsUYwulXtci3pBj72Ne64,6637
|
246
246
|
meerschaum/utils/formatting/_pipes.py,sha256=840O5rg2aHhQoraCDOh2ZtBo43_W2W6R60yYufEoXp8,19494
|
247
247
|
meerschaum/utils/formatting/_pprint.py,sha256=tgrT3FyGyu5CWJYysqK3kX1xdZYorlbOk9fcU_vt9Qg,3096
|
@@ -251,11 +251,11 @@ meerschaum/utils/packages/_packages.py,sha256=IFcQ4MzmTqjdWkqOsUa25xUNmG246TFqe2
|
|
251
251
|
meerschaum/utils/packages/lazy_loader.py,sha256=VHnph3VozH29R4JnSSBfwtA5WKZYZQFT_GeQSShCnuc,2540
|
252
252
|
meerschaum/utils/venv/_Venv.py,sha256=sBnlmxHdAh2bx8btfVoD79-H9-cYsv5lP02IIXkyECs,3553
|
253
253
|
meerschaum/utils/venv/__init__.py,sha256=f3oi67lXYPLKJrnRW9lae7M3A8SFiC7DzaMoBdCVUFs,24609
|
254
|
-
meerschaum-2.6.
|
255
|
-
meerschaum-2.6.
|
256
|
-
meerschaum-2.6.
|
257
|
-
meerschaum-2.6.
|
258
|
-
meerschaum-2.6.
|
259
|
-
meerschaum-2.6.
|
260
|
-
meerschaum-2.6.
|
261
|
-
meerschaum-2.6.
|
254
|
+
meerschaum-2.6.12.dist-info/LICENSE,sha256=jG2zQEdRNt88EgHUWPpXVWmOrOduUQRx7MnYV9YIPaw,11359
|
255
|
+
meerschaum-2.6.12.dist-info/METADATA,sha256=CHRO03ly42edn4c72djpC7gAWOG0yKfgnMl3j__f-BM,24758
|
256
|
+
meerschaum-2.6.12.dist-info/NOTICE,sha256=OTA9Fcthjf5BRvWDDIcBC_xfLpeDV-RPZh3M-HQBRtQ,114
|
257
|
+
meerschaum-2.6.12.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
258
|
+
meerschaum-2.6.12.dist-info/entry_points.txt,sha256=5YBVzibw-0rNA_1VjB16z5GABsOGf-CDhW4yqH8C7Gc,88
|
259
|
+
meerschaum-2.6.12.dist-info/top_level.txt,sha256=bNoSiDj0El6buocix-FRoAtJOeq1qOF5rRm2u9i7Q6A,11
|
260
|
+
meerschaum-2.6.12.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
261
|
+
meerschaum-2.6.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|