simo 2.0.4__py3-none-any.whl → 2.0.6__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/__pycache__/settings.cpython-38.pyc +0 -0
- simo/__pycache__/urls.cpython-38.pyc +0 -0
- simo/core/__pycache__/admin.cpython-38.pyc +0 -0
- simo/core/__pycache__/api.cpython-38.pyc +0 -0
- simo/core/__pycache__/api_auth.cpython-38.pyc +0 -0
- simo/core/__pycache__/api_meta.cpython-38.pyc +0 -0
- simo/core/__pycache__/auto_urls.cpython-38.pyc +0 -0
- simo/core/__pycache__/autocomplete_views.cpython-38.pyc +0 -0
- simo/core/__pycache__/base_types.cpython-38.pyc +0 -0
- simo/core/__pycache__/context.cpython-38.pyc +0 -0
- simo/core/__pycache__/controllers.cpython-38.pyc +0 -0
- simo/core/__pycache__/events.cpython-38.pyc +0 -0
- simo/core/__pycache__/forms.cpython-38.pyc +0 -0
- simo/core/__pycache__/gateways.cpython-38.pyc +0 -0
- simo/core/__pycache__/managers.cpython-38.pyc +0 -0
- simo/core/__pycache__/middleware.cpython-38.pyc +0 -0
- simo/core/__pycache__/models.cpython-38.pyc +0 -0
- simo/core/__pycache__/permissions.cpython-38.pyc +0 -0
- simo/core/__pycache__/serializers.cpython-38.pyc +0 -0
- simo/core/__pycache__/socket_consumers.cpython-38.pyc +0 -0
- simo/core/__pycache__/tasks.cpython-38.pyc +0 -0
- simo/core/__pycache__/views.cpython-38.pyc +0 -0
- simo/core/admin.py +8 -10
- simo/core/api.py +3 -3
- simo/core/api_auth.py +4 -2
- simo/core/controllers.py +1 -0
- simo/core/db_backend/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/core/db_backend/__pycache__/base.cpython-38.pyc +0 -0
- simo/core/drf_braces/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/core/drf_braces/__pycache__/utils.cpython-38.pyc +0 -0
- simo/core/drf_braces/fields/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/core/drf_braces/fields/__pycache__/_fields.cpython-38.pyc +0 -0
- simo/core/drf_braces/fields/__pycache__/custom.cpython-38.pyc +0 -0
- simo/core/drf_braces/fields/__pycache__/mixins.cpython-38.pyc +0 -0
- simo/core/drf_braces/fields/__pycache__/modified.cpython-38.pyc +0 -0
- simo/core/drf_braces/serializers/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/core/drf_braces/serializers/__pycache__/form_serializer.cpython-38.pyc +0 -0
- simo/core/forms.py +8 -6
- simo/core/migrations/__pycache__/0001_initial.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0002_load_icons.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0003_create_default_zones_and_categories.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0004_create_generic.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0005_component_subcomponents.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0006_alter_component_subcomponents.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0007_component_change_init_to.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0008_alter_component_change_init_to.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0009_auto_20220707_1404.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0010_historyaggregate.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0011_component_last_change.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0012_instance.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0013_auto_20231003_0754.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0014_zone_instance.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0015_auto_20231004_1113.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0016_auto_20231004_1113.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0017_auto_20231004_1313.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0018_auto_20231005_0622.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0019_alter_gateway_type.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0020_component_meta.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0021_auto_20231020_1041.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0026_category_instance.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0027_remove_component_tags.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0028_rename_subcomponents_component_slaves.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/0029_auto_20240229_1331.cpython-38.pyc +0 -0
- simo/core/migrations/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/core/models.py +30 -46
- simo/core/serializers.py +2 -3
- simo/core/templatetags/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/core/templatetags/__pycache__/components_list.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/admin.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/config_values.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/easing.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/form_fields.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/form_widgets.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/formsets.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/helpers.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/logs.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/mixins.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/model_helpers.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/relay.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/serialization.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/type_constants.cpython-38.pyc +0 -0
- simo/core/utils/__pycache__/validators.cpython-38.pyc +0 -0
- simo/core/utils/type_constants.py +32 -11
- simo/fleet/__pycache__/admin.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/api.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/auto_urls.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/controllers.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/forms.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/gateways.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/managers.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/models.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/serializers.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/socket_consumers.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/utils.cpython-38.pyc +0 -0
- simo/fleet/__pycache__/views.cpython-38.pyc +0 -0
- simo/fleet/migrations/__pycache__/0025_auto_20240130_1334.cpython-38.pyc +0 -0
- simo/fleet/migrations/__pycache__/0026_rename_i2cinterface_scl_pin_and_more.cpython-38.pyc +0 -0
- simo/fleet/migrations/__pycache__/0027_auto_20240306_0802.cpython-38.pyc +0 -0
- simo/fleet/migrations/__pycache__/0028_remove_i2cinterface_scl_pin_no_and_more.cpython-38.pyc +0 -0
- simo/fleet/migrations/__pycache__/0029_alter_i2cinterface_scl_pin_and_more.cpython-38.pyc +0 -0
- simo/fleet/migrations/__pycache__/0030_colonelpin_label_alter_colonel_type.cpython-38.pyc +0 -0
- simo/fleet/migrations/__pycache__/0031_alter_colonel_type.cpython-38.pyc +0 -0
- simo/fleet/models.py +2 -1
- simo/generic/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/generic/__pycache__/app_widgets.cpython-38.pyc +0 -0
- simo/generic/__pycache__/base_types.cpython-38.pyc +0 -0
- simo/generic/__pycache__/controllers.cpython-38.pyc +0 -0
- simo/generic/__pycache__/forms.cpython-38.pyc +0 -0
- simo/generic/__pycache__/gateways.cpython-38.pyc +0 -0
- simo/generic/__pycache__/models.cpython-38.pyc +0 -0
- simo/generic/__pycache__/routing.cpython-38.pyc +0 -0
- simo/generic/__pycache__/socket_consumers.cpython-38.pyc +0 -0
- simo/generic/controllers.py +0 -7
- simo/generic/forms.py +0 -3
- simo/generic/gateways.py +0 -8
- simo/multimedia/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/multimedia/__pycache__/admin.cpython-38.pyc +0 -0
- simo/multimedia/__pycache__/api.cpython-38.pyc +0 -0
- simo/multimedia/__pycache__/app_widgets.cpython-38.pyc +0 -0
- simo/multimedia/__pycache__/base_types.cpython-38.pyc +0 -0
- simo/multimedia/__pycache__/controllers.cpython-38.pyc +0 -0
- simo/multimedia/__pycache__/forms.cpython-38.pyc +0 -0
- simo/multimedia/__pycache__/models.cpython-38.pyc +0 -0
- simo/multimedia/__pycache__/serializers.cpython-38.pyc +0 -0
- simo/multimedia/migrations/__pycache__/0001_initial.cpython-38.pyc +0 -0
- simo/multimedia/migrations/__pycache__/0002_sound_length.cpython-38.pyc +0 -0
- simo/multimedia/migrations/__pycache__/0003_alter_sound_length.cpython-38.pyc +0 -0
- simo/multimedia/migrations/__pycache__/0004_auto_20231023_1055.cpython-38.pyc +0 -0
- simo/multimedia/migrations/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/notifications/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/notifications/__pycache__/admin.cpython-38.pyc +0 -0
- simo/notifications/__pycache__/api.cpython-38.pyc +0 -0
- simo/notifications/__pycache__/models.cpython-38.pyc +0 -0
- simo/notifications/__pycache__/serializers.cpython-38.pyc +0 -0
- simo/notifications/migrations/__pycache__/0001_initial.cpython-38.pyc +0 -0
- simo/notifications/migrations/__pycache__/0002_notification_instance.cpython-38.pyc +0 -0
- simo/notifications/migrations/__pycache__/__init__.cpython-38.pyc +0 -0
- simo/users/__pycache__/admin.cpython-38.pyc +0 -0
- simo/users/__pycache__/api.cpython-38.pyc +0 -0
- simo/users/__pycache__/auto_urls.cpython-38.pyc +0 -0
- simo/users/__pycache__/middleware.cpython-38.pyc +0 -0
- simo/users/__pycache__/models.cpython-38.pyc +0 -0
- simo/users/__pycache__/serializers.cpython-38.pyc +0 -0
- simo/users/__pycache__/sso_urls.cpython-38.pyc +0 -0
- simo/users/middleware.py +2 -4
- simo/users/migrations/__pycache__/0001_initial.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0002_componentpermission.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0003_create_roles_and_system_user.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0004_user_secret_key.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0005_permissionsrole_instance.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0006_auto_20231003_0850.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0007_auto_20231003_1228.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0008_auto_20231003_1229.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0009_remove_user_role.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0010_auto_20231004_1313.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0011_auto_20231004_1313.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0012_alter_userinstancerole_unique_together.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0013_remove_user_roles.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0014_user_roles.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0015_remove_user_at_home.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0016_auto_20231005_1050.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/0025_rename_name_fingerprint_type_and_more.cpython-38.pyc +0 -0
- simo/users/migrations/__pycache__/__init__.cpython-38.pyc +0 -0
- {simo-2.0.4.dist-info → simo-2.0.6.dist-info}/METADATA +1 -1
- {simo-2.0.4.dist-info → simo-2.0.6.dist-info}/RECORD +169 -81
- {simo-2.0.4.dist-info → simo-2.0.6.dist-info}/LICENSE.md +0 -0
- {simo-2.0.4.dist-info → simo-2.0.6.dist-info}/WHEEL +0 -0
- {simo-2.0.4.dist-info → simo-2.0.6.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
simo/core/admin.py
CHANGED
|
@@ -9,8 +9,7 @@ from django.views.decorators.csrf import csrf_protect
|
|
|
9
9
|
from django.shortcuts import redirect, render
|
|
10
10
|
from simo.users.models import ComponentPermission
|
|
11
11
|
from .utils.type_constants import (
|
|
12
|
-
ALL_BASE_TYPES,
|
|
13
|
-
get_all_gateways, get_controller_types_map
|
|
12
|
+
ALL_BASE_TYPES, GATEWAYS_MAP, CONTROLLERS_BY_GATEWAY
|
|
14
13
|
)
|
|
15
14
|
from .models import Instance, Icon, Gateway, Component, Zone, Category
|
|
16
15
|
from .forms import (
|
|
@@ -22,7 +21,6 @@ from .forms import (
|
|
|
22
21
|
)
|
|
23
22
|
from .filters import ZonesFilter
|
|
24
23
|
from .widgets import AdminImageWidget
|
|
25
|
-
from .middleware import get_current_instance
|
|
26
24
|
from simo.conf import dynamic_settings
|
|
27
25
|
|
|
28
26
|
csrf_protect_m = method_decorator(csrf_protect)
|
|
@@ -156,7 +154,7 @@ class GatewayAdmin(admin.ModelAdmin):
|
|
|
156
154
|
}
|
|
157
155
|
if request.session.get('gateway_type'):
|
|
158
156
|
try:
|
|
159
|
-
formClass =
|
|
157
|
+
formClass = GATEWAYS_MAP.get(
|
|
160
158
|
request.session.get('gateway_type')
|
|
161
159
|
).config_form
|
|
162
160
|
except:
|
|
@@ -188,7 +186,7 @@ class GatewayAdmin(admin.ModelAdmin):
|
|
|
188
186
|
)
|
|
189
187
|
except:
|
|
190
188
|
ctx['error'] = '%s gateway already exists!' \
|
|
191
|
-
%
|
|
189
|
+
% GATEWAYS_MAP.get(
|
|
192
190
|
request.session.get('gateway_type'), 'None'
|
|
193
191
|
).name
|
|
194
192
|
else:
|
|
@@ -210,7 +208,7 @@ class GatewayAdmin(admin.ModelAdmin):
|
|
|
210
208
|
|
|
211
209
|
def get_form(self, request, obj=None, change=False, **kwargs):
|
|
212
210
|
if obj:
|
|
213
|
-
gateway_class =
|
|
211
|
+
gateway_class = GATEWAYS_MAP.get(obj.type)
|
|
214
212
|
if gateway_class:
|
|
215
213
|
return gateway_class.config_form
|
|
216
214
|
return BaseGatewayForm
|
|
@@ -323,8 +321,8 @@ class ComponentAdmin(admin.ModelAdmin):
|
|
|
323
321
|
|
|
324
322
|
if request.session.get('add_comp_type'):
|
|
325
323
|
try:
|
|
326
|
-
controller_cls =
|
|
327
|
-
gateway
|
|
324
|
+
controller_cls = CONTROLLERS_BY_GATEWAY.get(
|
|
325
|
+
gateway, {}
|
|
328
326
|
)[request.session['add_comp_type']]
|
|
329
327
|
except:
|
|
330
328
|
request.session.pop('add_comp_type')
|
|
@@ -430,8 +428,8 @@ class ComponentAdmin(admin.ModelAdmin):
|
|
|
430
428
|
def get_form(self, request, obj=None, change=False, **kwargs):
|
|
431
429
|
if obj:
|
|
432
430
|
try:
|
|
433
|
-
self.form =
|
|
434
|
-
obj.gateway
|
|
431
|
+
self.form = CONTROLLERS_BY_GATEWAY.get(
|
|
432
|
+
obj.gateway, {}
|
|
435
433
|
)[obj.controller_uid].config_form
|
|
436
434
|
except KeyError:
|
|
437
435
|
pass
|
simo/core/api.py
CHANGED
|
@@ -14,6 +14,7 @@ from rest_framework.decorators import action
|
|
|
14
14
|
from rest_framework.response import Response as RESTResponse
|
|
15
15
|
from rest_framework.exceptions import ValidationError as APIValidationError
|
|
16
16
|
from simo.core.utils.config_values import ConfigException
|
|
17
|
+
from simo.users.middleware import introduce as introduce_user
|
|
17
18
|
from .models import (
|
|
18
19
|
Instance, Category, Zone, Component, Icon, ComponentHistory,
|
|
19
20
|
HistoryAggregate, Gateway
|
|
@@ -181,7 +182,6 @@ class ComponentViewSet(InstanceMixin, viewsets.ModelViewSet):
|
|
|
181
182
|
return singular
|
|
182
183
|
|
|
183
184
|
def perform_controller_method(self, json_data, component):
|
|
184
|
-
component.prepare_controller()
|
|
185
185
|
for method_name, param in json_data.items():
|
|
186
186
|
if not hasattr(component, method_name):
|
|
187
187
|
raise APIValidationError(
|
|
@@ -583,10 +583,10 @@ class ControllerTypes(InstanceMixin, viewsets.GenericViewSet):
|
|
|
583
583
|
return permissions
|
|
584
584
|
|
|
585
585
|
def list(self, request, *args, **kwargs):
|
|
586
|
-
from .utils.type_constants import
|
|
586
|
+
from .utils.type_constants import CONTROLLER_TYPES_MAP
|
|
587
587
|
data = {}
|
|
588
588
|
|
|
589
|
-
for uid, cls in
|
|
589
|
+
for uid, cls in CONTROLLER_TYPES_MAP.items():
|
|
590
590
|
if cls.gateway_class.name not in data:
|
|
591
591
|
data[cls.gateway_class.name] = []
|
|
592
592
|
data[cls.gateway_class.name].append({
|
simo/core/api_auth.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import json
|
|
2
1
|
from rest_framework.authentication import SessionAuthentication, BasicAuthentication
|
|
3
2
|
from rest_framework import HTTP_HEADER_ENCODING, exceptions
|
|
4
3
|
from simo.users.models import User
|
|
4
|
+
from simo.users.middleware import introduce as introduce_user
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class SecretKeyAuth(BasicAuthentication):
|
|
@@ -15,7 +15,7 @@ class SecretKeyAuth(BasicAuthentication):
|
|
|
15
15
|
|
|
16
16
|
if not user or not user.is_active:
|
|
17
17
|
return
|
|
18
|
-
|
|
18
|
+
introduce_user(user)
|
|
19
19
|
return (user, None)
|
|
20
20
|
|
|
21
21
|
def authenticate_header(self, request):
|
|
@@ -35,6 +35,8 @@ class IsAuthenticated(SessionAuthentication):
|
|
|
35
35
|
if not user.is_authenticated:
|
|
36
36
|
raise exceptions.NotAuthenticated()
|
|
37
37
|
|
|
38
|
+
introduce_user(user)
|
|
39
|
+
|
|
38
40
|
return (user, None)
|
|
39
41
|
|
|
40
42
|
def authenticate_header(self, request):
|
simo/core/controllers.py
CHANGED
|
@@ -222,6 +222,7 @@ class ControllerBase(ABC):
|
|
|
222
222
|
if value != self.component.value:
|
|
223
223
|
self.component.value_previous = self.component.value
|
|
224
224
|
self.component.value = value
|
|
225
|
+
|
|
225
226
|
self.component.change_init_by = None
|
|
226
227
|
self.component.change_init_date = None
|
|
227
228
|
self.component.change_init_to = None
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
simo/core/forms.py
CHANGED
|
@@ -260,10 +260,12 @@ class CompTypeSelectForm(forms.Form):
|
|
|
260
260
|
def __init__(self, gateway, *args, **kwargs):
|
|
261
261
|
super().__init__(*args, **kwargs)
|
|
262
262
|
if gateway:
|
|
263
|
-
from .utils.type_constants import
|
|
264
|
-
self.fields['controller_type'].choices =
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
from .utils.type_constants import CONTROLLERS_BY_GATEWAY
|
|
264
|
+
self.fields['controller_type'].choices = [
|
|
265
|
+
(cls.uid, cls.name) for cls in CONTROLLERS_BY_GATEWAY.get(
|
|
266
|
+
gateway.handler.uid, {}
|
|
267
|
+
).values()
|
|
268
|
+
]
|
|
267
269
|
|
|
268
270
|
|
|
269
271
|
class ComponentAdminForm(forms.ModelForm):
|
|
@@ -300,8 +302,8 @@ class ComponentAdminForm(forms.ModelForm):
|
|
|
300
302
|
self.gateway = self.instance.gateway
|
|
301
303
|
self.controller = self.instance.controller
|
|
302
304
|
else:
|
|
303
|
-
from .utils.type_constants import
|
|
304
|
-
ControllerClass =
|
|
305
|
+
from .utils.type_constants import CONTROLLER_TYPES_MAP
|
|
306
|
+
ControllerClass = CONTROLLER_TYPES_MAP.get(self.controller_uid)
|
|
305
307
|
if ControllerClass:
|
|
306
308
|
self.controller = ControllerClass(self.instance)
|
|
307
309
|
self.gateway = Gateway.objects.filter(
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
simo/core/models.py
CHANGED
|
@@ -217,16 +217,11 @@ class Gateway(DirtyFieldsMixin, models.Model, SimoAdminMixin):
|
|
|
217
217
|
return self.type
|
|
218
218
|
|
|
219
219
|
def __init__(self, *args, **kwargs):
|
|
220
|
-
from .utils.type_constants import
|
|
221
|
-
ALL_GATEWAYS = get_all_gateways()
|
|
222
|
-
GATEWAYS_CHOICES = [
|
|
223
|
-
(slug, cls.name) for slug, cls in ALL_GATEWAYS.items()
|
|
224
|
-
]
|
|
225
|
-
GATEWAYS_CHOICES.sort(key=lambda e: e[1])
|
|
220
|
+
from .utils.type_constants import GATEWAYS_MAP, GATEWAYS_CHOICES
|
|
226
221
|
self._meta.get_field('type').choices = GATEWAYS_CHOICES
|
|
227
222
|
super().__init__(*args, **kwargs)
|
|
228
223
|
|
|
229
|
-
gateway_class =
|
|
224
|
+
gateway_class = GATEWAYS_MAP.get(self.type)
|
|
230
225
|
if gateway_class:
|
|
231
226
|
self.handler = gateway_class(self)
|
|
232
227
|
if hasattr(self.handler, 'run'):
|
|
@@ -272,8 +267,8 @@ class Gateway(DirtyFieldsMixin, models.Model, SimoAdminMixin):
|
|
|
272
267
|
|
|
273
268
|
def process_discovery(self, data):
|
|
274
269
|
self.refresh_from_db()
|
|
275
|
-
from .utils.type_constants import
|
|
276
|
-
ControllerClass =
|
|
270
|
+
from .utils.type_constants import CONTROLLER_TYPES_MAP
|
|
271
|
+
ControllerClass = CONTROLLER_TYPES_MAP.get(
|
|
277
272
|
self.discovery['controller_uid']
|
|
278
273
|
)
|
|
279
274
|
if ControllerClass and hasattr(
|
|
@@ -403,18 +398,7 @@ def is_in_alarm(self):
|
|
|
403
398
|
|
|
404
399
|
def __init__(self, *args, **kwargs):
|
|
405
400
|
super().__init__(*args, **kwargs)
|
|
406
|
-
|
|
407
|
-
if self.instance_methods:
|
|
408
|
-
custom_methods = {}
|
|
409
|
-
funcType = type(self.save)
|
|
410
|
-
try:
|
|
411
|
-
exec(self.instance_methods, None, custom_methods)
|
|
412
|
-
except:
|
|
413
|
-
pass
|
|
414
|
-
for key, val in custom_methods.items():
|
|
415
|
-
if not callable(val):
|
|
416
|
-
continue
|
|
417
|
-
setattr(self, key, funcType(val, self))
|
|
401
|
+
self.prepare_controller()
|
|
418
402
|
|
|
419
403
|
def __str__(self):
|
|
420
404
|
if self.zone:
|
|
@@ -424,40 +408,40 @@ def is_in_alarm(self):
|
|
|
424
408
|
@cached_property
|
|
425
409
|
def controller(self):
|
|
426
410
|
from .utils.type_constants import (
|
|
427
|
-
|
|
428
|
-
|
|
411
|
+
CONTROLLERS_BY_GATEWAY,
|
|
412
|
+
CONTROLLER_TYPES_CHOICES
|
|
429
413
|
)
|
|
430
|
-
self._meta.get_field('controller_uid').choices =
|
|
431
|
-
get_controller_types_choices()
|
|
414
|
+
self._meta.get_field('controller_uid').choices = CONTROLLER_TYPES_CHOICES
|
|
432
415
|
if self.controller_uid:
|
|
433
416
|
controller_cls = None
|
|
434
|
-
if self.id and not 'test' in sys.argv:
|
|
435
|
-
try:
|
|
436
|
-
controller_cls = cache.get('c_%d_contr_cls' % self.id)
|
|
437
|
-
except:
|
|
438
|
-
pass
|
|
439
417
|
if not controller_cls:
|
|
440
|
-
controller_cls =
|
|
441
|
-
self.gateway
|
|
418
|
+
controller_cls = CONTROLLERS_BY_GATEWAY.get(
|
|
419
|
+
self.gateway.type, {}
|
|
442
420
|
).get(self.controller_uid)
|
|
443
|
-
if controller_cls and self.id and not 'test' in sys.argv:
|
|
444
|
-
cache.set(
|
|
445
|
-
'c_%d_contr_cls' % self.id,
|
|
446
|
-
controller_cls, None
|
|
447
|
-
)
|
|
448
421
|
if controller_cls:
|
|
449
422
|
return controller_cls(self)
|
|
450
423
|
|
|
451
424
|
def prepare_controller(self):
|
|
452
|
-
if
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
425
|
+
if self.controller:
|
|
426
|
+
controller_methods = [m for m in inspect.getmembers(
|
|
427
|
+
self.controller, predicate=inspect.ismethod
|
|
428
|
+
) if not m[0].startswith('_')]
|
|
429
|
+
for method in controller_methods:
|
|
430
|
+
setattr(self, method[0], method[1])
|
|
431
|
+
if not self.id:
|
|
432
|
+
self.value = self.controller.default_value
|
|
433
|
+
|
|
434
|
+
if self.instance_methods:
|
|
435
|
+
custom_methods = {}
|
|
436
|
+
funcType = type(self.save)
|
|
437
|
+
try:
|
|
438
|
+
exec(self.instance_methods, None, custom_methods)
|
|
439
|
+
except:
|
|
440
|
+
pass
|
|
441
|
+
for key, val in custom_methods.items():
|
|
442
|
+
if not callable(val):
|
|
443
|
+
continue
|
|
444
|
+
setattr(self, key, funcType(val, self))
|
|
461
445
|
|
|
462
446
|
def get_socket_url(self):
|
|
463
447
|
return reverse_lazy(
|
simo/core/serializers.py
CHANGED
|
@@ -284,10 +284,9 @@ class ComponentSerializer(FormSerializer):
|
|
|
284
284
|
def set_form_cls(self):
|
|
285
285
|
self.Meta.form = ComponentAdminForm
|
|
286
286
|
if not isinstance(self.instance, Iterable):
|
|
287
|
-
from .utils.type_constants import
|
|
288
|
-
controllers_map = get_controller_types_map()
|
|
287
|
+
from .utils.type_constants import CONTROLLER_TYPES_MAP
|
|
289
288
|
if not self.instance:
|
|
290
|
-
controller =
|
|
289
|
+
controller = CONTROLLER_TYPES_MAP.get(
|
|
291
290
|
#'simo.generic.controllers.AlarmClock'
|
|
292
291
|
self.context['request'].META.get('HTTP_CONTROLLER')
|
|
293
292
|
)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -19,20 +19,32 @@ def get_controller_types_map(gateway=None):
|
|
|
19
19
|
except ModuleNotFoundError:
|
|
20
20
|
continue
|
|
21
21
|
for cls_name, cls in configs.__dict__.items():
|
|
22
|
-
if inspect.isclass(cls)
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
if not inspect.isclass(cls):
|
|
23
|
+
continue
|
|
24
|
+
if not issubclass(cls, ControllerBase):
|
|
25
|
+
continue
|
|
26
|
+
if inspect.isabstract(cls):
|
|
27
|
+
continue
|
|
28
|
+
if gateway:
|
|
29
|
+
if issubclass(gateway, BaseGatewayHandler) \
|
|
30
|
+
or isinstance(gateway, BaseGatewayHandler):
|
|
31
|
+
if gateway.uid != cls.gateway_class.uid:
|
|
32
|
+
continue
|
|
33
|
+
else:
|
|
25
34
|
try:
|
|
26
|
-
same = gateway.
|
|
35
|
+
same = gateway.handler.uid == cls.gateway_class.uid
|
|
27
36
|
except:
|
|
28
37
|
continue
|
|
29
38
|
else:
|
|
30
39
|
if not same:
|
|
31
40
|
continue
|
|
32
|
-
|
|
41
|
+
controllers_map[cls.uid] = cls
|
|
33
42
|
return controllers_map
|
|
34
43
|
|
|
35
44
|
|
|
45
|
+
CONTROLLER_TYPES_MAP = get_controller_types_map()
|
|
46
|
+
|
|
47
|
+
|
|
36
48
|
def get_controller_types_choices(gateway=None):
|
|
37
49
|
choices = []
|
|
38
50
|
for controller_cls in get_controller_types_map(gateway).values():
|
|
@@ -40,11 +52,8 @@ def get_controller_types_choices(gateway=None):
|
|
|
40
52
|
return choices
|
|
41
53
|
|
|
42
54
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
# (slug, cls.name) for slug, cls in ALL_CONTROLLER_TYPES.items()
|
|
46
|
-
# ]
|
|
47
|
-
# CONTROLLER_TYPE_CHOICES.sort(key=lambda e: e[0])
|
|
55
|
+
CONTROLLER_TYPES_CHOICES = get_controller_types_choices()
|
|
56
|
+
|
|
48
57
|
|
|
49
58
|
def get_all_gateways():
|
|
50
59
|
all_gateways = {}
|
|
@@ -65,13 +74,25 @@ def get_all_gateways():
|
|
|
65
74
|
return all_gateways
|
|
66
75
|
|
|
67
76
|
|
|
77
|
+
GATEWAYS_MAP = get_all_gateways()
|
|
78
|
+
|
|
79
|
+
|
|
68
80
|
def get_gateway_choices():
|
|
69
81
|
choices = [
|
|
70
|
-
(slug, cls.name) for slug, cls in
|
|
82
|
+
(slug, cls.name) for slug, cls in GATEWAYS_MAP.items()
|
|
71
83
|
]
|
|
72
84
|
choices.sort(key=lambda e: e[1])
|
|
73
85
|
return choices
|
|
74
86
|
|
|
87
|
+
GATEWAYS_CHOICES = get_gateway_choices()
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
CONTROLLERS_BY_GATEWAY = {}
|
|
91
|
+
for gateway_slug, gateway_cls in GATEWAYS_MAP.items():
|
|
92
|
+
CONTROLLERS_BY_GATEWAY[gateway_slug] = {}
|
|
93
|
+
for ctrl_uid, ctrl_cls in get_controller_types_map(gateway_cls).items():
|
|
94
|
+
CONTROLLERS_BY_GATEWAY[gateway_slug][ctrl_uid] = ctrl_cls
|
|
95
|
+
|
|
75
96
|
|
|
76
97
|
ALL_BASE_TYPES = {}
|
|
77
98
|
for name, app in apps.app_configs.items():
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
simo/fleet/migrations/__pycache__/0028_remove_i2cinterface_scl_pin_no_and_more.cpython-38.pyc
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
simo/fleet/models.py
CHANGED
|
@@ -166,7 +166,8 @@ class Colonel(DirtyFieldsMixin, models.Model):
|
|
|
166
166
|
@transaction.atomic
|
|
167
167
|
def rebuild_occupied_pins(self):
|
|
168
168
|
for pin in ColonelPin.objects.filter(colonel=self):
|
|
169
|
-
pin.
|
|
169
|
+
pin.occupied_by_id = None
|
|
170
|
+
pin.occupied_by_content_type = None
|
|
170
171
|
pin.save()
|
|
171
172
|
|
|
172
173
|
for component in self.components.all():
|
|
Binary file
|
|
Binary file
|