jaseci 1.4.0.9__py3-none-any.whl → 1.4.0.11__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 jaseci might be problematic. Click here for more details.
- jaseci/VERSION +1 -1
- jaseci/__init__.py +3 -0
- jaseci/actions/standard/elastic.py +3 -2
- jaseci/actions/standard/mail.py +3 -2
- jaseci/actions/standard/std.py +3 -2
- jaseci/actions/standard/stripe.py +3 -2
- jaseci/actions/standard/task.py +3 -5
- jaseci/actions/standard/tests/test_mail_lib.py +8 -7
- jaseci/actions/tests/test_std.py +4 -5
- jaseci/actor/walker.py +6 -3
- jaseci/api/config_api.py +3 -2
- jaseci/api/jac_api.py +2 -2
- jaseci/api/jsorc_api.py +60 -121
- jaseci/api/prometheus_api.py +14 -20
- jaseci/api/queue_api.py +9 -5
- jaseci/api/tests/test_global_api.py +3 -3
- jaseci/api/tests/test_logger_api.py +3 -3
- jaseci/api/user_api.py +3 -3
- jaseci/api/webhook_api.py +6 -4
- jaseci/attr/action.py +10 -4
- jaseci/element/master.py +2 -0
- jaseci/element/super_master.py +2 -0
- jaseci/hook/memory.py +3 -1
- jaseci/hook/redis.py +5 -4
- jaseci/jac/interpreter/interp.py +16 -4
- jaseci/jac/tests/test_book.py +2 -2
- jaseci/jsctl/jsctl.py +48 -15
- jaseci/jsctl/tests/test_jsctl.py +5 -0
- jaseci/jsorc.py +733 -0
- jaseci/jsorc_settings.py +184 -0
- jaseci/manifests/database.yaml +107 -0
- jaseci/manifests/elastic.yaml +5923 -0
- jaseci/manifests/prometheus.yaml +1273 -0
- jaseci/{svc/jsorc-backup/jaseci-redis.yaml → manifests/redis.yaml} +20 -0
- jaseci/svc/__init__.py +0 -25
- jaseci/svc/{elastic/elastic.py → elastic_svc.py} +5 -16
- jaseci/svc/kube_svc.py +240 -0
- jaseci/svc/{mail/mail.py → mail_svc.py} +14 -17
- jaseci/svc/{prometheus/prometheus.py → prome_svc.py} +5 -16
- jaseci/svc/{redis/redis.py → redis_svc.py} +14 -26
- jaseci/svc/{stripe/stripe.py → stripe_svc.py} +4 -7
- jaseci/svc/{task/task.py → task_svc.py} +27 -24
- jaseci/svc/{task/common.py → tasks.py} +287 -293
- jaseci/tests/jac_test_progs.py +21 -0
- jaseci/tests/test_core.py +14 -15
- jaseci/tests/test_jac.py +59 -60
- jaseci/tests/test_node.py +6 -13
- jaseci/tests/test_progs.py +74 -52
- jaseci/tests/test_stripe.py +6 -10
- jaseci/utils/actions/actions_manager.py +254 -0
- jaseci/{svc/actions_optimizer → utils/actions}/actions_optimizer.py +9 -19
- jaseci/utils/json_handler.py +2 -3
- jaseci/utils/test_core.py +4 -5
- jaseci/utils/utils.py +12 -0
- {jaseci-1.4.0.9.dist-info → jaseci-1.4.0.11.dist-info}/METADATA +2 -1
- {jaseci-1.4.0.9.dist-info → jaseci-1.4.0.11.dist-info}/RECORD +63 -80
- jaseci/svc/common.py +0 -763
- jaseci/svc/config.py +0 -9
- jaseci/svc/elastic/__init__.py +0 -3
- jaseci/svc/elastic/config.py +0 -8
- jaseci/svc/elastic/manifest.py +0 -1
- jaseci/svc/jsorc-backup/jsorc.py +0 -182
- jaseci/svc/jsorc-backup/promon/__init__.py +0 -0
- jaseci/svc/jsorc-backup/promon/promon.py +0 -202
- jaseci/svc/mail/__init__.py +0 -4
- jaseci/svc/mail/config.py +0 -25
- jaseci/svc/meta.py +0 -164
- jaseci/svc/postgres/__init__.py +0 -0
- jaseci/svc/postgres/manifest.py +0 -106
- jaseci/svc/prometheus/__init__.py +0 -5
- jaseci/svc/prometheus/config.py +0 -11
- jaseci/svc/prometheus/manifest.py +0 -1102
- jaseci/svc/redis/__init__.py +0 -5
- jaseci/svc/redis/config.py +0 -10
- jaseci/svc/redis/manifest.py +0 -65
- jaseci/svc/state.py +0 -17
- jaseci/svc/stripe/__init__.py +0 -3
- jaseci/svc/stripe/config.py +0 -7
- jaseci/svc/task/__init__.py +0 -5
- jaseci/svc/task/config.py +0 -17
- /jaseci/{svc/actions_optimizer → manifests}/__init__.py +0 -0
- /jaseci/{svc/jsorc-backup → utils/actions}/__init__.py +0 -0
- /jaseci/{svc/actions_optimizer → utils/actions}/actions_state.py +0 -0
- {jaseci-1.4.0.9.dist-info → jaseci-1.4.0.11.dist-info}/LICENSE +0 -0
- {jaseci-1.4.0.9.dist-info → jaseci-1.4.0.11.dist-info}/WHEEL +0 -0
- {jaseci-1.4.0.9.dist-info → jaseci-1.4.0.11.dist-info}/entry_points.txt +0 -0
- {jaseci-1.4.0.9.dist-info → jaseci-1.4.0.11.dist-info}/top_level.txt +0 -0
|
@@ -1,293 +1,287 @@
|
|
|
1
|
-
import re
|
|
2
|
-
from copy import deepcopy
|
|
3
|
-
from typing import Tuple
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
wlk =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return f"{DEFAULT_MSG}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if not
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
key
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
key
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
t
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
response =
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if "break" in req and self.and_condition(
|
|
289
|
-
(persistence, container["current"]), req["break"]
|
|
290
|
-
):
|
|
291
|
-
break
|
|
292
|
-
|
|
293
|
-
return persistence
|
|
1
|
+
import re
|
|
2
|
+
from copy import deepcopy
|
|
3
|
+
from typing import Tuple
|
|
4
|
+
|
|
5
|
+
from celery import Task
|
|
6
|
+
from requests import get, post
|
|
7
|
+
from requests.exceptions import HTTPError
|
|
8
|
+
from jaseci import JsOrc
|
|
9
|
+
|
|
10
|
+
DEFAULT_MSG = "Skipping scheduled walker!"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Queue(Task):
|
|
14
|
+
def run(self, wlk, nd, args):
|
|
15
|
+
hook = JsOrc.hook()
|
|
16
|
+
|
|
17
|
+
wlk = hook.get_obj_from_store(wlk)
|
|
18
|
+
wlk._to_await = True
|
|
19
|
+
|
|
20
|
+
nd = hook.get_obj_from_store(nd)
|
|
21
|
+
resp = wlk.run(nd, *args)
|
|
22
|
+
wlk.destroy()
|
|
23
|
+
|
|
24
|
+
return {"anchor": wlk.anchor_value(), "response": resp}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ScheduledWalker(Task):
|
|
28
|
+
def get_obj(self, jid):
|
|
29
|
+
return self.hook.get_obj_from_store(jid)
|
|
30
|
+
|
|
31
|
+
def run(self, name, ctx, nd=None, snt=None, mst=None):
|
|
32
|
+
self.hook = JsOrc.hook()
|
|
33
|
+
|
|
34
|
+
if mst:
|
|
35
|
+
mst = self.get_obj(mst)
|
|
36
|
+
else:
|
|
37
|
+
return f"{DEFAULT_MSG} mst (Master) is required!"
|
|
38
|
+
|
|
39
|
+
if mst is None:
|
|
40
|
+
return f"{DEFAULT_MSG} Invalid Master!"
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
if not snt:
|
|
44
|
+
if mst.active_snt_id == "global":
|
|
45
|
+
global_snt_id = self.hook.get_glob("GLOB_SENTINEL")
|
|
46
|
+
snt = self.get_obj(global_snt_id)
|
|
47
|
+
elif mst.active_snt_id:
|
|
48
|
+
snt = self.get_obj(mst.active_snt_id)
|
|
49
|
+
elif snt in mst.alias_map:
|
|
50
|
+
snt = self.get_obj(mst.alias_map[snt])
|
|
51
|
+
else:
|
|
52
|
+
snt = self.get_obj(snt)
|
|
53
|
+
|
|
54
|
+
if not snt:
|
|
55
|
+
return f"{DEFAULT_MSG} Invalid Sentinel!"
|
|
56
|
+
|
|
57
|
+
if not nd:
|
|
58
|
+
if mst.active_gph_id:
|
|
59
|
+
nd = self.get_obj(mst.active_gph_id)
|
|
60
|
+
elif nd in mst.alias_map:
|
|
61
|
+
nd = self.get_obj(mst.alias_map[nd])
|
|
62
|
+
else:
|
|
63
|
+
nd = self.get_obj(nd)
|
|
64
|
+
|
|
65
|
+
if not nd:
|
|
66
|
+
return f"{DEFAULT_MSG} Invalid Node!"
|
|
67
|
+
|
|
68
|
+
return mst.walker_run(name, nd, ctx, ctx, snt, False, False)
|
|
69
|
+
except Exception as e:
|
|
70
|
+
return f"{DEFAULT_MSG} Error occured: {e}"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class ScheduledSequence(Task):
|
|
74
|
+
json_escape = re.compile(r"[^a-zA-Z0-9_]")
|
|
75
|
+
internal = re.compile(r"\(([a-zA-Z0-9_\.\[\]\$\#\@\!]*?)\)")
|
|
76
|
+
full = re.compile(r"^\{\{([a-zA-Z0-9_\.\[\]\$\#\(\)\@\!]*?)\}\}$")
|
|
77
|
+
partial = re.compile(r"\{\{([a-zA-Z0-9_\.\[\]\$\#\(\)\@\!]*?)\}\}")
|
|
78
|
+
|
|
79
|
+
def get_deep_value(self, data, keys, default):
|
|
80
|
+
if len(keys) == 0:
|
|
81
|
+
return data
|
|
82
|
+
|
|
83
|
+
key = keys.pop(0)
|
|
84
|
+
t = type(data)
|
|
85
|
+
|
|
86
|
+
if t is dict and key in data:
|
|
87
|
+
return self.get_deep_value(data[key], keys, default)
|
|
88
|
+
elif t is list and key.isnumeric():
|
|
89
|
+
return self.get_deep_value(data[int(key)], keys, default)
|
|
90
|
+
else:
|
|
91
|
+
return default
|
|
92
|
+
|
|
93
|
+
def get_value(self, holder: Tuple, keys: str, default=None):
|
|
94
|
+
while self.internal.search(keys):
|
|
95
|
+
for intern in self.internal.findall(keys):
|
|
96
|
+
keys = keys.replace(
|
|
97
|
+
"(" + intern + ")", self.get_value(holder, intern, "")
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
if keys:
|
|
101
|
+
keys = keys.split(".")
|
|
102
|
+
key = keys.pop(0)
|
|
103
|
+
if key == "#":
|
|
104
|
+
return self.get_deep_value(holder[0], keys, default)
|
|
105
|
+
elif key == "$":
|
|
106
|
+
t = type(holder[1])
|
|
107
|
+
if t is dict or t is list:
|
|
108
|
+
return self.get_deep_value(holder[1], keys, default)
|
|
109
|
+
else:
|
|
110
|
+
return holder[1]
|
|
111
|
+
elif key == "@":
|
|
112
|
+
t = type(holder[2])
|
|
113
|
+
if t is dict or t is list:
|
|
114
|
+
return self.get_deep_value(holder[2], keys, default)
|
|
115
|
+
else:
|
|
116
|
+
return holder[2]
|
|
117
|
+
elif key == "!":
|
|
118
|
+
return holder[3]
|
|
119
|
+
return default
|
|
120
|
+
|
|
121
|
+
def compare(self, condition, expected, actual):
|
|
122
|
+
if condition == "eq":
|
|
123
|
+
return actual == expected
|
|
124
|
+
elif condition == "ne":
|
|
125
|
+
return actual != expected
|
|
126
|
+
elif condition == "gt":
|
|
127
|
+
return actual > expected
|
|
128
|
+
elif condition == "gte":
|
|
129
|
+
return actual >= expected
|
|
130
|
+
elif condition == "lt":
|
|
131
|
+
return actual < expected
|
|
132
|
+
elif condition == "lte":
|
|
133
|
+
return actual <= expected
|
|
134
|
+
elif condition == "regex":
|
|
135
|
+
return re.compile(expected).match(actual)
|
|
136
|
+
|
|
137
|
+
def condition(self, holder: Tuple, filter):
|
|
138
|
+
for cons in filter["condition"].keys():
|
|
139
|
+
if not (filter["condition"][cons] is None) and not self.compare(
|
|
140
|
+
cons, filter["condition"][cons], self.get_value(holder, filter["by"])
|
|
141
|
+
):
|
|
142
|
+
return False
|
|
143
|
+
return True
|
|
144
|
+
|
|
145
|
+
def or_condition(self, holder: Tuple, filter):
|
|
146
|
+
for filt in filter:
|
|
147
|
+
if "condition" in filt and self.condition(holder, filt):
|
|
148
|
+
return True
|
|
149
|
+
elif "or" in filt and self.or_condition(holder, filt["or"]):
|
|
150
|
+
return True
|
|
151
|
+
elif "and" in filt and self.and_condition(holder, filt["and"]):
|
|
152
|
+
return True
|
|
153
|
+
return False
|
|
154
|
+
|
|
155
|
+
def and_condition(self, holder: Tuple, filter):
|
|
156
|
+
for filt in filter:
|
|
157
|
+
if "condition" in filt and not self.condition(holder, filt):
|
|
158
|
+
return False
|
|
159
|
+
elif "or" in filt and not self.or_condition(holder, filt["or"]):
|
|
160
|
+
return False
|
|
161
|
+
elif "and" in filt and not self.and_condition(holder, filt["and"]):
|
|
162
|
+
return False
|
|
163
|
+
return True
|
|
164
|
+
|
|
165
|
+
def deep_replace_str(self, holder: Tuple, data, key):
|
|
166
|
+
matcher = self.full.match(data[key])
|
|
167
|
+
if matcher:
|
|
168
|
+
data[key] = self.get_value(holder, matcher.group(1))
|
|
169
|
+
else:
|
|
170
|
+
for rep in self.partial.findall(data[key]):
|
|
171
|
+
data[key] = data[key].replace(
|
|
172
|
+
"{{" + rep + "}}", self.get_value(holder, rep, "")
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
def deep_replace_dict(self, holder: Tuple, data):
|
|
176
|
+
for key in data.keys():
|
|
177
|
+
if key != "__def_loop__":
|
|
178
|
+
t = type(data[key])
|
|
179
|
+
if t is str:
|
|
180
|
+
self.deep_replace_str(holder, data, key)
|
|
181
|
+
elif t is dict:
|
|
182
|
+
self.deep_replace_dict(holder, data[key])
|
|
183
|
+
|
|
184
|
+
def save(self, holder: Tuple, req, params):
|
|
185
|
+
if params in req:
|
|
186
|
+
holder[0][self.json_escape.sub("_", req[params])] = holder[1]
|
|
187
|
+
|
|
188
|
+
def trigger_interface(self, req: dict):
|
|
189
|
+
master = req.get("master")
|
|
190
|
+
if master is None:
|
|
191
|
+
caller = JsOrc.master()
|
|
192
|
+
trigger_type = "public"
|
|
193
|
+
else:
|
|
194
|
+
caller = JsOrc.hook().get_obj_from_store(master)
|
|
195
|
+
trigger_type = "general"
|
|
196
|
+
|
|
197
|
+
api = req.get("api")
|
|
198
|
+
body = req.get("body", {})
|
|
199
|
+
|
|
200
|
+
return getattr(caller, f"{trigger_type}_interface_to_api")(body, api)
|
|
201
|
+
|
|
202
|
+
def run(self, *args, **kwargs):
|
|
203
|
+
requests = kwargs.get("requests")
|
|
204
|
+
persistence = kwargs.get("persistence", {})
|
|
205
|
+
container = kwargs.get("container", {"current": persistence})
|
|
206
|
+
index = container.get("index", "0")
|
|
207
|
+
|
|
208
|
+
if "parent_current" in container:
|
|
209
|
+
container["current"] = container["parent_current"]
|
|
210
|
+
|
|
211
|
+
for req in requests:
|
|
212
|
+
try:
|
|
213
|
+
self.deep_replace_dict(
|
|
214
|
+
(
|
|
215
|
+
persistence,
|
|
216
|
+
container["current"],
|
|
217
|
+
container.get("parent_current", {}),
|
|
218
|
+
index,
|
|
219
|
+
),
|
|
220
|
+
req,
|
|
221
|
+
)
|
|
222
|
+
self.save((persistence, req), req, "save_req_to")
|
|
223
|
+
|
|
224
|
+
method = req["method"].upper()
|
|
225
|
+
|
|
226
|
+
if method == "JAC":
|
|
227
|
+
container["current"] = self.trigger_interface(req)
|
|
228
|
+
else:
|
|
229
|
+
if method == "POST":
|
|
230
|
+
response = post(
|
|
231
|
+
req["api"],
|
|
232
|
+
json=req.get("body", {}),
|
|
233
|
+
headers=req.get("header", {}),
|
|
234
|
+
)
|
|
235
|
+
elif method == "GET":
|
|
236
|
+
response = get(req["api"], headers=req.get("header", {}))
|
|
237
|
+
response.raise_for_status()
|
|
238
|
+
if "application/json" in response.headers.get("Content-Type"):
|
|
239
|
+
container["current"] = response.json()
|
|
240
|
+
else:
|
|
241
|
+
container["current"] = response.text
|
|
242
|
+
|
|
243
|
+
if "__def_loop__" in req:
|
|
244
|
+
def_loop = req["__def_loop__"]
|
|
245
|
+
for idx, loop in enumerate(
|
|
246
|
+
self.get_value(
|
|
247
|
+
(persistence, container["current"]), def_loop["by"], []
|
|
248
|
+
)
|
|
249
|
+
):
|
|
250
|
+
if "filter" in def_loop and not self.and_condition(
|
|
251
|
+
(persistence, loop), def_loop["filter"]
|
|
252
|
+
):
|
|
253
|
+
continue
|
|
254
|
+
loop_container = {"parent_current": loop, "index": str(idx)}
|
|
255
|
+
self.run(
|
|
256
|
+
requests=deepcopy(def_loop["requests"]),
|
|
257
|
+
persistence=persistence,
|
|
258
|
+
container=loop_container,
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
self.save((persistence, container["current"]), req, "save_to")
|
|
262
|
+
|
|
263
|
+
except Exception as err:
|
|
264
|
+
container["current"] = (
|
|
265
|
+
{
|
|
266
|
+
"status": err.response.status_code,
|
|
267
|
+
"message": err.response.reason,
|
|
268
|
+
}
|
|
269
|
+
if isinstance(err, HTTPError)
|
|
270
|
+
else {
|
|
271
|
+
"worker_error": str(err),
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
self.save((persistence, container["current"]), req, "save_to")
|
|
276
|
+
|
|
277
|
+
if "ignore_error" not in req or not req["ignore_error"]:
|
|
278
|
+
if "parent_current" in container:
|
|
279
|
+
raise err
|
|
280
|
+
break
|
|
281
|
+
|
|
282
|
+
if "break" in req and self.and_condition(
|
|
283
|
+
(persistence, container["current"]), req["break"]
|
|
284
|
+
):
|
|
285
|
+
break
|
|
286
|
+
|
|
287
|
+
return persistence
|
jaseci/tests/jac_test_progs.py
CHANGED
|
@@ -557,6 +557,26 @@ check_dict_for_in_loop = """
|
|
|
557
557
|
}
|
|
558
558
|
"""
|
|
559
559
|
|
|
560
|
+
list_pairwise = """
|
|
561
|
+
walker init{
|
|
562
|
+
with entry{
|
|
563
|
+
_list = [1,2,3,4];
|
|
564
|
+
p = _list.list::pairwise;
|
|
565
|
+
report p;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
"""
|
|
569
|
+
|
|
570
|
+
list_unique = """
|
|
571
|
+
walker init{
|
|
572
|
+
with entry{
|
|
573
|
+
_list = [1,2,3,4,2,3,4,5];
|
|
574
|
+
p = _list.list::unique;
|
|
575
|
+
report p;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
"""
|
|
579
|
+
|
|
560
580
|
check_new_builtin = """
|
|
561
581
|
walker init {
|
|
562
582
|
with entry {
|
|
@@ -578,6 +598,7 @@ check_new_builtin = """
|
|
|
578
598
|
}
|
|
579
599
|
"""
|
|
580
600
|
|
|
601
|
+
|
|
581
602
|
continue_issue = """
|
|
582
603
|
walker init {
|
|
583
604
|
root {
|