simo 2.2.11__py3-none-any.whl → 2.2.12__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.

@@ -57,17 +57,6 @@ class AutoUpdate(BooleanPreference):
57
57
  name = 'auto_update'
58
58
  default = True
59
59
 
60
- def validate(self, value):
61
- if value:
62
- with open(os.path.join(settings.VAR_DIR, 'auto_update'), 'w') as f:
63
- f.write("YES!")
64
- else:
65
- try:
66
- os.remove(os.path.join(settings.VAR_DIR, 'auto_update'))
67
- except:
68
- pass
69
- return
70
-
71
60
 
72
61
  @global_preferences_registry.register
73
62
  class NeedsMqttAclsRebuild(BooleanPreference):
@@ -55,53 +55,10 @@ def prepare_mosquitto():
55
55
  )
56
56
 
57
57
 
58
- def update_auto_update():
59
- import simo
60
- auto_update_file_path = os.path.join(
61
- os.path.dirname(simo.__file__), 'management',
62
- 'auto_update.py'
63
- )
64
- st = os.stat(auto_update_file_path)
65
- os.chmod(auto_update_file_path, st.st_mode | 0o111)
66
-
67
- executable_path = '/usr/local/bin/simo-auto-update'
68
- if os.geteuid() == 0:
69
- # We are running as root!
70
- if os.path.exists(executable_path):
71
- # refresh the link if it already exists
72
- os.remove(executable_path)
73
- os.symlink(auto_update_file_path, executable_path)
74
-
75
- if not os.path.islink(executable_path):
76
- # There is no symbolic link yet made for auto updates.
77
- # Let's make it!
78
- os.symlink(auto_update_file_path, executable_path)
79
- auto_update_cron = f'0 * * * * {executable_path} \n'
80
- cron_out = subprocess.Popen(['crontab', '-'], stdin=subprocess.PIPE)
81
- cron_out.communicate(input=str.encode(auto_update_cron))
82
-
83
-
84
- def maybe_update_to_latest_immediately():
85
- from simo.core.tasks import update_latest_version_available, update
86
- from simo.core.models import Instance
87
- from simo.conf import dynamic_settings
88
- update_latest_version_available()
89
- if dynamic_settings['core__latest_version_available'] != \
90
- pkg_resources.get_distribution('simo').version:
91
- print("There is newer version, we should probably update!")
92
- if not Instance.objects.all().count():
93
- print("Yes let's do it asynchronously!")
94
- return update.s()
95
- print("Nope, we already have some instances running, "
96
- "so we leave that for hub owners.")
97
-
98
-
99
-
100
58
 
101
59
  class Command(BaseCommand):
102
60
 
103
-
104
61
  def handle(self, *args, **options):
105
62
  prepare_mosquitto()
106
- update_auto_update()
107
- maybe_update_to_latest_immediately()
63
+ from simo.core.tasks import maybe_update_to_latest
64
+ maybe_update_to_latest.delay()
simo/core/tasks.py CHANGED
@@ -325,15 +325,6 @@ def update():
325
325
  perform_update()
326
326
 
327
327
 
328
- @celery_app.task
329
- def update_latest_version_available():
330
- resp = requests.get("https://pypi.org/pypi/simo/json")
331
- if resp.status_code != 200:
332
- print("Bad response from server")
333
- return
334
- latest = list(resp.json()['releases'].keys())[-1]
335
- dynamic_settings['core__latest_version_available'] = latest
336
- print("Got the latest version available!")
337
328
 
338
329
 
339
330
  @celery_app.task
@@ -392,11 +383,33 @@ def low_battery_notifications():
392
383
  )
393
384
 
394
385
 
386
+ @celery_app.task
387
+ def maybe_update_to_latest():
388
+ from simo.core.models import Instance
389
+ from simo.conf import dynamic_settings
390
+ resp = requests.get("https://pypi.org/pypi/simo/json")
391
+ if resp.status_code != 200:
392
+ print("Bad response from server")
393
+ return
394
+ latest = list(resp.json()['releases'].keys())[-1]
395
+ dynamic_settings['core__latest_version_available'] = latest
396
+ if dynamic_settings['core__latest_version_available'] == \
397
+ pkg_resources.get_distribution('simo').version:
398
+ print("Up to date!")
399
+ return
400
+
401
+ if not Instance.objects.all().count() or dynamic_settings['auto_update']:
402
+ print("Need to update!!")
403
+ return update.s()
404
+
405
+ print("New version is available, but auto update is disabled.")
406
+
407
+
395
408
  @celery_app.on_after_finalize.connect
