simo 2.0.30__py3-none-any.whl → 2.0.32__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 simo might be problematic. Click here for more details.

simo/generic/forms.py CHANGED
@@ -33,7 +33,7 @@ class ScriptConfigForm(BaseComponentForm):
33
33
  )
34
34
  keep_alive = forms.BooleanField(
35
35
  initial=True, required=False,
36
- help_text="Wake up every 10s if not running."
36
+ help_text="Restart the script if it fails. "
37
37
  )
38
38
  code = forms.CharField(widget=PythonCode)
39
39
  log = forms.CharField(
simo/generic/gateways.py CHANGED
@@ -216,7 +216,7 @@ class GenericGatewayHandler(BaseObjectCommandsGatewayHandler):
216
216
  for script in Component.objects.filter(
217
217
  controller_uid=Script.uid,
218
218
  config__keep_alive=True
219
- ).exclude(value='running'):
219
+ ).exclude(value__in=('running', 'stopped', 'finished')):
220
220
  self.start_script(script)
221
221
 
222
222
  def watch_watering(self):
@@ -252,12 +252,18 @@ class GenericGatewayHandler(BaseObjectCommandsGatewayHandler):
252
252
  for component in Component.objects.filter(
253
253
  controller_uid=Script.uid, value='running'
254
254
  ):
255
- component.value = 'stopped'
255
+ component.value = 'error'
256
256
  component.save()
257
257
 
258
+ # Start scripts that are designed to be autostarted
259
+ # as well as those who are designed to be kept alive, but
260
+ # got terminated unexpectedly
258
261
  for script in Component.objects.filter(
259
- controller_uid=Script.uid, config__autostart=True
260
- ):
262
+ controller_uid=Script.uid,
263
+ ).filter(
264
+ Q(config__autostart=True) |
265
+ Q(value='error', config__keep_alive=True)
266
+ ).distinct():
261
267
  self.start_script(script)
262
268
 
