chanjunkai 5 éve
szülő
commit
a5c3638bef
2 módosított fájl, 25 hozzáadás és 1 törlés
  1. 3 1
      azoauth/urls.py
  2. 22 0
      controller/index.py

+ 3 - 1
azoauth/urls.py

@@ -25,8 +25,10 @@ urlpatterns = [
     path('oa2/token', index.oa2TokenView.as_view()),
     path('oa2/rtspStart', index.oa2RtspStartView.as_view()),
     path('oa2/discoverydevice', index.oa2DiscoveryDevice.as_view()),
-    #新增
+    #新增停流
     path('oa2/stoprtsp', index.testRunSendStop),
+    #新增设备推流测试
+    path('oa2/runstream', index.testRunStream),
     #测试服务器是否正常接口
     path('oa2/test', index.test),
 

+ 22 - 0
controller/index.py

@@ -427,6 +427,28 @@ def testRunSendStop(request):
         print("back0----", back[0].decode())  # 注意需要进行解码操作,默认输出的是字节
         print("back1----", back[1].decode())  # back是一个元祖,可以通过元祖取值的方式获取结果
         return JsonResponse({'msg': 'stop Stream', 'code': 0})
+
+def testRunStream(request):
+    request.encoding = 'utf-8'
+    if request.method == 'GET':
+        request_dict = request.GET
+    UID=request_dict.get('UID', None)
+    PWD=request_dict.get('PWD', None)
+    MSG=request_dict.get('MSG', None)
+    command = "./pushtool {UID} {PWD} {MSG} 1".format(UID=UID, PWD=PWD, MSG=MSG)
+    print('command=>{command}'.format(command=command))
+    try:
+        back = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE). \
+            communicate(timeout=10)
+    except Exception as e:
+        return repr(e)
+    else:
+        print("back0----", back[0].decode())  # 注意需要进行解码操作,默认输出的是字节
+        print("back1----", back[1].decode())  # back是一个元祖,可以通过元祖取值的方式获取结果
+        return str(back[0].decode()) + str(back[1].decode())
+        return True
+
+
 #测试是否正常接口
 def test(request):
     return JsonResponse({'msg': 'Server running normal', 'code': 0})