smallneuron 2.2.8__tar.gz → 2.3.1__tar.gz

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.
Files changed (29) hide show
  1. {smallneuron-2.2.8/src/smallneuron.egg-info → smallneuron-2.3.1}/PKG-INFO +1 -1
  2. {smallneuron-2.2.8 → smallneuron-2.3.1}/pyproject.toml +1 -1
  3. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/smallneuron.py +28 -4
  4. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/snwatcher.py +4 -23
  5. {smallneuron-2.2.8 → smallneuron-2.3.1/src/smallneuron.egg-info}/PKG-INFO +1 -1
  6. {smallneuron-2.2.8 → smallneuron-2.3.1}/.gitignore +0 -0
  7. {smallneuron-2.2.8 → smallneuron-2.3.1}/LICENSE +0 -0
  8. {smallneuron-2.2.8 → smallneuron-2.3.1}/README.md +0 -0
  9. {smallneuron-2.2.8 → smallneuron-2.3.1}/example.py +0 -0
  10. {smallneuron-2.2.8 → smallneuron-2.3.1}/setup.cfg +0 -0
  11. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/__init__.py +0 -0
  12. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/build +0 -0
  13. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/gpio_h3.c +0 -0
  14. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/gpio_h3.h +0 -0
  15. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/gpio_h3.so +0 -0
  16. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/logger.py +0 -0
  17. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/sndummy.py +0 -0
  18. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/sngpio.py +0 -0
  19. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/sninput.py +0 -0
  20. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/snmqtt.py +0 -0
  21. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/snserial.py +0 -0
  22. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron/sntimer.py +0 -0
  23. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron.egg-info/SOURCES.txt +0 -0
  24. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron.egg-info/dependency_links.txt +0 -0
  25. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron.egg-info/top_level.txt +0 -0
  26. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron_pelainux.egg-info/PKG-INFO +0 -0
  27. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron_pelainux.egg-info/SOURCES.txt +0 -0
  28. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron_pelainux.egg-info/dependency_links.txt +0 -0
  29. {smallneuron-2.2.8 → smallneuron-2.3.1}/src/smallneuron_pelainux.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smallneuron
3
- Version: 2.2.8
3
+ Version: 2.3.1
4
4
  Summary: Small Neuron Workflow
5
5
  Author-email: Andres Artigas <andres@artigas.cl>
6
6
  Project-URL: Homepage, https://github.com/pypa/sampleproject
@@ -3,7 +3,7 @@ requires = ["setuptools", "setuptools-scm"]
3
3
 
4
4
  [project]
5
5
  name = "smallneuron"
6
- version = "2.2.8"
6
+ version = "2.3.1"
7
7
  authors = [
8
8
  { name="Andres Artigas", email="andres@artigas.cl" },
9
9
  ]
@@ -9,6 +9,7 @@ from .snwatcher import SnWatcher
9
9
  import traceback
10
10
  from datetime import datetime
11
11
  import sys
12
+ import glob
12
13
 
13
14
  #
14
15
  # Para que funcione el tooltip debe set en formato svg, para generarlo usar:
@@ -131,13 +132,15 @@ class EventManager:
131
132
  # que generaran eventos
132
133
  def watchEvent(self,event, event_params={}, data_pattern=None,
133
134
  callback_obj=None, callback_function_args={},
134
- mode="loop",period=1, semaphore:threading.Semaphore=None):
135
- watcher=SnWatcher(self,event,event_params, data_pattern,semaphore)
135
+ mode="loop",period=1):
136
+ watcher=SnWatcher(self,event,event_params, data_pattern)
136
137
  watcher.start(callback_obj,callback_function_args,mode,period)
137
138
  return watcher
138
139
 
139
140
 
140
- def graph(self, f, bold_event=None):
141
+ def graph(self, f, bold_event=None, filename=None):
142
+ if filename !=None:
143
+ f.write("//{filename}\n\n")
141
144
  f.write("digraph { \n")
142
145
  f.write(' layout="dot" \n')
143
146
  f.write(" //rankdir=LR \n")
@@ -218,8 +221,29 @@ class EventManager:
218
221
  )
219
222
 
220
223
  with open(desc, 'w') as f:
221
- self.graph(f, bold_event)
224
+ self.graph(f, bold_event, filename=filename)
222
225
 
