|
@@ -27,7 +27,6 @@ from object.RedisObject import RedisObject
|
|
from azoauth.config import *
|
|
from azoauth.config import *
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
class authView(TemplateView):
|
|
class authView(TemplateView):
|
|
def post(self, request, *args, **kwargs):
|
|
def post(self, request, *args, **kwargs):
|
|
request.encoding = 'utf-8'
|
|
request.encoding = 'utf-8'
|
|
@@ -79,7 +78,7 @@ class loginHandleView(TemplateView):
|
|
# 返回code
|
|
# 返回code
|
|
print(user)
|
|
print(user)
|
|
print(pwd)
|
|
print(pwd)
|
|
- auth_request_url = '{SERVER_PREFIX}/oalexa/auth'.\
|
|
|
|
|
|
+ auth_request_url = '{SERVER_PREFIX}/oalexa/auth'. \
|
|
format(SERVER_PREFIX=SERVER_PREFIX)
|
|
format(SERVER_PREFIX=SERVER_PREFIX)
|
|
print(auth_request_url)
|
|
print(auth_request_url)
|
|
# auth_request_url = 'http://192.168.136.40:8077/oalexa/auth'
|
|
# auth_request_url = 'http://192.168.136.40:8077/oalexa/auth'
|
|
@@ -214,7 +213,7 @@ class oa2RtspStartView(TemplateView):
|
|
if user_qs.exists():
|
|
if user_qs.exists():
|
|
print('select by mysql data')
|
|
print('select by mysql data')
|
|
# userID = user_qs[0].userID
|
|
# userID = user_qs[0].userID
|
|
- ur_qs = UidRtspModel.objects.filter(uid=id).values('uid', 'nick', 'rtsp_url', 'password','region')
|
|
|
|
|
|
+ ur_qs = UidRtspModel.objects.filter(uid=id).values('uid', 'nick', 'rtsp_url', 'password', 'region')
|
|
# ur_qs = UidRtspModel.objects.filter(usermodel__userID=userID,uid=)
|
|
# ur_qs = UidRtspModel.objects.filter(usermodel__userID=userID,uid=)
|
|
UID = ur_qs[0]['uid']
|
|
UID = ur_qs[0]['uid']
|
|
region = ur_qs[0]['region']
|
|
region = ur_qs[0]['region']
|
|
@@ -259,7 +258,7 @@ class oa2RtspStartView(TemplateView):
|
|
'protocols': ['RTSP'],
|
|
'protocols': ['RTSP'],
|
|
'authorizationTypes': ['NONE'],
|
|
'authorizationTypes': ['NONE'],
|
|
'uri': rtsp_uri,
|
|
'uri': rtsp_uri,
|
|
- 'msg':send_flag
|
|
|
|
|
|
+ 'msg': send_flag
|
|
}
|
|
}
|
|
# time.sleep(1.5)
|
|
# time.sleep(1.5)
|
|
redisObj.set_data(key=key, val=str(res_json), expire=60)
|
|
redisObj.set_data(key=key, val=str(res_json), expire=60)
|
|
@@ -268,31 +267,32 @@ class oa2RtspStartView(TemplateView):
|
|
return JsonResponse({'msg': 'wrong'})
|
|
return JsonResponse({'msg': 'wrong'})
|
|
|
|
|
|
def runReqRtspMsg(self, UID, PWD, MSG):
|
|
def runReqRtspMsg(self, UID, PWD, MSG):
|
|
- request_url = 'http://localhost:5000/?UID={UID}&MSG={MSG}&CMD=1&PWD={PWD}'.\
|
|
|
|
- format(UID=UID,PWD=PWD,MSG=MSG)
|
|
|
|
|
|
+ request_url = 'http://localhost:5000/?UID={UID}&MSG={MSG}&CMD=1&PWD={PWD}'. \
|
|
|
|
+ format(UID=UID, PWD=PWD, MSG=MSG)
|
|
res = requests.get(url=request_url)
|
|
res = requests.get(url=request_url)
|
|
print(res)
|
|
print(res)
|
|
return True
|
|
return True
|
|
|
|
+
|
|
def runSendRtspMsg(self, UID, PWD, MSG):
|
|
def runSendRtspMsg(self, UID, PWD, MSG):
|
|
# return True
|
|
# return True
|
|
command = "./pushtool {UID} {PWD} {MSG} 1".format(UID=UID, PWD=PWD, MSG=MSG)
|
|
command = "./pushtool {UID} {PWD} {MSG} 1".format(UID=UID, PWD=PWD, MSG=MSG)
|
|
print('command=>{command}'.format(command=command))
|
|
print('command=>{command}'.format(command=command))
|
|
try:
|
|
try:
|
|
- back = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).\
|
|
|
|
|
|
+ back = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE). \
|
|
communicate(timeout=10)
|
|
communicate(timeout=10)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return repr(e)
|
|
return repr(e)
|
|
else:
|
|
else:
|
|
print("back0----", back[0].decode()) # 注意需要进行解码操作,默认输出的是字节
|
|
print("back0----", back[0].decode()) # 注意需要进行解码操作,默认输出的是字节
|
|
print("back1----", back[1].decode()) # back是一个元祖,可以通过元祖取值的方式获取结果
|
|
print("back1----", back[1].decode()) # back是一个元祖,可以通过元祖取值的方式获取结果
|
|
- return str(back[0].decode())+str(back[1].decode())
|
|
|
|
|
|
+ return str(back[0].decode()) + str(back[1].decode())
|
|
return True
|
|
return True
|
|
|
|
|
|
def runSendStop(self, UID, PWD, MSG):
|
|
def runSendStop(self, UID, PWD, MSG):
|
|
command = "./pushtool {UID} {PWD} {MSG} 0".format(UID=UID, PWD=PWD, MSG=MSG)
|
|
command = "./pushtool {UID} {PWD} {MSG} 0".format(UID=UID, PWD=PWD, MSG=MSG)
|
|
print('command=>{command}'.format(command=command))
|
|
print('command=>{command}'.format(command=command))
|
|
try:
|
|
try:
|
|
- back = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).\
|
|
|
|
|
|
+ back = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE). \
|
|
communicate(timeout=10)
|
|
communicate(timeout=10)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return False
|
|
return False
|
|
@@ -338,16 +338,17 @@ class oa2DiscoveryDevice(TemplateView):
|
|
uid_rtsp_id_list = []
|
|
uid_rtsp_id_list = []
|
|
for uid_a in uid_arr:
|
|
for uid_a in uid_arr:
|
|
uid = uid_a['uid']
|
|
uid = uid_a['uid']
|
|
|
|
+ if uid_a['region'] == 'CN':
|
|
|
|
+ region = 'CN'
|
|
|
|
+ else:
|
|
|
|
+ region = 'EN'
|
|
rtsp_url = rtko.encrypt(data=uid)
|
|
rtsp_url = rtko.encrypt(data=uid)
|
|
try:
|
|
try:
|
|
uid_rtsp_qs = UidRtspModel.objects.get(uid=uid)
|
|
uid_rtsp_qs = UidRtspModel.objects.get(uid=uid)
|
|
except UidRtspModel.DoesNotExist:
|
|
except UidRtspModel.DoesNotExist:
|
|
- uid_rtsp_qs = UidRtspModel.objects.create(uid=uid_a['uid'],
|
|
|
|
- password=uid_a['password'],
|
|
|
|
- nick=uid_a['nick'],
|
|
|
|
- addTime=now_time,
|
|
|
|
- updTime=now_time,
|
|
|
|
- rtsp_url=rtsp_url,
|
|
|
|
|
|
+ uid_rtsp_qs = UidRtspModel.objects.create(uid=uid_a['uid'], password=uid_a['password'],
|
|
|
|
+ nick=uid_a['nick'], addTime=now_time,
|
|
|
|
+ updTime=now_time, rtsp_url=rtsp_url,
|
|
region=region)
|
|
region=region)
|
|
else:
|
|
else:
|
|
# if uid_rtsp_qs.password != uid_a['password']:
|
|
# if uid_rtsp_qs.password != uid_a['password']:
|