synapse 2.176.0__py311-none-any.whl → 2.178.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.

Files changed (95) hide show
  1. synapse/axon.py +24 -9
  2. synapse/cortex.py +337 -172
  3. synapse/cryotank.py +46 -37
  4. synapse/datamodel.py +17 -4
  5. synapse/exc.py +19 -0
  6. synapse/lib/agenda.py +7 -13
  7. synapse/lib/aha.py +361 -88
  8. synapse/lib/auth.py +1520 -0
  9. synapse/lib/base.py +27 -9
  10. synapse/lib/cell.py +422 -163
  11. synapse/lib/config.py +15 -11
  12. synapse/lib/coro.py +13 -0
  13. synapse/lib/grammar.py +5 -0
  14. synapse/lib/hive.py +24 -3
  15. synapse/lib/hiveauth.py +6 -32
  16. synapse/lib/layer.py +7 -9
  17. synapse/lib/link.py +22 -18
  18. synapse/lib/lmdbslab.py +152 -3
  19. synapse/lib/modelrev.py +1 -1
  20. synapse/lib/nexus.py +24 -12
  21. synapse/lib/schemas.py +136 -0
  22. synapse/lib/storm.py +61 -29
  23. synapse/lib/stormlib/aha.py +1 -1
  24. synapse/lib/stormlib/auth.py +185 -10
  25. synapse/lib/stormlib/cortex.py +16 -5
  26. synapse/lib/stormlib/gen.py +80 -0
  27. synapse/lib/stormlib/imap.py +6 -2
  28. synapse/lib/stormlib/model.py +55 -0
  29. synapse/lib/stormlib/modelext.py +60 -0
  30. synapse/lib/stormlib/smtp.py +12 -2
  31. synapse/lib/stormlib/tabular.py +212 -0
  32. synapse/lib/stormtypes.py +14 -1
  33. synapse/lib/trigger.py +1 -1
  34. synapse/lib/version.py +2 -2
  35. synapse/lib/view.py +55 -28
  36. synapse/models/base.py +7 -0
  37. synapse/models/biz.py +4 -0
  38. synapse/models/files.py +8 -1
  39. synapse/models/inet.py +8 -0
  40. synapse/telepath.py +32 -17
  41. synapse/tests/files/aha/certs/cas/synapse.crt +28 -0
  42. synapse/tests/files/aha/certs/cas/synapse.key +51 -0
  43. synapse/tests/files/aha/certs/hosts/00.aha.loop.vertex.link.crt +30 -0
  44. synapse/tests/files/aha/certs/hosts/00.aha.loop.vertex.link.key +51 -0
  45. synapse/tests/files/aha/certs/users/root@synapse.crt +29 -0
  46. synapse/tests/files/aha/certs/users/root@synapse.key +51 -0
  47. synapse/tests/files/changelog/model_2.176.0_16ee721a6b7221344eaf946c3ab4602dda546b1a.yaml.gz +0 -0
  48. synapse/tests/files/changelog/model_2.176.0_2a25c58bbd344716cd7cbc3f4304d8925b0f4ef2.yaml.gz +0 -0
  49. synapse/tests/files/rstorm/testsvc.py +1 -1
  50. synapse/tests/test_axon.py +8 -5
  51. synapse/tests/test_cortex.py +149 -141
  52. synapse/tests/test_cryotank.py +4 -4
  53. synapse/tests/test_datamodel.py +7 -0
  54. synapse/tests/test_lib_agenda.py +10 -3
  55. synapse/tests/test_lib_aha.py +336 -490
  56. synapse/tests/{test_lib_hiveauth.py → test_lib_auth.py} +314 -11
  57. synapse/tests/test_lib_base.py +20 -0
  58. synapse/tests/test_lib_cell.py +210 -30
  59. synapse/tests/test_lib_config.py +4 -3
  60. synapse/tests/test_lib_httpapi.py +18 -14
  61. synapse/tests/test_lib_layer.py +33 -33
  62. synapse/tests/test_lib_link.py +42 -1
  63. synapse/tests/test_lib_lmdbslab.py +68 -0
  64. synapse/tests/test_lib_nexus.py +12 -4
  65. synapse/tests/test_lib_node.py +0 -7
  66. synapse/tests/test_lib_storm.py +45 -0
  67. synapse/tests/test_lib_stormlib_aha.py +35 -36
  68. synapse/tests/test_lib_stormlib_auth.py +21 -0
  69. synapse/tests/test_lib_stormlib_cell.py +4 -15
  70. synapse/tests/test_lib_stormlib_cortex.py +12 -12
  71. synapse/tests/test_lib_stormlib_gen.py +99 -0
  72. synapse/tests/test_lib_stormlib_imap.py +14 -3
  73. synapse/tests/test_lib_stormlib_model.py +108 -0
  74. synapse/tests/test_lib_stormlib_modelext.py +64 -0
  75. synapse/tests/test_lib_stormlib_smtp.py +51 -0
  76. synapse/tests/test_lib_stormlib_tabular.py +226 -0
  77. synapse/tests/test_lib_stormsvc.py +4 -1
  78. synapse/tests/test_lib_stormtypes.py +10 -0
  79. synapse/tests/test_model_base.py +3 -0
  80. synapse/tests/test_model_biz.py +3 -0
  81. synapse/tests/test_model_files.py +12 -2
  82. synapse/tests/test_model_inet.py +24 -0
  83. synapse/tests/test_tools_aha.py +78 -101
  84. synapse/tests/test_tools_changelog.py +196 -0
  85. synapse/tests/test_tools_healthcheck.py +4 -3
  86. synapse/tests/utils.py +87 -121
  87. synapse/tools/aha/clone.py +50 -0
  88. synapse/tools/aha/enroll.py +2 -1
  89. synapse/tools/backup.py +2 -2
  90. synapse/tools/changelog.py +776 -15
  91. {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/METADATA +48 -48
  92. {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/RECORD +95 -82
  93. {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/WHEEL +1 -1
  94. {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/LICENSE +0 -0
  95. {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/top_level.txt +0 -0
synapse/lib/base.py CHANGED
@@ -179,6 +179,13 @@ class Base:
179
179
  '''
180
180
  Add a function/coroutine/Base to be called on fini().
181
181
  '''
182
+ if self.isfini:
183
+ if isinstance(func, Base):
184
+ s_coro.create_task(func.fini())
185
+ else:
186
+ s_coro.create_task(s_coro.ornot(func))
187
+ return
188
+
182
189
  if isinstance(func, Base):
183
190
  self.tofini.add(func)
184
191
  return
@@ -408,8 +415,6 @@ class Base:
408
415
  for fini in self._fini_funcs:
409
416
  try:
410
417
  await s_coro.ornot(fini)
411
- except asyncio.CancelledError: # pragma: no cover TODO: remove once >= py 3.8 only
412
- raise
413
418
  except Exception:
414
419
  logger.exception(f'{self} - fini function failed: {fini}')
415
420
 
@@ -579,7 +584,7 @@ class Base:
579
584
  loop.add_signal_handler(signal.SIGINT, sigint)
580
585
  loop.add_signal_handler(signal.SIGTERM, sigterm)
581
586
 
582
- async def main(self):
587
+ async def main(self): # pragma: no cover
583
588
  '''
584
589
  Helper function to setup signal handlers for this base as the main object.
585
590
  ( use base.waitfini() to block )
@@ -590,7 +595,7 @@ class Base:
590
595
  await self.addSignalHandlers()
591
596
  return await self.waitfini()
592
597
 
593
- def waiter(self, count, *names):
598
+ def waiter(self, count, *names, timeout=None):
594
599
  '''
595
600
  Construct and return a new Waiter for events on this base.
596
601
 
@@ -615,16 +620,17 @@ class Base:
615
620
  race conditions with this mechanism ;)
616
621
 
617
622
  '''
618
- return Waiter(self, count, *names)
623
+ return Waiter(self, count, *names, timeout=timeout)
619
624
 
620
625
  class Waiter:
621
626
  '''
622
627
  A helper to wait for a given number of events on a Base.
623
628
  '''
624
- def __init__(self, base, count, *names):
629
+ def __init__(self, base, count, *names, timeout=None):
625
630
  self.base = base
626
631
  self.names = names
627
632
  self.count = count
633
+ self.timeout = timeout
628
634
  self.event = asyncio.Event()
629
635
 
630
636
  self.events = []
@@ -656,6 +662,9 @@ class Waiter:
656
662
  doStuff(evnt)
657
663
 
658
664
  '''
665
+ if timeout is None:
666
+ timeout = self.timeout
667
+
659
668
  try:
660
669
 
661
670
  retn = await s_coro.event_wait(self.event, timeout)
@@ -676,6 +685,18 @@ class Waiter:
676
685
  self.base.unlink(self._onWaitEvent)
677
686
  del self.event
678
687
 
688
+ async def __aenter__(self):
689
+ return self
690
+
691
+ async def __aexit__(self, exc, cls, tb):
692
+ if exc is None:
693
+ if await self.wait() is None: # pragma: no cover
694
+ # these lines are 100% covered by the tests but
695
+ # the coverage plugin cannot seem to see them...
696
+ events = ','.join(self.names)
697
+ mesg = f'timeout waiting for {self.count} event(s): {events}'
698
+ raise s_exc.TimeOut(mesg=mesg)
699
+
679
700
  class BaseRef(Base):
680
701
  '''
681
702
  An object for managing multiple Base instances by name.
@@ -777,9 +798,6 @@ async def schedGenr(genr, maxsize=100):
777
798
 
778
799
  await q.put((False, None))
779
800
 
780
- except asyncio.CancelledError: # pragma: no cover TODO: remove once >= py 3.8 only
781
- raise
782
-
783
801
  except Exception:
784
802
  if not base.isfini:
785
803
  await q.put((False, None))