1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
- @AUTHOR: ASJRD018
- @NAME: AnsjerPush
- @software: PyCharm
- @DATE: 2020/2/14 13:54
- @Version: python3.6
- @MODIFY DECORD:ansjer dev
- @file: ShadowController.py
- @Contact: chanjunkai@163.com
- """
- # 测试环境
- # test.shadow.dvema.com
- # 生产环境
- # shadow.dvema.com
- # 设备影子更新
- import logging
- import time
- import requests
- from django.http import JsonResponse
- from ratelimit.decorators import ratelimit
- from AnsjerPush.config import SERVER_TYPE
- from Model.models import Device_Info, UidSetModel, UID_Preview, VoicePromptModel, UID_Bucket, UidChannelSetModel, \
- AiService, CountryModel
- from Object.ETkObject import ETkObject
- from Object.ResponseObject import ResponseObject
- from Service.CommonService import CommonService
- def generate_utk(request):
- request.encoding = 'utf-8'
- response = ResponseObject()
- if request.method == 'GET':
- request_dict = request.GET
- elif request.method == 'POST':
- request_dict = request.POST
- else:
- return response.json(444, 'wrong method')
- username = request_dict.get('username', None)
- password = request_dict.get('password', None)
- uid = request_dict.get('uid', None)
- if username and password:
- if username == 'debug_user' and password == 'debug_password':
- # utko = UidTokenObject()
- # # right
- # utko.generate(data={'uid': uid})
- etkObj = ETkObject(etk='')
- etk = etkObj.encrypt(uid)
- return response.json(0, {'etk': etk})
- else:
- return response.json(404)
- else:
- return response.json(444, 'username password')
- # 设备影子更新
- def update_device_shadow(request):
- return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
|