synapse 2.173.1__py311-none-any.whl → 2.175.0__py311-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 synapse might be problematic. Click here for more details.
- synapse/axon.py +1 -1
- synapse/common.py +19 -5
- synapse/cortex.py +46 -10
- synapse/daemon.py +11 -12
- synapse/lib/agenda.py +6 -0
- synapse/lib/ast.py +5 -1
- synapse/lib/cell.py +22 -13
- synapse/lib/jupyter.py +21 -0
- synapse/lib/layer.py +124 -30
- synapse/lib/link.py +3 -2
- synapse/lib/lmdbslab.py +11 -1
- synapse/lib/modelrev.py +31 -1
- synapse/lib/modules.py +1 -0
- synapse/lib/msgpack.py +25 -3
- synapse/lib/nexus.py +26 -22
- synapse/lib/schemas.py +31 -0
- synapse/lib/snap.py +13 -0
- synapse/lib/storm.py +103 -86
- synapse/lib/stormsvc.py +30 -11
- synapse/lib/stormtypes.py +23 -9
- synapse/lib/trigger.py +0 -4
- synapse/lib/types.py +1 -1
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +2 -0
- synapse/models/crypto.py +22 -0
- synapse/models/economic.py +23 -2
- synapse/models/entity.py +16 -0
- synapse/models/files.py +4 -1
- synapse/models/geopol.py +3 -0
- synapse/models/orgs.py +3 -4
- synapse/tests/test_cortex.py +13 -0
- synapse/tests/test_daemon.py +36 -0
- synapse/tests/test_lib_agenda.py +129 -1
- synapse/tests/test_lib_ast.py +56 -0
- synapse/tests/test_lib_cell.py +11 -0
- synapse/tests/test_lib_grammar.py +4 -0
- synapse/tests/test_lib_httpapi.py +1 -0
- synapse/tests/test_lib_lmdbslab.py +16 -1
- synapse/tests/test_lib_modelrev.py +86 -0
- synapse/tests/test_lib_msgpack.py +58 -8
- synapse/tests/test_lib_nexus.py +44 -1
- synapse/tests/test_lib_storm.py +134 -18
- synapse/tests/test_lib_stormsvc.py +128 -51
- synapse/tests/test_lib_stormtypes.py +43 -4
- synapse/tests/test_lib_trigger.py +23 -4
- synapse/tests/test_model_crypto.py +6 -0
- synapse/tests/test_model_economic.py +14 -1
- synapse/tests/test_model_geopol.py +3 -0
- synapse/tools/changelog.py +256 -0
- {synapse-2.173.1.dist-info → synapse-2.175.0.dist-info}/METADATA +1 -1
- {synapse-2.173.1.dist-info → synapse-2.175.0.dist-info}/RECORD +54 -52
- {synapse-2.173.1.dist-info → synapse-2.175.0.dist-info}/WHEEL +1 -1
- {synapse-2.173.1.dist-info → synapse-2.175.0.dist-info}/LICENSE +0 -0
- {synapse-2.173.1.dist-info → synapse-2.175.0.dist-info}/top_level.txt +0 -0
synapse/axon.py
CHANGED
|
@@ -493,7 +493,7 @@ class AxonApi(s_cell.CellApi, s_share.Share): # type: ignore
|
|
|
493
493
|
|
|
494
494
|
async def wants(self, sha256s):
|
|
495
495
|
'''
|
|
496
|
-
Get a list of sha256 values the axon does not have from
|
|
496
|
+
Get a list of sha256 values the axon does not have from an input list.
|
|
497
497
|
|
|
498
498
|
Args:
|
|
499
499
|
sha256s (list): A list of sha256 values as bytes.
|
synapse/common.py
CHANGED
|
@@ -11,6 +11,7 @@ import types
|
|
|
11
11
|
import base64
|
|
12
12
|
import shutil
|
|
13
13
|
import struct
|
|
14
|
+
import typing
|
|
14
15
|
import asyncio
|
|
15
16
|
import decimal
|
|
16
17
|
import fnmatch
|
|
@@ -379,7 +380,7 @@ def reqbytes(*paths):
|
|
|
379
380
|
with reqfile(*paths) as fd:
|
|
380
381
|
return fd.read()
|
|
381
382
|
|
|
382
|
-
def genfile(*paths):
|
|
383
|
+
def genfile(*paths) -> typing.BinaryIO:
|
|
383
384
|
'''
|
|
384
385
|
Create or open (for read/write) a file path join.
|
|
385
386
|
|
|
@@ -396,7 +397,7 @@ def genfile(*paths):
|
|
|
396
397
|
to append.
|
|
397
398
|
|
|
398
399
|
Returns:
|
|
399
|
-
|
|
400
|
+
A file-object which can be read/written too.
|
|
400
401
|
'''
|
|
401
402
|
path = genpath(*paths)
|
|
402
403
|
gendir(os.path.dirname(path))
|
|
@@ -535,13 +536,26 @@ def yamlload(*paths):
|
|
|
535
536
|
with io.open(path, 'rb') as fd:
|
|
536
537
|
return yamlloads(fd)
|
|
537
538
|
|
|
539
|
+
def yamldump(obj, stream: typing.Optional[typing.BinaryIO] =None) -> bytes:
|
|
540
|
+
'''
|
|
541
|
+
Dump a object to yaml.
|
|
542
|
+
|
|
543
|
+
Args:
|
|
544
|
+
obj: The object to serialize.
|
|
545
|
+
stream: The optional stream to write the stream too.
|
|
546
|
+
|
|
547
|
+
Returns:
|
|
548
|
+
The raw yaml bytes if stream is not provided.
|
|
549
|
+
'''
|
|
550
|
+
return yaml.dump(obj, allow_unicode=True, default_flow_style=False,
|
|
551
|
+
default_style='', explicit_start=True, explicit_end=True,
|
|
552
|
+
encoding='utf8', stream=stream, Dumper=Dumper)
|
|
553
|
+
|
|
538
554
|
def yamlsave(obj, *paths):
|
|
539
555
|
path = genpath(*paths)
|
|
540
556
|
with genfile(path) as fd:
|
|
541
557
|
fd.truncate(0)
|
|
542
|
-
|
|
543
|
-
default_style='', explicit_start=True, explicit_end=True,
|
|
544
|
-
encoding='utf8', stream=fd, Dumper=Dumper)
|
|
558
|
+
yamldump(obj, stream=fd)
|
|
545
559
|
|
|
546
560
|
def yamlmod(obj, *paths):
|
|
547
561
|
'''
|
synapse/cortex.py
CHANGED
|
@@ -42,6 +42,7 @@ import synapse.lib.schemas as s_schemas
|
|
|
42
42
|
import synapse.lib.spooled as s_spooled
|
|
43
43
|
import synapse.lib.version as s_version
|
|
44
44
|
import synapse.lib.urlhelp as s_urlhelp
|
|
45
|
+
import synapse.lib.hashitem as s_hashitem
|
|
45
46
|
import synapse.lib.jsonstor as s_jsonstor
|
|
46
47
|
import synapse.lib.modelrev as s_modelrev
|
|
47
48
|
import synapse.lib.stormsvc as s_stormsvc
|
|
@@ -949,6 +950,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
949
950
|
|
|
950
951
|
# Initialize our storage and views
|
|
951
952
|
await self._initCoreAxon()
|
|
953
|
+
await self._initJsonStor()
|
|
952
954
|
|
|
953
955
|
await self._initCoreLayers()
|
|
954
956
|
await self._initCoreViews()
|
|
@@ -1009,8 +1011,16 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
1009
1011
|
await self._bumpCellVers('cortex:storage', (
|
|
1010
1012
|
(1, self._storUpdateMacros),
|
|
1011
1013
|
(2, self._storLayrFeedDefaults),
|
|
1014
|
+
(3, self._updateTriggerViewIdens),
|
|
1012
1015
|
), nexs=False)
|
|
1013
1016
|
|
|
1017
|
+
async def _updateTriggerViewIdens(self):
|
|
1018
|
+
for view in self.views.values():
|
|
1019
|
+
for trigiden, trigger in await view.listTriggers():
|
|
1020
|
+
if trigger.get('view') != view.iden:
|
|
1021
|
+
trigger.tdef['view'] = view.iden
|
|
1022
|
+
await view.trigdict.set(trigiden, trigger.tdef)
|
|
1023
|
+
|
|
1014
1024
|
async def _viewNomergeToProtected(self):
|
|
1015
1025
|
for view in self.views.values():
|
|
1016
1026
|
nomerge = view.info.get('nomerge', False)
|
|
@@ -1462,8 +1472,6 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
1462
1472
|
async def initServiceRuntime(self):
|
|
1463
1473
|
|
|
1464
1474
|
# do any post-nexus initialization here...
|
|
1465
|
-
await self._initJsonStor()
|
|
1466
|
-
|
|
1467
1475
|
if self.isactive:
|
|
1468
1476
|
await self._checkNexsIndx()
|
|
1469
1477
|
|
|
@@ -2550,7 +2558,10 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
2550
2558
|
name = pkgdef.get('name')
|
|
2551
2559
|
olddef = self.pkghive.get(name, None)
|
|
2552
2560
|
if olddef is not None:
|
|
2553
|
-
|
|
2561
|
+
if s_hashitem.hashitem(pkgdef) != s_hashitem.hashitem(olddef):
|
|
2562
|
+
await self._dropStormPkg(olddef)
|
|
2563
|
+
else:
|
|
2564
|
+
return
|
|
2554
2565
|
|
|
2555
2566
|
await self.loadStormPkg(pkgdef)
|
|
2556
2567
|
await self.pkghive.set(name, pkgdef)
|
|
@@ -2965,17 +2976,19 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
2965
2976
|
'''
|
|
2966
2977
|
Delete storm packages associated with a service.
|
|
2967
2978
|
'''
|
|
2968
|
-
|
|
2969
|
-
for _, pdef in self.pkghive.items():
|
|
2970
|
-
pkgiden = pdef.get('svciden')
|
|
2971
|
-
if pkgiden and pkgiden == iden:
|
|
2972
|
-
oldpkgs.append(pdef)
|
|
2973
|
-
|
|
2974
|
-
for pkg in oldpkgs:
|
|
2979
|
+
for pkg in self.getStormSvcPkgs(iden):
|
|
2975
2980
|
name = pkg.get('name')
|
|
2976
2981
|
if name:
|
|
2977
2982
|
await self._delStormPkg(name)
|
|
2978
2983
|
|
|
2984
|
+
def getStormSvcPkgs(self, iden):
|
|
2985
|
+
pkgs = []
|
|
2986
|
+
for _, pdef in self.pkghive.items():
|
|
2987
|
+
pkgiden = pdef.get('svciden')
|
|
2988
|
+
if pkgiden and pkgiden == iden:
|
|
2989
|
+
pkgs.append(pdef)
|
|
2990
|
+
return pkgs
|
|
2991
|
+
|
|
2979
2992
|
async def setStormSvcEvents(self, iden, edef):
|
|
2980
2993
|
'''
|
|
2981
2994
|
Set the event callbacks for a storm service. Extends the sdef dict.
|
|
@@ -6113,6 +6126,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
6113
6126
|
Args:
|
|
6114
6127
|
iden (bytes): The iden of the cron job to be deleted
|
|
6115
6128
|
'''
|
|
6129
|
+
await self._killCronTask(iden)
|
|
6116
6130
|
try:
|
|
6117
6131
|
await self.agenda.delete(iden)
|
|
6118
6132
|
except s_exc.NoSuchIden:
|
|
@@ -6142,6 +6156,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
6142
6156
|
'''
|
|
6143
6157
|
await self.agenda.enable(iden)
|
|
6144
6158
|
await self.feedBeholder('cron:enable', {'iden': iden}, gates=[iden])
|
|
6159
|
+
logger.info(f'Enabled cron job {iden}', extra=await self.getLogExtra(iden=iden, status='MODIFY'))
|
|
6145
6160
|
|
|
6146
6161
|
@s_nexus.Pusher.onPushAuto('cron:disable')
|
|
6147
6162
|
async def disableCronJob(self, iden):
|
|
@@ -6152,7 +6167,28 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
6152
6167
|
iden (bytes): The iden of the cron job to be changed
|
|
6153
6168
|
'''
|
|
6154
6169
|
await self.agenda.disable(iden)
|
|
6170
|
+
await self._killCronTask(iden)
|
|
6155
6171
|
await self.feedBeholder('cron:disable', {'iden': iden}, gates=[iden])
|
|
6172
|
+
logger.info(f'Disabled cron job {iden}', extra=await self.getLogExtra(iden=iden, status='MODIFY'))
|
|
6173
|
+
|
|
6174
|
+
async def killCronTask(self, iden):
|
|
6175
|
+
if self.agenda.appts.get(iden) is None:
|
|
6176
|
+
return False
|
|
6177
|
+
return await self._push('cron:task:kill', iden)
|
|
6178
|
+
|
|
6179
|
+
@s_nexus.Pusher.onPush('cron:task:kill')
|
|
6180
|
+
async def _killCronTask(self, iden):
|
|
6181
|
+
|
|
6182
|
+
appt = self.agenda.appts.get(iden)
|
|
6183
|
+
if appt is None:
|
|
6184
|
+
return False
|
|
6185
|
+
|
|
6186
|
+
task = appt.task
|
|
6187
|
+
if task is None:
|
|
6188
|
+
return False
|
|
6189
|
+
|
|
6190
|
+
self.schedCoro(task.kill())
|
|
6191
|
+
return True
|
|
6156
6192
|
|
|
6157
6193
|
async def listCronJobs(self):
|
|
6158
6194
|
'''
|
synapse/daemon.py
CHANGED
|
@@ -178,7 +178,7 @@ async def t2call(link, meth, args, kwargs):
|
|
|
178
178
|
if isinstance(e, asyncio.CancelledError):
|
|
179
179
|
logger.info('t2call task %s cancelled', meth.__name__)
|
|
180
180
|
else:
|
|
181
|
-
logger.exception('error during task
|
|
181
|
+
logger.exception(f'error during task {meth.__name__} {e}')
|
|
182
182
|
|
|
183
183
|
if isinstance(valu, types.AsyncGeneratorType):
|
|
184
184
|
await valu.aclose()
|
|
@@ -211,7 +211,7 @@ async def t2call(link, meth, args, kwargs):
|
|
|
211
211
|
return
|
|
212
212
|
|
|
213
213
|
except (asyncio.CancelledError, Exception) as e:
|
|
214
|
-
logger.exception('error during task:
|
|
214
|
+
logger.exception(f'error during task: {meth.__name__} {e}')
|
|
215
215
|
if not link.isfini:
|
|
216
216
|
retn = s_common.retnexc(e)
|
|
217
217
|
await link.tx(('t2:fini', {'retn': retn}))
|
|
@@ -380,24 +380,23 @@ class Daemon(s_base.Base):
|
|
|
380
380
|
|
|
381
381
|
link.schedCoro(rxloop())
|
|
382
382
|
|
|
383
|
-
async def _onLinkMesg(self, link, mesg):
|
|
383
|
+
async def _onLinkMesg(self, link: s_link.Link, mesg):
|
|
384
384
|
|
|
385
385
|
try:
|
|
386
386
|
func = self.mesgfuncs.get(mesg[0])
|
|
387
387
|
if func is None:
|
|
388
|
-
logger.
|
|
388
|
+
logger.error(f'Dmon.onLinkMesg Invalid mesg: mesg={s_common.trimText(repr(mesg), n=80)} '
|
|
389
|
+
f'link={link.getAddrInfo()}')
|
|
389
390
|
return
|
|
390
391
|
|
|
391
392
|
await func(link, mesg)
|
|
392
393
|
|
|
393
|
-
except asyncio.CancelledError: # pragma: no cover # TODO: remove once >= py 3.8 only
|
|
394
|
-
raise
|
|
395
|
-
|
|
396
394
|
except ConnectionResetError:
|
|
397
|
-
logger.debug('Dmon.onLinkMesg Handler: connection reset')
|
|
395
|
+
logger.debug(f'Dmon.onLinkMesg Handler: connection reset link={link.getAddrInfo()}')
|
|
398
396
|
|
|
399
397
|
except Exception:
|
|
400
|
-
logger.exception('Dmon.onLinkMesg Handler:
|
|
398
|
+
logger.exception(f'Dmon.onLinkMesg Handler: mesg={s_common.trimText(repr(mesg), n=80)} '
|
|
399
|
+
f'link={link.getAddrInfo()}')
|
|
401
400
|
|
|
402
401
|
async def _onShareFini(self, link, mesg):
|
|
403
402
|
|
|
@@ -473,7 +472,7 @@ class Daemon(s_base.Base):
|
|
|
473
472
|
reply[1]['sess'] = sess.iden
|
|
474
473
|
|
|
475
474
|
except Exception as e:
|
|
476
|
-
logger.exception('tele:syn error')
|
|
475
|
+
logger.exception(f'tele:syn error: {e} link={link.getAddrInfo()}')
|
|
477
476
|
reply[1]['retn'] = s_common.retnexc(e)
|
|
478
477
|
|
|
479
478
|
await link.tx(reply)
|
|
@@ -501,7 +500,7 @@ class Daemon(s_base.Base):
|
|
|
501
500
|
typename = valu.typename
|
|
502
501
|
return ('task:fini', {'task': task, 'retn': retn, 'type': typename})
|
|
503
502
|
|
|
504
|
-
async def _onTaskV2Init(self, link, mesg):
|
|
503
|
+
async def _onTaskV2Init(self, link: s_link.Link, mesg):
|
|
505
504
|
|
|
506
505
|
# t2:init is used by the pool sockets on the client
|
|
507
506
|
name = mesg[1].get('name')
|
|
@@ -539,7 +538,7 @@ class Daemon(s_base.Base):
|
|
|
539
538
|
sess.onfini(sessitem)
|
|
540
539
|
|
|
541
540
|
except (asyncio.CancelledError, Exception) as e:
|
|
542
|
-
logger.exception('on t2:init:
|
|
541
|
+
logger.exception(f'Error on t2:init: {s_common.trimText(repr(mesg), n=80)} link={link.getAddrInfo()}')
|
|
543
542
|
if not link.isfini:
|
|
544
543
|
retn = s_common.retnexc(e)
|
|
545
544
|
await link.tx(('t2:fini', {'retn': retn}))
|
synapse/lib/agenda.py
CHANGED
|
@@ -274,6 +274,7 @@ class _Appt:
|
|
|
274
274
|
def __init__(self, stor, iden, recur, indx, query, creator, recs, nexttime=None, view=None, created=None, pool=False):
|
|
275
275
|
self.doc = ''
|
|
276
276
|
self.name = ''
|
|
277
|
+
self.task = None
|
|
277
278
|
self.stor = stor
|
|
278
279
|
self.pool = pool
|
|
279
280
|
self.iden = iden
|
|
@@ -801,7 +802,12 @@ class Agenda(s_base.Base):
|
|
|
801
802
|
|
|
802
803
|
coro = self._runJob(user, appt)
|
|
803
804
|
task = self.core.runActiveTask(coro)
|
|
805
|
+
|
|
804
806
|
appt.task = await self.core.boss.promotetask(task, f'Cron {appt.iden}', user, info=info)
|
|
807
|
+
async def fini():
|
|
808
|
+
appt.task = None
|
|
809
|
+
|
|
810
|
+
appt.task.onfini(fini)
|
|
805
811
|
|
|
806
812
|
async def _markfailed(self, appt, reason):
|
|
807
813
|
now = self._getNowTick()
|
synapse/lib/ast.py
CHANGED
|
@@ -2097,6 +2097,10 @@ class PivotIn(PivotOper):
|
|
|
2097
2097
|
async for pivo in runt.snap.nodesByPropArray(prop.full, '=', valu):
|
|
2098
2098
|
yield pivo, path.fork(pivo)
|
|
2099
2099
|
|
|
2100
|
+
async for refsbuid in runt.snap.getNdefRefs(node.buid):
|
|
2101
|
+
pivo = await runt.snap.getNodeByBuid(refsbuid)
|
|
2102
|
+
yield pivo, path.fork(pivo)
|
|
2103
|
+
|
|
2100
2104
|
class N2WalkNPivo(PivotIn):
|
|
2101
2105
|
|
|
2102
2106
|
async def run(self, runt, genr):
|
|
@@ -3017,11 +3021,11 @@ class ArrayCond(Cond):
|
|
|
3017
3021
|
|
|
3018
3022
|
async def getCondEval(self, runt):
|
|
3019
3023
|
|
|
3020
|
-
name = await self.kids[0].compute(runt, None)
|
|
3021
3024
|
cmpr = await self.kids[1].compute(runt, None)
|
|
3022
3025
|
|
|
3023
3026
|
async def cond(node, path):
|
|
3024
3027
|
|
|
3028
|
+
name = await self.kids[0].compute(runt, None)
|
|
3025
3029
|
prop = node.form.props.get(name)
|
|
3026
3030
|
if prop is None:
|
|
3027
3031
|
raise self.kids[0].addExcInfo(s_exc.NoSuchProp.init(name))
|
synapse/lib/cell.py
CHANGED
|
@@ -1100,6 +1100,7 @@ class Cell(s_nexus.Pusher, s_telepath.Aware):
|
|
|
1100
1100
|
self.inaugural = False
|
|
1101
1101
|
self.activecoros = {}
|
|
1102
1102
|
self.sockaddr = None # Default value...
|
|
1103
|
+
self.https_listeners = []
|
|
1103
1104
|
self.ahaclient = None
|
|
1104
1105
|
self._checkspace = s_coro.Event()
|
|
1105
1106
|
self._reloadfuncs = {} # name -> func
|
|
@@ -2822,6 +2823,8 @@ class Cell(s_nexus.Pusher, s_telepath.Aware):
|
|
|
2822
2823
|
|
|
2823
2824
|
self.addReloadableSystem('https:certs', reload)
|
|
2824
2825
|
|
|
2826
|
+
self.https_listeners.append({'host': lhost, 'port': lport})
|
|
2827
|
+
|
|
2825
2828
|
return (lhost, lport)
|
|
2826
2829
|
|
|
2827
2830
|
def initSslCtx(self, certpath, keypath):
|
|
@@ -2877,18 +2880,7 @@ class Cell(s_nexus.Pusher, s_telepath.Aware):
|
|
|
2877
2880
|
|
|
2878
2881
|
log_method(mesg, extra=extra)
|
|
2879
2882
|
|
|
2880
|
-
async def
|
|
2881
|
-
|
|
2882
|
-
self.httpds = []
|
|
2883
|
-
self.sessstor = s_lmdbslab.GuidStor(self.slab, 'http:sess')
|
|
2884
|
-
|
|
2885
|
-
async def fini():
|
|
2886
|
-
[await s.fini() for s in self.sessions.values()]
|
|
2887
|
-
for http in self.httpds:
|
|
2888
|
-
http.stop()
|
|
2889
|
-
|
|
2890
|
-
self.onfini(fini)
|
|
2891
|
-
|
|
2883
|
+
async def _getCellHttpOpts(self):
|
|
2892
2884
|
# Generate/Load a Cookie Secret
|
|
2893
2885
|
secpath = os.path.join(self.dirn, 'cookie.secret')
|
|
2894
2886
|
if not os.path.isfile(secpath):
|
|
@@ -2898,12 +2890,26 @@ class Cell(s_nexus.Pusher, s_telepath.Aware):
|
|
|
2898
2890
|
with s_common.getfile(secpath) as fd:
|
|
2899
2891
|
secret = fd.read().decode('utf8')
|
|
2900
2892
|
|
|
2901
|
-
|
|
2893
|
+
return {
|
|
2902
2894
|
'cookie_secret': secret,
|
|
2903
2895
|
'log_function': self._log_web_request,
|
|
2904
2896
|
'websocket_ping_interval': 10
|
|
2905
2897
|
}
|
|
2906
2898
|
|
|
2899
|
+
async def _initCellHttp(self):
|
|
2900
|
+
|
|
2901
|
+
self.httpds = []
|
|
2902
|
+
self.sessstor = s_lmdbslab.GuidStor(self.slab, 'http:sess')
|
|
2903
|
+
|
|
2904
|
+
async def fini():
|
|
2905
|
+
[await s.fini() for s in self.sessions.values()]
|
|
2906
|
+
for http in self.httpds:
|
|
2907
|
+
http.stop()
|
|
2908
|
+
|
|
2909
|
+
self.onfini(fini)
|
|
2910
|
+
|
|
2911
|
+
opts = await self._getCellHttpOpts()
|
|
2912
|
+
|
|
2907
2913
|
self.wapp = t_web.Application(**opts)
|
|
2908
2914
|
self._initCellHttpApis()
|
|
2909
2915
|
|
|
@@ -4070,6 +4076,9 @@ class Cell(s_nexus.Pusher, s_telepath.Aware):
|
|
|
4070
4076
|
'name': self.conf.get('aha:name'),
|
|
4071
4077
|
'leader': self.conf.get('aha:leader'),
|
|
4072
4078
|
'network': self.conf.get('aha:network'),
|
|
4079
|
+
},
|
|
4080
|
+
'network': {
|
|
4081
|
+
'https': self.https_listeners,
|
|
4073
4082
|
}
|
|
4074
4083
|
},
|
|
4075
4084
|
'features': {
|
synapse/lib/jupyter.py
CHANGED
|
@@ -38,6 +38,7 @@ def getDocPath(fn, root=None):
|
|
|
38
38
|
Raises:
|
|
39
39
|
ValueError if the file does not exist or directory traversal attempted..
|
|
40
40
|
'''
|
|
41
|
+
s_common.deprdate('synapse.lib.jupyter.getDocPath', '2024-08-26')
|
|
41
42
|
cwd = pathlib.Path(os.getcwd())
|
|
42
43
|
if root:
|
|
43
44
|
cwd = pathlib.Path(root)
|
|
@@ -84,6 +85,7 @@ def getDocData(fp, root=None):
|
|
|
84
85
|
Raises:
|
|
85
86
|
ValueError if the file does not exist or directory traversal attempted..
|
|
86
87
|
'''
|
|
88
|
+
s_common.deprdate('synapse.lib.jupyter.getDocData', '2024-08-26')
|
|
87
89
|
fpath = getDocPath(fp, root)
|
|
88
90
|
if fpath.endswith('.yaml'):
|
|
89
91
|
return s_common.yamlload(fpath)
|
|
@@ -103,6 +105,7 @@ def getDocData(fp, root=None):
|
|
|
103
105
|
@contextlib.asynccontextmanager
|
|
104
106
|
async def genTempCoreProxy(mods=None):
|
|
105
107
|
'''Get a temporary cortex proxy.'''
|
|
108
|
+
s_common.deprdate('synapse.lib.jupyter.genTempCoreProxy', '2024-08-26')
|
|
106
109
|
with s_common.getTempDir() as dirn:
|
|
107
110
|
async with await s_cortex.Cortex.anit(dirn) as core:
|
|
108
111
|
if mods:
|
|
@@ -115,6 +118,8 @@ async def genTempCoreProxy(mods=None):
|
|
|
115
118
|
|
|
116
119
|
@contextlib.asynccontextmanager
|
|
117
120
|
async def genTempStormsvcProxy(cmdrcore, svcname, svcctor, conf=None):
|
|
121
|
+
s_common.deprdate('synapse.lib.jupyter.genTempStormsvcProxy', '2024-08-26')
|
|
122
|
+
|
|
118
123
|
if conf is None:
|
|
119
124
|
conf = {}
|
|
120
125
|
|
|
@@ -142,12 +147,14 @@ async def genTempStormsvcProxy(cmdrcore, svcname, svcctor, conf=None):
|
|
|
142
147
|
|
|
143
148
|
async def getItemStorm(prox, outp=None):
|
|
144
149
|
'''Get a Storm CLI instance with prepopulated locs'''
|
|
150
|
+
s_common.deprdate('synapse.lib.jupyter.getItemStorm', '2024-08-26')
|
|
145
151
|
storm = await s_t_storm.StormCli.anit(prox, outp=outp)
|
|
146
152
|
storm.echoline = True
|
|
147
153
|
return storm
|
|
148
154
|
|
|
149
155
|
async def getItemCmdr(prox, outp=None, locs=None):
|
|
150
156
|
'''Get a Cmdr instance with prepopulated locs'''
|
|
157
|
+
s_common.deprdate('synapse.lib.jupyter.getItemCmdr', '2024-08-26')
|
|
151
158
|
cmdr = await s_cmdr.getItemCmdr(prox, outp=outp)
|
|
152
159
|
cmdr.echoline = True
|
|
153
160
|
if locs:
|
|
@@ -159,6 +166,7 @@ def suppress_logging(suppress):
|
|
|
159
166
|
'''
|
|
160
167
|
Context manager to suppress specific loggers.
|
|
161
168
|
'''
|
|
169
|
+
s_common.deprdate('synapse.lib.jupyter.suppress_logging', '2024-08-26')
|
|
162
170
|
logs = {}
|
|
163
171
|
if not suppress:
|
|
164
172
|
yield None
|
|
@@ -197,6 +205,7 @@ class StormCore(s_base.Base):
|
|
|
197
205
|
'''
|
|
198
206
|
Context manager to suppress specific loggers.
|
|
199
207
|
'''
|
|
208
|
+
s_common.deprdate('StormCore.suppress_logging', '2024-08-26')
|
|
200
209
|
with suppress_logging(suppress):
|
|
201
210
|
yield None
|
|
202
211
|
|
|
@@ -204,6 +213,7 @@ class StormCore(s_base.Base):
|
|
|
204
213
|
'''
|
|
205
214
|
Run a line of text directly via storm cli.
|
|
206
215
|
'''
|
|
216
|
+
s_common.deprdate('StormCore.runCmdLine', '2024-08-26')
|
|
207
217
|
await self.stormcli.runCmdLine(text, opts=opts)
|
|
208
218
|
|
|
209
219
|
async def _runStorm(self, text, opts=None, cli=False, suppress_logging=False):
|
|
@@ -240,6 +250,7 @@ class StormCore(s_base.Base):
|
|
|
240
250
|
Returns:
|
|
241
251
|
list: A list of storm messages.
|
|
242
252
|
'''
|
|
253
|
+
s_common.deprdate('StormCore.storm', '2024-08-26')
|
|
243
254
|
mesgs = await self._runStorm(text, opts, cli, suppress_logging)
|
|
244
255
|
if num is not None:
|
|
245
256
|
nodes = [m for m in mesgs if m[0] == 'node']
|
|
@@ -265,12 +276,14 @@ class CmdrCore(s_base.Base):
|
|
|
265
276
|
'''
|
|
266
277
|
Add feed data to the cortex.
|
|
267
278
|
'''
|
|
279
|
+
s_common.deprdate('CmdrCore.addFeedData', '2024-08-26')
|
|
268
280
|
return await self.core.addFeedData(name, items, viewiden=viewiden)
|
|
269
281
|
|
|
270
282
|
async def runCmdLine(self, text):
|
|
271
283
|
'''
|
|
272
284
|
Run a line of text directly via cmdr.
|
|
273
285
|
'''
|
|
286
|
+
s_common.deprdate('CmdrCore.runCmdLine', '2024-08-26')
|
|
274
287
|
await self.cmdr.runCmdLine(text)
|
|
275
288
|
|
|
276
289
|
@contextlib.contextmanager
|
|
@@ -278,6 +291,7 @@ class CmdrCore(s_base.Base):
|
|
|
278
291
|
'''
|
|
279
292
|
Context manager to suppress specific loggers.
|
|
280
293
|
'''
|
|
294
|
+
s_common.deprdate('CmdrCore.suppress_logging', '2024-08-26')
|
|
281
295
|
with suppress_logging(suppress):
|
|
282
296
|
yield None
|
|
283
297
|
|
|
@@ -318,6 +332,7 @@ class CmdrCore(s_base.Base):
|
|
|
318
332
|
Returns:
|
|
319
333
|
list: A list of storm messages.
|
|
320
334
|
'''
|
|
335
|
+
s_common.deprdate('CmdrCore.storm', '2024-08-26')
|
|
321
336
|
mesgs = await self._runStorm(text, opts, cmdr, suppress_logging)
|
|
322
337
|
if num is not None:
|
|
323
338
|
nodes = [m for m in mesgs if m[0] == 'node']
|
|
@@ -342,6 +357,7 @@ class CmdrCore(s_base.Base):
|
|
|
342
357
|
Returns:
|
|
343
358
|
list: A list of packed nodes.
|
|
344
359
|
'''
|
|
360
|
+
s_common.deprdate('CmdrCore.eval', '2024-08-26')
|
|
345
361
|
mesgs = await self._runStorm(text, opts, cmdr)
|
|
346
362
|
for mesg in mesgs:
|
|
347
363
|
if mesg[0] == 'err': # pragma: no cover
|
|
@@ -375,6 +391,7 @@ async def getTempCoreProx(mods=None):
|
|
|
375
391
|
Returns:
|
|
376
392
|
s_telepath.Proxy
|
|
377
393
|
'''
|
|
394
|
+
s_common.deprdate('synapse.lib.jupyter.getTempCoreProx', '2024-08-26')
|
|
378
395
|
acm = genTempCoreProxy(mods)
|
|
379
396
|
prox = await acm.__aenter__()
|
|
380
397
|
# Use object.__setattr__ to hulk smash and avoid proxy getattr magick
|
|
@@ -399,6 +416,7 @@ async def getTempCoreStorm(mods=None, outp=None):
|
|
|
399
416
|
Returns:
|
|
400
417
|
StormCore: A StormCore instance.
|
|
401
418
|
'''
|
|
419
|
+
s_common.deprdate('synapse.lib.jupyter.getTempCoreStorm', '2024-08-26')
|
|
402
420
|
acm = genTempCoreProxy(mods)
|
|
403
421
|
prox = await acm.__aenter__()
|
|
404
422
|
stormcore = await StormCore.anit(prox, outp=outp)
|
|
@@ -419,6 +437,7 @@ async def getTempCoreCmdr(mods=None, outp=None):
|
|
|
419
437
|
Returns:
|
|
420
438
|
CmdrCore: A CmdrCore instance.
|
|
421
439
|
'''
|
|
440
|
+
s_common.deprdate('synapse.lib.jupyter.getTempCoreCmdr', '2024-08-26')
|
|
422
441
|
acm = genTempCoreProxy(mods)
|
|
423
442
|
prox = await acm.__aenter__()
|
|
424
443
|
cmdrcore = await CmdrCore.anit(prox, outp=outp)
|
|
@@ -441,6 +460,7 @@ async def getTempCoreCmdrStormsvc(svcname, svcctor, svcconf=None, outp=None):
|
|
|
441
460
|
Returns:
|
|
442
461
|
(CmdrCore, Proxy): A CmdrCore instance and proxy to the Storm service
|
|
443
462
|
'''
|
|
463
|
+
s_common.deprdate('synapse.lib.jupyter.getTempCoreCmdrStormsvc', '2024-08-26')
|
|
444
464
|
cmdrcore = await getTempCoreCmdr(outp=outp)
|
|
445
465
|
|
|
446
466
|
acm = genTempStormsvcProxy(cmdrcore, svcname, svcctor, svcconf)
|
|
@@ -470,6 +490,7 @@ async def getTempCoreStormStormsvc(svcname, svcctor, svcconf=None, outp=None):
|
|
|
470
490
|
Returns:
|
|
471
491
|
(StormCore, Proxy): A StormCore instance and proxy to the Storm service
|
|
472
492
|
'''
|
|
493
|
+
s_common.deprdate('synapse.lib.jupyter.getTempCoreStormStormsvc', '2024-08-26')
|
|
473
494
|
stormcore = await getTempCoreStorm(outp=outp)
|
|
474
495
|
|
|
475
496
|
acm = genTempStormsvcProxy(stormcore, svcname, svcctor, svcconf)
|