226
+ def readGraphFile(self, file, delta=0):
227
+ dotList=glob.glob(self.graphDir+'*.dot')
228
+ dotList.sort()
229
+
230
+ index=-1
231
+ if len(dotList) == 0:
232
+ return ""
233
+ try:
234
+ index=dotList.index(file)+delta
235
+ if index < 0:
236
+ index=0
237
+ elif index >= len(dotList):
238
+ index=-1
239
+ except ValueError as e:
240
+ index=-1
241
+
242
+ nextfile= dotList[index]
243
+ with open(nextfile, 'r') as content_file:
244
+ return content_file.read()
245
+ return ""
246
+
223
247
  def start(self, n_first: Node):
224
248
  n_start = Node(
225
249
  "_start_",
@@ -13,31 +13,21 @@ class SnWatcher():
13
13
  Cada instancia de esta clase monitorea la funcion callback() del bridge, con bridge_args como parametros,
14
14
  Si la respuesta contiene el bridge_pattern se dispara el evento con event_params que se le agrega "data": respuesta
15
15
 
16
- Consideraciones importantes de la funcion check:
16
+ Consideraciones importantes de la funcion callback:
17
17
  1. Debe recibir como parametros los mismo elementos del dict bridge_args de enter()
18
18
  2. Debe retornar un diccionario con almenos el elemento data, todo el diccionario retornado
19
19
  seran parte del argumento del evento junto a los event_params
20
- 3. Si se repiten los elementos retornados por check() con los events_params mandan los de check()
21
- una respuesta hasta que respuesta, bloqueando
20
+ 3. Si se repiten los elementos retornados por callback() con los events_params mandan los de callback()
22
21
  '''
23
- def __init__(self, eventManager, event, event_params={}, event_pattern=None,semaphore:threading.Semaphore=None):
22
+ def __init__(self, eventManager, event, event_params={}, event_pattern=ModuleNotFoundError):
24
23
  self.em=eventManager
25
24
  self.event=event
26
25
  self.event_params=event_params
27
26
  self.event_pattern=event_pattern
28
27
  self.stoploop=False
29
28
  self.thread=None
30
- self._sem:threading.Semaphore=semaphore
31
29
  log.debug("created")
32
-
33
- def semAcquire(self):
34
- if self._sem != None:
35
- self._sem.acquire()
36
-
37
- def semRelease(self):
38
- if self._sem != None:
39
- self._sem.release()
40
-
30
+
41
31
  def start(self, callback_obj, callback_function_args={}, mode="loop",period=1):
42
32
  '''
43
33
  modos validos:
@@ -68,17 +58,13 @@ class SnWatcher():
68
58
  [callback_obj,callback_function_args,mode, period] = args
69
59
  # Pasamos como argumento a la funcion externa un diccionario para los datos
70
60
  # que necesite persistir entre llamados
71
- self.semAcquire()
72
61
  while not self.stoploop:
73
62
  try:
74
63
  resp=callback_obj.callback(**callback_function_args)
75
- self.semRelease()
76
64
  except Exception as e:
77
65
  log.warn(threading.get_ident(),"Exception from callback", e)
78
66
  # Nos olvidamos de esto y saltamos al proximo ciclo
79
- self.semRelease()
80
67
  sleep(period)
81
- self.semAcquire()
82
68
  continue
83
69
 
84
70
  # Si la respuesta no es un dict
@@ -100,21 +86,16 @@ class SnWatcher():
100
86
 
101
87
  # default mode is loop
102
88
  sleep(period)
103
- self.semAcquire()
104
89
 
105
- self.semRelease()
106
90
  log.debug(threading.get_ident(),"_check loop exit, stop")
107
91
  except Exception as e:
108
92
  log.error(e)
109
93
  log.error(traceback.format_exc())
110
94
  log.debug(threading.get_ident(),"_check loop exit, exception")
111
- self.semRelease()
112
95
 
113
96
 
114
97
  def stop(self, wait_to_finish=False):
115
- self.semAcquire()
116
98
  self.stoploop=True
117
- self.semRelease()
118
99
  if wait_to_finish:
119
100
  self.thread.join()
120
101
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smallneuron
3
- Version: 2.2.8
3
+ Version: 2.3.1
4
4
  Summary: Small Neuron Workflow
5
5
  Author-email: Andres Artigas <andres@artigas.cl>
6
6
  Project-URL: Homepage, https://github.com/pypa/sampleproject
File without changes
File without changes
File without changes
File without changes
File without changes