|
@@ -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'
|