263
269
  for cam in Component.objects.filter(
@@ -276,7 +282,9 @@ class GenericGatewayHandler(BaseObjectCommandsGatewayHandler):
276
282
 
277
283
  script_ids = [id for id in self.running_scripts.keys()]
278
284
  for id in script_ids:
279
- self.stop_script(Component.objects.get(id=id))
285
+ self.stop_script(
286
+ Component.objects.get(id=id), 'error'
287
+ )
280
288
 
281
289
  while len(script_ids):
282
290
  time.sleep(0.1)
@@ -310,22 +318,27 @@ class GenericGatewayHandler(BaseObjectCommandsGatewayHandler):
310
318
  if component.id in self.running_scripts:
311
319
  if self.running_scripts[component.id].is_alive():
312
320
  self.running_scripts[component.id].kill()
313
- component.value = 'stopped'
321
+ component.value = 'error'
314
322
  component.save(update_fields=['value'])
315
323
  self.running_scripts[component.id] = ScriptRunHandler(
316
324
  component.id, daemon=True
317
325
  )
318
326
  self.running_scripts[component.id].start()
319
327
 
320
- def stop_script(self, component):
328
+ def stop_script(self, component, stop_status='stopped'):
321
329
  if component.id not in self.running_scripts:
322
330
  if component.value == 'running':
323
- component.value = 'stopped'
331
+ component.value = stop_status
324
332
  component.save(update_fields=['value'])
325
333
  return
326
334
  if self.running_scripts[component.id].is_alive():
335
+ tz = pytz.timezone(component.zone.instance.timezone)
336
+ timezone.activate(tz)
327
337
  logger = get_component_logger(component)
328
- logger.log(logging.INFO, "-------STOP-------")
338
+ if stop_status == 'error':
339
+ logger.log(logging.INFO, "-------GATEWAY STOP-------")
340
+ else:
341
+ logger.log(logging.INFO, "-------STOP-------")
329
342
  self.running_scripts[component.id].terminate()
330
343
 
331
344
  def kill():
@@ -337,12 +350,13 @@ class GenericGatewayHandler(BaseObjectCommandsGatewayHandler):
337
350
  break
338
351
  time.sleep(0.1)
339
352
  if not terminated:
340
- logger.log(
341
- logging.INFO, "-------KILL!-------"
342
- )
353
+ if stop_status == 'error':
354
+ logger.log(logging.INFO, "-------GATEWAY KILL-------")
355
+ else:
356
+ logger.log(logging.INFO, "-------KILL!-------")
343
357
  self.running_scripts[component.id].kill()
344
358
 
345
- component.value = 'stopped'
359
+ component.value = stop_status
346
360
  component.save(update_fields=['value'])
347
361
  self.running_scripts.pop(component.id)
348
362
  logger.handlers = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.0.30
3
+ Version: 2.0.32
4
4
  Summary: Smart Home on Steroids!
5
5
  Author-email: Simanas Venčkauskas <simanas@simo.io>
6
6
  Project-URL: Homepage, https://simo.io
@@ -10276,8 +10276,8 @@ simo/generic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10276
10276
  simo/generic/app_widgets.py,sha256=E_pnpA1hxMIhenRCrHoQ5cik06jm2BAHCkl_eo-OudU,1264
10277
10277
  simo/generic/base_types.py,sha256=djymox_boXTHX1BTTCLXrCH7ED-uAsV_idhaDOc3OLI,409
10278
10278
  simo/generic/controllers.py,sha256=WYuOUzDWvkYRaTvlbdGy_qmwp1o_ohqKDfV7OrOq2QU,52218
10279
- simo/generic/forms.py,sha256=vmkjiQLV6Ab8nm485WK4YCasJG9f-ak0iXpH11sQujo,24263
10280
- simo/generic/gateways.py,sha256=LYCOOO6TffOiLvHYvJcMt6t_lkunlKfUNjhYghEKI2Q,17035
10279
+ simo/generic/forms.py,sha256=NPHNg_8BPTIJt-DR0-GkNWgVo9bE0_50PUWSnpIE4Dg,24262
10280
+ simo/generic/gateways.py,sha256=RcHubz3oyY_ysPLNPLRoyh8C6r-WfPzpD98OVkDvPPI,17731
10281
10281
  simo/generic/models.py,sha256=92TACMhJHadAg0TT9GnARO_R3_Sl6i-GGjhG_x7YdFI,7391
10282
10282
  simo/generic/routing.py,sha256=elQVZmgnPiieEuti4sJ7zITk1hlRxpgbotcutJJgC60,228
10283
10283
  simo/generic/socket_consumers.py,sha256=NfTQGYtVAc864IoogZRxf_0xpDPM0eMCWn0SlKA5P7Y,1751
@@ -10285,8 +10285,8 @@ simo/generic/__pycache__/__init__.cpython-38.pyc,sha256=mLu54WS9KIl-pHwVCBKpsDFI
10285
10285
  simo/generic/__pycache__/app_widgets.cpython-38.pyc,sha256=0IoKRG9n1tkNRRkrqAeOQwWBPd_33u98JBcVtMVVCio,2374
10286
10286
  simo/generic/__pycache__/base_types.cpython-38.pyc,sha256=ptw6axyAqemZA35oa6vzr7EihzvbhW9w7Y-G6kfDedU,555
10287
10287
  simo/generic/__pycache__/controllers.cpython-38.pyc,sha256=e0bvgyePgJbIs1omBq0TRPlVSKar2sK_JbUKqDRj7mY,33235
10288
- simo/generic/__pycache__/forms.cpython-38.pyc,sha256=QCESCygqXCfTzPJ0HMgHEAzq-sZrHi-mOwg5gPm5erQ,17916
10289
- simo/generic/__pycache__/gateways.cpython-38.pyc,sha256=e9_y6PdY05SDZkBT2u1V9jQUowC0hjqsquzWK2YXBjI,12695
10288
+ simo/generic/__pycache__/forms.cpython-38.pyc,sha256=du8pawGkAyGP51Cb6uWgvVLx48JZKNkVCdOpRmqQFaA,17915
10289
+ simo/generic/__pycache__/gateways.cpython-38.pyc,sha256=IbRdwj0oIUyyuR-AOlaPmEwKXr5utWf0LsLTN-HHSuI,12962
10290
10290
  simo/generic/__pycache__/models.cpython-38.pyc,sha256=PzlZsM1jxo3FVb7QDm3bny8UFwTsGrMQe4mj4tJ06eQ,5675
10291
10291
  simo/generic/__pycache__/routing.cpython-38.pyc,sha256=xtxTUTBTdivzFyA5Wh7k-hUj1WDO_FiRq6HYXdbr9Ks,382
10292
10292
  simo/generic/__pycache__/socket_consumers.cpython-38.pyc,sha256=piFHces0J9QuXu_CNBCQCYjoZEeoaxyVjLfJ9KaR8C8,1898
@@ -10456,8 +10456,8 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10456
10456
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10457
10457
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10458
10458
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10459
- simo-2.0.30.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10460
- simo-2.0.30.dist-info/METADATA,sha256=d5-fMPYcwWRAZCXV-9M_bSY14gqQ5M3h5wPaGm28Fzc,1730
10461
- simo-2.0.30.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10462
- simo-2.0.30.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10463
- simo-2.0.30.dist-info/RECORD,,
10459
+ simo-2.0.32.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10460
+ simo-2.0.32.dist-info/METADATA,sha256=z2RvhzDmB2eQsigSTU8ueR531aRvnhHR6AdMINLJucw,1730
10461
+ simo-2.0.32.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10462
+ simo-2.0.32.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10463
+ simo-2.0.32.dist-info/RECORD,,
File without changes