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

Binary file
simo/core/tasks.py CHANGED
@@ -9,6 +9,7 @@ import threading
9
9
  import pkg_resources
10
10
  import sys
11
11
  import traceback
12
+ import uuid
12
13
  from django.db.models import Q
13
14
  from django.db import connection, transaction
14
15
  from django.template.loader import render_to_string
@@ -102,9 +103,15 @@ def save_config(data):
102
103
  def sync_with_remote():
103
104
  from simo.users.models import User
104
105
 
106
+ try:
107
+ mac = str(hex(uuid.getnode()))
108
+ except:
109
+ mac = ''
110
+
105
111
  report_data = {
106
112
  'simo_version': pkg_resources.get_distribution('simo').version,
107
113
  'local_http': 'https://%s' % get_self_ip(),
114
+ 'mac': mac,
108
115
  'hub_uid': dynamic_settings['core__hub_uid'],
109
116
  'hub_secret': dynamic_settings['core__hub_secret'],
110
117
  'remote_conn_version': dynamic_settings['core__remote_conn_version'],
@@ -321,7 +328,7 @@ def vacuum_full():
321
328
 
322
329
  @celery_app.task
323
330
  def update():
324
- from simo.auto_update import perform_update
331
+ from simo.management.auto_update import perform_update
325
332
  perform_update()
326
333
 
327
334
 
@@ -397,7 +404,7 @@ def setup_periodic_tasks(sender, **kwargs):
397
404
  sender.add_periodic_task(1, watch_timers.s())
398
405
  sender.add_periodic_task(20, sync_with_remote.s())
399
406
  sender.add_periodic_task(60 * 60, clear_history.s())
400
- sender.add_periodic_task(60 * 60 * 6, update_latest_version_available.s())
407
+ sender.add_periodic_task(60 * 60, update_latest_version_available.s())
401
408
  sender.add_periodic_task(60, drop_fingerprints_learn.s())
402
409
  sender.add_periodic_task(60 * 60 * 24, restart_postgresql.s())
403
410
  sender.add_periodic_task(60 * 60, low_battery_notifications.s())
@@ -86,6 +86,7 @@ def copy_template(to_directory='/etc/SIMO'):
86
86
  def install():
87
87
  simo_directory = '/etc/SIMO'
88
88
  installed_flag_file_path = os.path.join(simo_directory, 'is_installed.json')
89
+ HUB_DIR = os.path.join(simo_directory, 'hub')
89
90
 
90
91
  if os.path.exists(installed_flag_file_path):
91
92
  print("SIMO.io hub is already installed. ")
@@ -115,21 +116,50 @@ def install():
115
116
  step += 1
116
117
  print(f"{step}.___________Copy default template__________________")
117
118
 
118
- if os.path.exists(simo_directory):
119
- print("Already exists!")
120
- else:
121
- try:
122
- copy_template(simo_directory)
123
- except Exception as e:
124
- print(traceback.format_exc(), file=sys.stderr)
125
- shutil.rmtree(simo_directory, ignore_errors=True)
126
- return
119
+ shutil.rmtree(simo_directory, ignore_errors=True)
120
+ try:
121
+ copy_template(simo_directory)
122
+ except Exception as e:
123
+ print(traceback.format_exc(), file=sys.stderr)
124
+ shutil.rmtree(simo_directory, ignore_errors=True)
125
+ return
126
+
127
+ step += 1
128
+ print(f"{step}.___________Create database__________________")
129
+ subprocess.call(
130
+ 'sudo -u postgres createuser -s -i -d -r -l -w root',
131
+ shell=True
132
+ )
133
+ subprocess.call('createdb SIMO', shell=True)
134
+
135
+ step += 1
136
+ print(f"{step}.___________Apply migrations__________________")
137
+
138
+ proc = subprocess.Popen(
139
+ [os.path.join(HUB_DIR, 'manage.py'), 'migrate'],
140
+ cwd=HUB_DIR,
141
+ stderr=subprocess.PIPE
142
+ )
143
+ out, err = proc.communicate()
144
+ if proc.returncode:
145
+ raise Exception(err.decode())
146
+
147
+ step += 1
148
+ print(f"{step}.___________Collect statics__________________")
149
+ proc = subprocess.Popen(
150
+ [os.path.join(HUB_DIR, 'manage.py'), 'collectstatic',
151
+ '--noinput'],
152
+ cwd=HUB_DIR, stderr=subprocess.PIPE
153
+ )
154
+ out, err = proc.communicate()
155
+ if proc.returncode:
156
+ raise Exception(err.decode())
127
157
 
128
158
  step += 1
129
159
  print(f"{step}.___________Configure supervisor__________________")
130
160
 
131
161
  try:
132
- os.remove('/etc/supervisor/conf.d/SIMO.conf', ignore_errors=True)
162
+ os.remove('/etc/supervisor/conf.d/SIMO.conf')
133
163
  except:
134
164
  pass
135
165
  os.symlink(
@@ -141,7 +171,6 @@ def install():
141
171
  sys.exit("INSTALLATION FAILED! Unable to start supervisord")
142
172
 
143
173
 
144
-
145
174
  step += 1
146
175
  print("%d._____________ Configure NGINX _________________________" % step)
147
176
 
@@ -68,6 +68,11 @@ def update_auto_update():
68
68
  executable_path = '/usr/local/bin/simo-auto-update'
69
69
  if os.geteuid() == 0:
70
70
  # We are running as root!
71
+ if os.path.exists(executable_path):
72
+ # refresh the link if it already exists
73
+ os.remove(executable_path)
74
+ os.symlink(auto_update_file_path, executable_path)
75
+
71
76
  if not os.path.islink(executable_path):
72
77
  # There is no symbolic link yet made for auto updates.
73
78
  # Let's make it!
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.1.2
3
+ Version: 2.1.4
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
@@ -40,7 +40,7 @@ simo/core/serializers.py,sha256=M3r2P1-Eb5eObOqcI9dttedh4UxgPwWwGYmOfXe3BDk,2030
40
40
  simo/core/signal_receivers.py,sha256=ZhHg1mLn_Yhin-23Af1WNPfE5hnGYhhVDZDTEjRtO-A,6190
41
41
  simo/core/socket_consumers.py,sha256=n7VE2Fvqt4iEAYLTRbTPOcI-7tszMAADu7gimBxB-Fg,9635
42
42
  simo/core/storage.py,sha256=YlxmdRs-zhShWtFKgpJ0qp2NDBuIkJGYC1OJzqkbttQ,572
43
- simo/core/tasks.py,sha256=6Fyn6_eMiH9CEj-Nb4BkrQNmWeiIQr2ski7Rkoe3pvg,13888
43
+ simo/core/tasks.py,sha256=VTr83_8avke6UwFZ9VQ8c2qROpVOqAWqc0RbMxNPd08,14005
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=ze8yX0PBLN-DH8B8jol6NKj0hLOAE4WA1rTXf07G-MU,2129
@@ -73,7 +73,7 @@ simo/core/__pycache__/serializers.cpython-38.pyc,sha256=ibatzlaahJ0keKpml7JWuPsr
73
73
  simo/core/__pycache__/signal_receivers.cpython-38.pyc,sha256=gKwUVUf1vtIo1Ecvm6xGmBSwpEUALHrXai5pkMmjr9I,4895
74
74
  simo/core/__pycache__/socket_consumers.cpython-38.pyc,sha256=NJUr7nRyHFvmAumxxWpsod5wzVVZM99rCEuJs1utHA4,8432
75
75
  simo/core/__pycache__/storage.cpython-38.pyc,sha256=BTkYH8QQyjqI0WOtJC8fHNtgu0YA1vjqZclXjC2vCVI,1116
76
- simo/core/__pycache__/tasks.cpython-38.pyc,sha256=VHLvLqJF23l083sXptO7xaPrJbs2J6R7uhM79Sz2L9s,9796
76
+ simo/core/__pycache__/tasks.cpython-38.pyc,sha256=maImi7pqoVNvKNESi4xY_WdTOJdjDgP11knfXKKuVcI,9902
77
77
  simo/core/__pycache__/todos.cpython-38.pyc,sha256=lOqGZ58siHM3isoJV4r7sg8igrfE9fFd-jSfeBa0AQI,253
78
78
  simo/core/__pycache__/views.cpython-38.pyc,sha256=ULyoiWRiU_auXTuxzi2RyqYIea9VfaiMuTzkMAWaWOA,2343
79
79
  simo/core/__pycache__/widgets.cpython-38.pyc,sha256=sR0ZeHCHrhnNDBJuRrxp3zUsfBp0xrtF0xrK2TkQv1o,3520
@@ -10337,10 +10337,10 @@ simo/generic/templates/generic/controllers_info/stateselect.md,sha256=T0w3vJg02W
10337
10337
  simo/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10338
10338
  simo/management/auto_update.py,sha256=4MDrJHdtC5LxEJM258Y0kc5yI4yloeKhDjh-S2BN-ZQ,2115
10339
10339
  simo/management/copy_template.py,sha256=Iehq57FYMzdHNp3LU4ue6rr6AkRiGeOthG7PoGWd88Q,2002
10340
- simo/management/install.py,sha256=n6lSMYuXXrkpBlikTqVgH9pH7sv-WHlcqsZxS2FY1O4,8761
10341
- simo/management/on_http_start.py,sha256=YUG4sspyUMRbMyyF3oYJrK6A-vOC1xxkeq10RhZwczE,3113
10340
+ simo/management/install.py,sha256=IwSeullwXxATsL4cpLNmOgmVJASwLehopohp9Ua-064,9640
10341
+ simo/management/on_http_start.py,sha256=ZDotfMQaCjksD5FFf3eZYgJS-gd_-7eZhYTHLaD-448,3312
10342
10342
  simo/management/__pycache__/__init__.cpython-38.pyc,sha256=ey9k5mPsmvAHRVf5Du6QUqy40LgBCAPN_B5EaR6h9Eg,164
10343
- simo/management/__pycache__/on_http_start.cpython-38.pyc,sha256=I3IXOxj87WQC6MsLLEOmM4E_Z1sr5oXE77HyZquar2M,2811
10343
+ simo/management/__pycache__/on_http_start.cpython-38.pyc,sha256=ERfcMNz3QnqDJTJ4PwbmDfLgPCh5hrEcaedejARFkUQ,2864
10344
10344
  simo/management/_hub_template/hub/asgi.py,sha256=ElN_fdeSkf0Ysa7pS9rJVmZ1HmLhFxb8jFaMLqe1220,126
10345
10345
  simo/management/_hub_template/hub/celeryc.py,sha256=3ksDXftIZKJ4Cq9WNKJERdZdQlDEnjTQXycweRFmsSQ,27
10346
10346
  simo/management/_hub_template/hub/manage.py,sha256=PNNlw3EVeIJDgkG0l-klqoxsKWfTYWG9jzRG0upmAaI,620
@@ -10494,9 +10494,9 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10494
10494
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10495
10495
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10496
10496
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10497
- simo-2.1.2.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10498
- simo-2.1.2.dist-info/METADATA,sha256=-XN-d9NSYev-sEOutv6tpl24fZqUGR3N4KACepMnEOM,1817
10499
- simo-2.1.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10500
- simo-2.1.2.dist-info/entry_points.txt,sha256=3njaDZyp2UwCRhVkWOHrDt1TsSCfZVmfVVGsMsaUhyk,60
10501
- simo-2.1.2.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10502
- simo-2.1.2.dist-info/RECORD,,
10497
+ simo-2.1.4.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10498
+ simo-2.1.4.dist-info/METADATA,sha256=BV3GcDw-Fy6Wx4aVwZIwJ6vS_Qwea0cVZbGor3xjYiE,1817
10499
+ simo-2.1.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10500
+ simo-2.1.4.dist-info/entry_points.txt,sha256=SJBxiDpH7noO0STxVI_eRIsGR-nLgdXXeqCDe8cXlbM,65
10501
+ simo-2.1.4.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10502
+ simo-2.1.4.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ simo-install = simo.management.install:install
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- simo-install = management.install:install
File without changes