396
409
  def setup_periodic_tasks(sender, **kwargs):
397
410
  sender.add_periodic_task(20, sync_with_remote.s())
398
411
  sender.add_periodic_task(60 * 60, clear_history.s())
399
- sender.add_periodic_task(60 * 60, update_latest_version_available.s())
412
+ sender.add_periodic_task(60 * 60, maybe_update_to_latest.s())
400
413
  sender.add_periodic_task(60, drop_fingerprints_learn.s())
401
414
  sender.add_periodic_task(60 * 60 * 24, restart_postgresql.s())
402
415
  sender.add_periodic_task(60 * 60, low_battery_notifications.s())
@@ -1,7 +1,7 @@
1
1
  # using gunicorn for regular requests
2
2
  [program:simo-gunicorn]
3
3
  directory={{ project_dir }}/hub/
4
- command=/bin/sh -c "/usr/bin/python3 manage.py on_http_start && /usr/local/bin/gunicorn --workers 4 --timeout 120 --bind unix:/tmp/gunicorn.sock wsgi:application"
4
+ command=/bin/sh -c "{{ venv_path }}/python manage.py on_http_start && {{ venv_path }}/gunicorn --workers 4 --timeout 120 --bind unix:/tmp/gunicorn.sock wsgi:application"
5
5
  process_name=%(program_name)s
6
6
  user=root
7
7
  stdout_logfile=/var/log/simo/gunicorn.log
@@ -14,7 +14,7 @@ autorestart=true
14
14
  # using daphne for socket connections routed to /ws/ on nginx.conf
15
15
  [program:simo-daphne]
16
16
  directory={{ project_dir }}/hub/
17
- command=/usr/local/bin/daphne -u /tmp/http.sock --access-log /dev/stdout --proxy-headers asgi:application
17
+ command={{ venv_path }}/daphne -u /tmp/http.sock --access-log /dev/stdout --proxy-headers asgi:application
18
18
  process_name=%(program_name)s
19
19
  user=root
20
20
  stdout_logfile=/var/log/simo/daphne.log
@@ -26,7 +26,7 @@ autorestart=true
26
26
 
27
27
 
28
28
  [program:simo-gateways]
29
- command=/usr/bin/python3 {{ project_dir }}/hub/manage.py gateways_manager
29
+ command={{ venv_path }}/python {{ project_dir }}/hub/manage.py gateways_manager
30
30
  process_name=%(program_name)s
31
31
  user=root
32
32
  stopsignal=INT
@@ -40,7 +40,7 @@ autorestart=true
40
40
 
41
41
  [program:simo-celery-beat]
42
42
  directory={{ project_dir }}/hub/
43
- command=/usr/local/bin/celery -A celeryc.celery_app beat -l info --pidfile="/var/run/celerybeat.pid"
43
+ command={{ venv_path }}/celery -A celeryc.celery_app beat -l info --pidfile="/var/run/celerybeat.pid"
44
44
  process_name=%(program_name)s
45
45
  user=root
46
46
  stdout_logfile=/var/log/simo/celery_beat.log
@@ -52,7 +52,7 @@ autorestart=true
52
52
 
53
53
  [program:simo-celery-worker]
54
54
  directory={{ project_dir }}/hub/
55
- command=/usr/local/bin/celery -A celeryc.celery_app worker -l info --concurrency=4
55
+ command={{ venv_path }}/celery -A celeryc.celery_app worker -l info --concurrency=4
56
56
  process_name=%(program_name)s
57
57
  user=root
58
58
  stdout_logfile=/var/log/simo/celery_worker.log
@@ -19,7 +19,7 @@ def install_dependencies():
19
19
  'postgresql-client-common python3-pip redis-server supervisor '
20
20
  'mosquitto libopenjp2-7 libtiff5 pkg-config libcairo2-dev '
