locky 2 лет назад
Родитель
Сommit
0ed43caa3b
3 измененных файлов с 5 добавлено и 203 удалено
  1. 5 15
      azoauth/urls.py
  2. 0 93
      controller/distribution.py
  3. 0 95
      controller/index.py

+ 5 - 15
azoauth/urls.py

@@ -17,7 +17,6 @@ from django.conf.urls import url
 from django.contrib import admin
 from django.urls import path, re_path
 from controller import index, beian
-from controller import distribution
 from controller import deviceStatus
 
 urlpatterns = [
@@ -27,24 +26,15 @@ urlpatterns = [
     path('oa2/authLoocam', index.authLoocamView.as_view()),
     path('oa2/login', index.loginHandleView.as_view()),
     path('oa2/token', index.oa2TokenView.as_view()),
-    path('oa2/rtspStart', index.oa2RtspStartView.as_view()),
+
+    # 搜索设备
     path('oa2/discoverydevice', index.oa2DiscoveryDevice.as_view()),
     path('oa2/discoveryswitch', index.oa2DiscoverySwitch.as_view()),
-    # 新增停流
-    path('oa2/stoprtsp', index.testRunSendStop),
-    # 新增设备推流测试
-    path('oa2/runstream', index.testRunStream),
-    # 测试服务器是否正常接口
-    path('oa2/test', index.test),
-    # 负载均衡接口test(后期可删)
-    path('oa2/loadserver', index.loadBalancingServer),
-    # 查询存储alexa连接数
-    path('distribution/select', distribution.selectConnectNum.as_view()),       # 查询连接数并返回url
-    path('distribution/storage', distribution.storageConnectNum.as_view()),     # 存储连接数
+
+    path('oa2/rtspStart', index.oa2RtspStartView.as_view()),            # 通知摄像头设备推流
     path('oa2/powerController', index.powerController.as_view()),       # 控制智能插座开关
 
-    # 更新设备状态到alexa网关.
-    url(r'^deviceStatus/(?P<operation>.*)$', deviceStatus.deviceStatus.as_view()),
+    url(r'^deviceStatus/(?P<operation>.*)$', deviceStatus.deviceStatus.as_view()),  # 更新设备信息等接口
     url(r'^vseesTest/(?P<operation>.*)', index.VesseTest.as_view()),  # test
 
     # 域名备案网站

+ 0 - 93
controller/distribution.py

@@ -1,93 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""
-"""
-import json
-import time
-import requests
-from django.views.generic import TemplateView
-from django.shortcuts import render_to_response
-from django.http import JsonResponse
-from object.ResObject import ResObject
-import subprocess
-# from gevent.pool import Pool
-from model.models import UserModel,UidRtspModel
-from object.tkObject import tkObject
-from service.CommonService import CommonService
-from object.RedisObject import RedisObject
-
-rtspServer = "rtsp.zositech.org,3.16.66.144"
-
-class selectConnectNum(TemplateView):
-    def post(self, request, *args, **kwargs):
-        request.encoding = 'utf-8'
-        request_dict = json.loads(request.body.decode('utf-8'))
-        return self.select(request_dict)
-
-    def get(self, request, *args, **kwargs):
-        request.encoding = 'utf-8'
-        request_dict = request.GET
-        return self.select(request_dict)
-
-    # def select(self, request_dict):
-    #     uid = 'xixixixiixixixixix'
-    #     response = ResObject()
-    #     redisObj = RedisObject(db=1)
-    #     rtko = tkObject(rank=1)
-    #     rtsp_stream = rtko.encrypt(data=uid)
-    #     res = redisObj.z_revrange('url')
-    #     url = res[0]
-    #     rtspUrl = str(url) + rtsp_stream
-    #     return response.json(0, res=rtspUrl)
-    def select(self, request_dict):
-        response = ResObject()
-        redisObj = RedisObject(db=1)
-        urls = rtspServer.split(',')
-        httpPrefix = 'http://'
-        rtspPrefix = 'rtsp://'
-        postfix = ':10008/api/v1/pushers'
-        redisdata=[]
-        for url in urls:
-            res = redisObj.get_data(url)
-            redisdata.append(res)
-        return JsonResponse({'msg': redisdata, 'code': 0})
-
-class storageConnectNum(TemplateView):
-    def post(self, request, *args, **kwargs):
-        request.encoding = 'utf-8'
-        request_dict = json.loads(request.body.decode('utf-8'))
-        return self.storage(request_dict)
-
-    def get(self, request, *args, **kwargs):
-        request.encoding = 'utf-8'
-        request_dict = request.GET
-        return self.storage(request_dict)
-
-    def storage(self, request_dict):
-        response = ResObject()
-        redisObj = RedisObject(db=1)
-        urls = rtspServer.split(',')
-        httpPrefix = 'http://'
-        # rtspPrefix = 'rtsp://'
-        postfix = ':10008/api/v1/pushers'
-
-        for url in urls:
-            apiUrl = httpPrefix + url + postfix
-            try:
-                selectRtsp = requests.get(url=apiUrl, timeout=5)
-                connectNum = selectRtsp.json()['total']
-            except Exception as e:
-                connectNum = -1
-            redisObj.set_data(url, connectNum)
-        return response.json(0, res={'connectNum':connectNum})
-
-
-
-
-
-
-
-
-
-
-

+ 0 - 95
controller/index.py

@@ -626,101 +626,6 @@ class oa2DiscoverySwitch(TemplateView):
         return JsonResponse(res_json, safe=False)
 
 
-# 新增
-def testRunSendStop(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} 0".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 False
-    else:
-        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)
-    time1 = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
-    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)
-        time2 = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
-        # print("时间:%s"%datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3])
-    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 JsonResponse({'msg': "star is %s" % time1 + ",end is %s" % time2, 'code': 0})
-        # return JsonResponse({'msg': "run stream", 'code': 0})
-
-
-# 测试是否正常接口
-def test(request):
-    return JsonResponse({'msg': 'Server running normal', 'code': 0})
-
-
-# test接口
-def loadBalancingServer(request):
-    try:
-        res1 = requests.get('http://rtsp.zositech.com:10008/api/v1/players', timeout=5)
-    except Exception as e:
-        res1 = -1
-
-    time1 = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
-    print("时间1:%s" % time1)
-    # ---------压测接口demo------------
-    redisObj = RedisObject(db=1)
-    key1 = 'rtsp.zositech.com'
-    key2 = '18.222.107.129'
-    redis_data1 = redisObj.get_data(key1)
-    redis_data2 = redisObj.get_data(key2)
-    if redis_data1 and redis_data2:
-        print("进缓存")
-        mm = min(redis_data1, redis_data2)
-        if redis_data1 == mm and redis_data1 != -1:
-            RESP_SERVER_DOMAIN = RESP_SERVER_DOMAIN_DATA['EN']
-        elif redis_data2 == mm and redis_data2 != -1:
-            RESP_SERVER_DOMAIN = RESP_SERVER_DOMAIN_DATA['EN1']
-    # ---------/压测demo------------
-    # else:
-    #     print("第一次")
-    #     res1 = requests.get('http://rtsp.zositech.com:10008/api/v1/players', timeout=0.001)
-    #     res2 = requests.get('http://18.222.107.129:10008/api/v1/players', timeout=0.001)
-    #     res_data1 = res1.json()
-    #     res_data2 = res1.json()
-    #     total1 = res_data1['total']
-    #     total2 = res_data2['total']
-    #     print(total1)
-    #     print(total2)
-    #     redisObj8.set_data(key=key1, val=total1, expire=30)
-    #     redisObj8.set_data(key=key2, val=total2, expire=30)
-    #     mm=min(total1,total2)
-    #     print(mm)
-    #     if total1 == mm:
-    #         RESP_SERVER_DOMAIN = RESP_SERVER_DOMAIN_DATA['EN']
-    #     else:
-    #         RESP_SERVER_DOMAIN = RESP_SERVER_DOMAIN_DATA['EN1']
-    return JsonResponse({'msg': 'The number of people online is :%s' % res1, 'code': 0})
-
-
 class powerController(TemplateView):
     def post(self, request, *args, **kwargs):
         request.encoding = 'utf-8'