add json_wb in snapshot
This commit is contained in:
parent
45a787aa39
commit
e7e595f2c2
|
@ -305,6 +305,7 @@ class UploadSnapshotForm(SnapshotMixin, FlaskForm):
|
|||
devices = []
|
||||
self.tmp_snapshots = app.config['TMP_SNAPSHOTS']
|
||||
for filename, snapshot_json in self.snapshots:
|
||||
self.json_wb = copy.copy(snapshot_json)
|
||||
path_snapshot = save_json(snapshot_json, self.tmp_snapshots, g.user.email)
|
||||
debug = snapshot_json.pop('debug', None)
|
||||
self.version = snapshot_json.get('schema_api')
|
||||
|
|
|
@ -699,6 +699,12 @@ class Snapshot(JoinedWithOneDeviceMixin, ActionWithOneDevice):
|
|||
return
|
||||
|
||||
json_hw = {}
|
||||
json_wb = copy.copy(json_wb)
|
||||
|
||||
if json_wb.get('device', {}).get('system_uuid'):
|
||||
system_uuid = str(json_wb['device']['system_uuid'])
|
||||
json_wb['device']['system_uuid'] = system_uuid
|
||||
|
||||
for k, v in json_wb.items():
|
||||
if k == 'device':
|
||||
json_hw['device'] = copy.copy(v)
|
||||
|
@ -755,8 +761,10 @@ class Snapshot(JoinedWithOneDeviceMixin, ActionWithOneDevice):
|
|||
return snapshots and 'update' or 'new_device'
|
||||
|
||||
def register_passport_dlt(self):
|
||||
import pdb; pdb.set_trace()
|
||||
if 'trublo' not in app.blueprints.keys() or not self.hid:
|
||||
import pdb
|
||||
|
||||
pdb.set_trace()
|
||||
if 'trublo' not in app.blueprints.keys() or not self.device.hid:
|
||||
return
|
||||
|
||||
if not session.get('token_dlt'):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
""" This is the view for Snapshots """
|
||||
|
||||
import copy
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
|
@ -121,6 +122,7 @@ class SnapshotMixin:
|
|||
snapshot.device.set_hid()
|
||||
snapshot.device.binding.device.set_hid()
|
||||
|
||||
snapshot.create_json_hw(self.json_wb)
|
||||
snapshot.device.register_dlt()
|
||||
snapshot.register_passport_dlt()
|
||||
|
||||
|
@ -214,6 +216,7 @@ class SnapshotView(SnapshotMixin):
|
|||
self.schema = schema
|
||||
self.resource_def = resource_def
|
||||
self.tmp_snapshots = app.config['TMP_SNAPSHOTS']
|
||||
self.json_wb = copy.copy(snapshot_json)
|
||||
self.path_snapshot = save_json(snapshot_json, self.tmp_snapshots, g.user.email)
|
||||
self.version = snapshot_json.get('version')
|
||||
self.uuid = snapshot_json.get('uuid')
|
||||
|
|
|
@ -777,10 +777,6 @@ class Device(Thing):
|
|||
).first()
|
||||
|
||||
def set_hid(self):
|
||||
with suppress(TypeError):
|
||||
self.hid = Naming.hid(
|
||||
self.type, self.manufacturer, self.model, self.serial_number
|
||||
)
|
||||
if 'property_hid' in app.blueprints.keys():
|
||||
try:
|
||||
from modules.device.utils import set_hid
|
||||
|
@ -887,7 +883,9 @@ class Device(Thing):
|
|||
return types.get(self.type, '')
|
||||
|
||||
def register_dlt(self):
|
||||
import pdb; pdb.set_trace()
|
||||
import pdb
|
||||
|
||||
pdb.set_trace()
|
||||
if 'trublo' not in app.blueprints.keys() or not self.hid:
|
||||
return
|
||||
|
||||
|
|
Reference in New Issue