21
21
  'libgirepository1.0-dev libcairo2 libudev-dev gdal-bin net-tools '
22
- 'timeshift nginx postgis openvpn ffmpeg libsm6 libxext6 ssh keychain -y',
22
+ 'nginx postgis openvpn ffmpeg libsm6 libxext6 ssh keychain -y',
23
23
  shell=True
24
24
  )
25
25
  if status != 0:
@@ -48,7 +48,8 @@ def copy_template(to_directory='/etc/SIMO'):
48
48
  context = Context({
49
49
  'secret_key': get_random_secret_key(),
50
50
  'project_dir': to_directory,
51
- 'base_dir': to_directory
51
+ 'base_dir': to_directory,
52
+ 'venv_path': os.path.dirname(sys.executable),
52
53
  }, autoescape=False)
53
54
  template_dir = os.path.join(
54
55
  os.path.dirname(simo.__file__), 'management', '_hub_template'
@@ -170,6 +171,7 @@ def install():
170
171
  os.remove('/etc/supervisor/conf.d/SIMO.conf')
171
172
  except:
172
173
  pass
174
+
173
175
  os.symlink(
174
176
  f'{simo_directory}/hub/supervisor.conf',
175
177
  '/etc/supervisor/conf.d/SIMO.conf'
@@ -247,45 +249,6 @@ def install():
247
249
  if status != 0:
248
250
  sys.exit("INSTALLATION FAILED! Unable to enable UFW")
249
251
 
250
-
251
- step += 1
252
- print("%d.__________ CONFIGURE TIMESHIFT _____________________" % step)
253
-
254
- default_timeshift_file_path = '/etc/timeshift/default.json'
255
- if not os.path.exists(default_timeshift_file_path):
256
- default_timeshift_file_path = '/etc/timeshift/timeshift.json'
257
- if not os.path.exists(default_timeshift_file_path):
258
- default_timeshift_file_path = '/etc/default/timeshift.json'
259
-
260
- if not os.path.exists(default_timeshift_file_path):
261
- print("Unable to find default TimeShift config! Skip TimeShift configuration.")
262
-
263
- else:
264
-
265
- with open(default_timeshift_file_path, 'r') as conf_f:
266
- timeshift_conf = json.loads(conf_f.read())
267
-
268
- timeshift_conf['backup_device_uuid'] = subprocess.check_output(
269
- "lsblk -no UUID $(df -P /etc/SIMO/hub/settings.py | awk 'END{print $1}')",
270
- shell=True
271
- ).decode()[:-1]
272
- timeshift_conf['schedule_monthly'] = "true"
273
- timeshift_conf['schedule_weekly'] = "true"
274
- timeshift_conf['schedule_daily'] = "true"
275
- timeshift_conf['exclude'] = []
276
-
277
- # Must be copied to /etc/timeshift/timeshift.json to work
278
- with open('/etc/timeshift/timeshift.json', 'w') as conf_f:
279
- conf_f.write(json.dumps(timeshift_conf))
280
-
281
- # status = subprocess.call([
282
- # '/usr/bin/timeshift', '--create',
283
- # '--comments', '"Initial backup"', '--tags', 'M'
284
- # ])
285
- # if status != 0:
286
- # print("Unable to start TimeShift")
287
-
288
-
289
252
  step += 1
290
253
  print("%d.__________ PUT UP INSTALL COMPLETE FLAG! _____________________" % step)
291
254
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.2.11
3
+ Version: 2.2.12
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
@@ -33,7 +33,7 @@ Requires-Dist: itsdangerous ==2.0.1
33
33
  Requires-Dist: redis ==3.5.3
34
34
  Requires-Dist: django-redis ==4.12.1
35
35
  Requires-Dist: webservices ==0.7
36
- Requires-Dist: numpy ==1.24.4
36
+ Requires-Dist: numpy ==1.26.4
37
37
  Requires-Dist: opencv-python ==4.5.4.60
38
38
  Requires-Dist: geopy ==2.2.0
39
39
  Requires-Dist: requests ==2.26.0
@@ -24,7 +24,7 @@ simo/core/autocomplete_views.py,sha256=JT5LA2_Wtr60XYSAIqaXFKFYPjrmkEf6yunXD9y2z
24
24
  simo/core/base_types.py,sha256=qVh6MrXZEfN7bFOyFftC7u0yyz0PkvpsjllLBc6SCp4,616
25
25
  simo/core/context.py,sha256=98PXAMie43faRVBFkOG22uNpvGRNprcGhzjBFkrxaRY,1367
26
26
  simo/core/controllers.py,sha256=rLgJqnEMzRC0GpZnQb0m_Cz43Gp2zaYbODU7UUxE5oA,29602
27
- simo/core/dynamic_settings.py,sha256=U9pY7p_hoeD1LxobIvxZqQ7Zn_4MhYMqZvsr4O0PAYs,1871
27
+ simo/core/dynamic_settings.py,sha256=txfRcU2QA_WF6-7Ykc4Hl5gpTkZzi94N8gmmvEolezM,1549
28
28
  simo/core/events.py,sha256=LvtonJGNyCb6HLozs4EG0WZItnDwNdtnGQ4vTcnKvUs,4438
29
29
  simo/core/filters.py,sha256=ghtOZcrwNAkIyF5_G9Sn73NkiI71mXv0NhwCk4IyMIM,411
30
30
  simo/core/form_fields.py,sha256=9tIjiEN3IE55GPyB4tOlfkd51JDne3-h8pKhpL3tLFE,2220
@@ -40,7 +40,7 @@ simo/core/serializers.py,sha256=quXznnTKCm57rvRgke0mBnlWmaO8C5scJ8R251wa1jY,2086
40
40
  simo/core/signal_receivers.py,sha256=9-qFCCeSLcMFEMg6QUtKOVgUsoNoqhzGoI98nuNSTEo,6228
41
41
  simo/core/socket_consumers.py,sha256=n7VE2Fvqt4iEAYLTRbTPOcI-7tszMAADu7gimBxB-Fg,9635
42
42
  simo/core/storage.py,sha256=_5igjaoWZAiExGWFEJMElxUw55DzJG1jqFty33xe8BE,342
43
- simo/core/tasks.py,sha256=pWVq9JGbZQIjwiG02KkfAqyAL8cYAiSA7AWJZbKFYfc,13846
43
+ simo/core/tasks.py,sha256=HE3VsVGJjLKtlZyjYF-TQ2-9vChxZ2EtY6A5vNkZl-0,14235
44
44
  simo/core/todos.py,sha256=eYVXfLGiapkxKK57XuviSNe3WsUYyIWZ0hgQJk7ThKo,665
45
45
  simo/core/types.py,sha256=WJEq48mIbFi_5Alt4wxWMGXxNxUTXqfQU5koH7wqHHI,1108
46
46
  simo/core/views.py,sha256=VVqfEPzK0EdbVMMarkG8rd7cODG5QHpXnr3e8UdrTQE,2600
@@ -130,7 +130,7 @@ simo/core/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
130
130
  simo/core/management/__pycache__/__init__.cpython-38.pyc,sha256=Ptf1WzljXMt3wP1tzOy6q3JfLERYDs66wSHBVdrzjHg,169
131
131
  simo/core/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
132
132
  simo/core/management/commands/gateways_manager.py,sha256=a_JmUG1SPJhbhPh5QdViCT5DL0YvKQH-KsO8ptLhB34,6970
133
- simo/core/management/commands/on_http_start.py,sha256=FuSm3pEOB4gfO_GFtx8lZXaeZaYnA6HbrEmtgoZF8-k,3457
133
+ simo/core/management/commands/on_http_start.py,sha256=un8r0oOwU7niC7uHf63IFvFBVWkl4GeTLEkpmDUpanA,1802
134
134
  simo/core/management/commands/run_gateway.py,sha256=bp0FQQoBeOSoxjHCCMicDL1fxPZZGyLgnq2QKht3bJo,645
135
135
  simo/core/management/commands/update.py,sha256=Y2_6EL8E757nr-MjSuIpdSsEItI0yN42DT5P1e1zkno,175
136
136
  simo/core/management/commands/__pycache__/__init__.cpython-38.pyc,sha256=WKpfZZpAB9D7U4X6oWQIrU_H-6rUmq8Gl9fj9XaY2fw,178
@@ -10346,7 +10346,7 @@ simo/generic/templates/generic/controllers_info/stateselect.md,sha256=T0w3vJg02W
10346
10346
  simo/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10347
10347
  simo/management/auto_update.py,sha256=4MDrJHdtC5LxEJM258Y0kc5yI4yloeKhDjh-S2BN-ZQ,2115
10348
10348
  simo/management/copy_template.py,sha256=Iehq57FYMzdHNp3LU4ue6rr6AkRiGeOthG7PoGWd88Q,2002
10349
- simo/management/install.py,sha256=hy2LB0sPNpaFHv2Wvp6CeiItvKJb3sFVU0lJuz02VDM,10127
10349
+ simo/management/install.py,sha256=hKyjqzE90cyCKYkXEyMhMToYk3xzNZgyjO7nPwrklJo,8668
10350
10350
  simo/management/__pycache__/__init__.cpython-38.pyc,sha256=ey9k5mPsmvAHRVf5Du6QUqy40LgBCAPN_B5EaR6h9Eg,164
10351
10351
  simo/management/__pycache__/auto_update.cpython-38.pyc,sha256=OAp7w4PdXY0xeo7Yof7O_x9y7qNMyZV4ZerRlswjQ2I,1681
10352
10352
  simo/management/_hub_template/hub/asgi.py,sha256=ElN_fdeSkf0Ysa7pS9rJVmZ1HmLhFxb8jFaMLqe1220,126
@@ -10354,7 +10354,7 @@ simo/management/_hub_template/hub/celeryc.py,sha256=3ksDXftIZKJ4Cq9WNKJERdZdQlDE
10354
10354
  simo/management/_hub_template/hub/manage.py,sha256=PNNlw3EVeIJDgkG0l-klqoxsKWfTYWG9jzRG0upmAaI,620
10355
10355
  simo/management/_hub_template/hub/nginx.conf,sha256=40hvXL42MeiqqkLURNcDQsRudv1dNFLJnvb2-Y3RCkk,2394
10356
10356
  simo/management/_hub_template/hub/settings.py,sha256=4QhvhbtLRxHvAntwqG_qeAAtpDUqKvN4jzw9u3vqff8,361
10357
- simo/management/_hub_template/hub/supervisor.conf,sha256=M5FgVi6JS_nel6_Ptt4Dwz2Vugc0gFalxrs90a7R11E,1872
10357
+ simo/management/_hub_template/hub/supervisor.conf,sha256=tl1nW95DrVwcGxgLXAOgIn5ow1p_-LRNNE1bCEoq00k,1888
10358
10358
  simo/management/_hub_template/hub/urls.py,sha256=Ydm-1BkYAzWeEF-MKSDIFf-7aE4qNLPm48-SA51XgJQ,25
10359
10359
  simo/management/_hub_template/hub/wsgi.py,sha256=Lo-huLHnMDTxSmMBOodVFMWBls9poddrV2KRzXU0xGo,280
10360
10360
  simo/multimedia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -10513,9 +10513,9 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10513
10513
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10514
10514
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10515
10515
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10516
- simo-2.2.11.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10517
- simo-2.2.11.dist-info/METADATA,sha256=MwJmlJfWOd9kH5Wrw9ZMSYFI7xVeyetdleeMo5LOJ5k,1881
10518
- simo-2.2.11.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
10519
- simo-2.2.11.dist-info/entry_points.txt,sha256=SJBxiDpH7noO0STxVI_eRIsGR-nLgdXXeqCDe8cXlbM,65
10520
- simo-2.2.11.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10521
- simo-2.2.11.dist-info/RECORD,,
10516
+ simo-2.2.12.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10517
+ simo-2.2.12.dist-info/METADATA,sha256=H_OyTQyMFUXkAZxf_qvyTv_9ecYRdM1azzwJd5dkI-g,1881
10518
+ simo-2.2.12.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
10519
+ simo-2.2.12.dist-info/entry_points.txt,sha256=SJBxiDpH7noO0STxVI_eRIsGR-nLgdXXeqCDe8cXlbM,65
10520
+ simo-2.2.12.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10521
+ simo-2.2.12.dist-info/RECORD,,
File without changes