|
@@ -58,33 +58,14 @@ class EquipmentManagerV3(View):
|
|
|
Type = request_dict.get('Type', None)
|
|
|
ChannelIndex = request_dict.get('ChannelIndex', None)
|
|
|
|
|
|
- file_path = '/'.join((BASE_DIR, 'static/test.log'))
|
|
|
- file = open(file_path, 'a+')
|
|
|
- file.write(UID)
|
|
|
-
|
|
|
if all([UID, NickName, View_Account, Type, ChannelIndex]):
|
|
|
tko = TokenObject(token)
|
|
|
- file.write('in all------------------------------')
|
|
|
+
|
|
|
response.lang = tko.lang
|
|
|
if tko.code == 0:
|
|
|
userID = tko.userID
|
|
|
re_uid = re.compile(r'^[A-Za-z0-9]{20}$')
|
|
|
if re_uid.match(UID):
|
|
|
- try:
|
|
|
- file.write(UID)
|
|
|
- file.write('------unEnter--')
|
|
|
- file.write('\n')
|
|
|
- file.write(userID)
|
|
|
- file.write('\n')
|
|
|
- file.write(NickName)
|
|
|
- file.write('\n')
|
|
|
- file.flush()
|
|
|
- file.close()
|
|
|
-
|
|
|
- asy = threading.Thread(target=ModelService.notify_alexa_add, args=(UID, userID, NickName))
|
|
|
- asy.start()
|
|
|
- except Exception as e:
|
|
|
- print(repr(e))
|
|
|
is_exist = Device_Info.objects.filter(UID=UID, userID_id=userID)
|
|
|
if is_exist:
|
|
|
# 判断设备是否已存在
|
|
@@ -118,8 +99,12 @@ class EquipmentManagerV3(View):
|
|
|
View_Password=View_Password, Type=Type, ChannelIndex=ChannelIndex)
|
|
|
userDevice.save()
|
|
|
|
|
|
- # if not us_qs.exists():
|
|
|
- # us_qs = UidSetModel.objects.filter(uid=UID)
|
|
|
+ if not us_qs.exists():
|
|
|
+ us_qs = UidSetModel.objects.filter(uid=UID)
|
|
|
+
|
|
|
+ if us_qs.exists() and us_qs[0].is_alexa == 1:
|
|
|
+ asy = threading.Thread(target=ModelService.notify_alexa_add, args=(UID, userID, NickName))
|
|
|
+ asy.start()
|
|
|
|
|
|
# redisObj = RedisObject(db=8)
|
|
|
# redisObj.del_data(key='uid_qs_' + userID)
|
|
@@ -174,11 +159,6 @@ class EquipmentManagerV3(View):
|
|
|
else:
|
|
|
qs = Device_Info.objects.filter(userID_id=userID, id=id)
|
|
|
res = CommonService.qs_to_dict(qs)
|
|
|
- file_path = '/'.join((BASE_DIR, 'static/test.log'))
|
|
|
- file = open(file_path, 'a+')
|
|
|
-
|
|
|
- file.write(qs[0].UID)
|
|
|
- file.write('------modifyEnter--')
|
|
|
if qs.exists():
|
|
|
uid = qs[0].UID
|
|
|
nickname = qs[0].NickName
|
|
@@ -200,15 +180,7 @@ class EquipmentManagerV3(View):
|
|
|
UidSetModel.objects.create(**uid_set_create_dict)
|
|
|
di_qs = Device_Info.objects.filter(UID=uid)
|
|
|
di_qs.update(NickName=nickname)
|
|
|
- if deviceData is not None and deviceData.__contains__('NickName') and us_qs[0].is_alexa:
|
|
|
-
|
|
|
- file.write('\n')
|
|
|
- file.write(userID)
|
|
|
- file.write('\n')
|
|
|
- file.write(nickname)
|
|
|
- file.write('\n')
|
|
|
- file.flush()
|
|
|
- file.close()
|
|
|
+ if deviceData is not None and deviceData.__contains__('NickName') and us_qs[0].is_alexa == 1:
|
|
|
|
|
|
asy = threading.Thread(target=ModelService.notify_alexa_add, args=(uid, userID, nickname))
|
|
|
asy.start()
|