chenjunkai преди 6 години
родител
ревизия
9cfd11e4d8
променени са 8 файла, в които са добавени 43 реда и са изтрити 80 реда
  1. 22 4
      Ansjer/test/oss.py
  2. 13 12
      Controller/AdminManage.py
  3. 1 2
      Controller/OTAEquipment.py
  4. 4 3
      Controller/SysManage.py
  5. 1 1
      Controller/UserController.py
  6. 0 55
      Object/QSmsObject.py
  7. 2 2
      Service/CommonService.py
  8. 0 1
      Service/DeviceOperation.py

+ 22 - 4
Ansjer/test/oss.py

@@ -20,18 +20,36 @@ import urllib
 ###########
 host = "oss-cn-shenzhen.aliyuncs.com"  # just for example
 # host = "hlsvoda.zositech.cn"  # just for example
+# host = 'oss-eu-central-1.aliyuncs.com'
 
 accessid = 'LTAIyMkGfEdogyL9'
 accesskey = '71uIjpsqVOmF7DAITRyRuc259jHOjO'
-bucket_name = "cloudvod1"
+
+
+
+import oss2
+
+# 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
+auth = Auth(accessid, accesskey)
+
+# Endpoint以杭州为例,其它Region请按实际情况填写。
+service = oss2.Service(auth, host)
+
+print([b.name for b in oss2.BucketIterator(service)])
+
+
+exit()
+
+
+
+bucket_name = "cnvod1"
 channel_name = "vod"
 auth = Auth(accessid, accesskey)
 bucket = Bucket(auth, host, bucket_name)
+
 ######################
-# 生成oss签名url
-# url = bucket.sign_url('GET', 'vod/1543902118/1543902118.m3u8', 60 * 60, params={'x-oss-process': 'hls/sign'})
 # 缩略图
-url = bucket.sign_url('GET', 'FTSLL8HM437Z38WU111A/vod4/2018121001/1543902118/ts0.ts', 60 * 60, params={'x-oss-process': 'video/snapshot,t_10000,m_fast,w_300'})
+url = bucket.sign_url('GET', 'VVDHCVBYDKFMJRWA111A/vod1/2019010315/1546498920/ts2.ts', 60 * 60, params={'x-oss-process': 'video/snapshot,t_10000,m_fast,w_300'})
 # url = bucket.sign_url('GET', 'FTSLL8HM437Z38WU111A/vod4/2018121001/1543902118/1543902118.m3u8', 60 * 60, params={'x-oss-process': 'hls/sign'})
 # url = urllib.parse.unquote(url, encoding='utf-8', errors='replace')
 urllst = url.split('?')

+ 13 - 12
Controller/AdminManage.py

@@ -69,18 +69,19 @@ class AdminManage(TemplateView):
             return response.json(404)
         duserID = request_dict.get('duserID', None)
         userPwd = request_dict.get('userPwd', None)
-        if duserID:
-            UserValid = Device_User.objects.filter(userID=duserID)
-            if UserValid:
-                if userPwd is None:
-                    userPwd = '123456'
-                is_update = UserValid.update(password=make_password(userPwd))
-                if is_update:
-                    return response.json(0)
-                else:
-                    return response.json(106)
-        else:
+        if not duserID:
             return response.json(444, 'duserID')
+        UserValid = Device_User.objects.filter(userID=duserID)
+        if UserValid:
+            if userPwd is None:
+                userPwd = '123456'
+            is_update = UserValid.update(password=make_password(userPwd))
+            if is_update:
+                return response.json(0)
+            else:
+                return response.json(106)
+        else:
+            return response.json(104)
 
     def getAllUserName(self, userID, response):
         # 权限固定为30
@@ -193,7 +194,7 @@ class AdminManage(TemplateView):
         uid_list = Device_Info.objects.all().values_list('UID', flat=True)
         res = {}
         if uid_list:
-            res = {'count': len(uid_list), 'uid_list': list(uid_list)}
+            res = {'count':uid_list.count(), 'uid_list': list(uid_list)}
         return response.json(0, res)
 
 

+ 1 - 2
Controller/OTAEquipment.py

@@ -583,7 +583,6 @@ def downloadOTAInterface(request, fullPath, *callback_args, **callback_kwargs):
     if fullPath:
         if os.path.isfile(fullPath):
             try:
-                JSON = res.formal(0)
                 wrapper = FileWrapper(open(fullPath, 'rb'))
                 response = HttpResponse(wrapper, content_type="application/octet-stream")
                 response['Content-Length'] = os.path.getsize(fullPath)
@@ -592,7 +591,7 @@ def downloadOTAInterface(request, fullPath, *callback_args, **callback_kwargs):
                 # 校验文件md5值
                 response['Content-SHA265'] = getMD5orSHA265(fullPath, 'SHA265')
                 response['Content-CRC32'] = getMD5orSHA265(fullPath, 'CRC32')
-                response['Content-Error'] = JSON
+                response['Content-Error'] = res.formal(0)
                 return response
             except Exception as e:
                 return res.json(906, repr(e))

+ 4 - 3
Controller/SysManage.py

@@ -22,15 +22,16 @@ import os
 
 @csrf_exempt
 def updateLog(request):
+    response = ResponseObject()
+    request.encoding = 'utf-8'
     if request.method == 'GET':
-        request.encoding = 'utf-8'
         request_dict = request.GET
     if request.method == 'POST':
-        request.encoding = 'utf-8'
         request_dict = request.POST
+    else:
+        response.json(404)
     token = request_dict.get('token',None)
     content = request_dict.get('content',None)
-    response = ResponseObject()
     if not content:
         return response.json(444,'content')
     tko = TokenObject(token)

+ 1 - 1
Controller/UserController.py

@@ -310,7 +310,7 @@ class ChangePwdView(TemplateView):
         return self.validates(request_dict)
 
     def get(self, request, *args, **kwargs):
-        request.encoding = 'gb2312'
+        request.encoding = 'utf-8'
         request_dict = request.GET
         return self.validates(request_dict)
 

+ 0 - 55
Object/QSmsObject.py

@@ -1,55 +0,0 @@
-#!/usr/bin/env python3  
-# -*- coding: utf-8 -*-  
-"""
-@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
-@AUTHOR: ASJRD018
-@NAME: AnsjerOA
-@software: PyCharm
-@DATE: 2018/8/20 15:36
-@Version: python3.6
-@MODIFY DECORD:ansjer dev
-@file: SmsObject.py
-@Contact: chanjunkai@163.com
-"""
-# 腾讯发送短信
-from Ansjer.config import TX_PHONE_APP_KEY, TX_PHONE_APP_ID
-from qcloudsms_py import SmsSingleSender
-
-TX_PHONE_APP_ID = '1400052907'
-TX_PHONE_APP_KEY = '7705976ca6e85fe7b86d6bc2d11f7783'
-
-
-class QSmsObject(object):
-
-    def __init__(self, phone, msg):
-        self.appid = TX_PHONE_APP_ID
-        self.appkey = TX_PHONE_APP_KEY
-        self.msg = msg
-        self.phone = phone
-
-    def sms(self):
-        try:
-            sender = SmsSingleSender(self.appid, self.appkey)
-            res = sender.send(0, "86", self.phone, self.msg)
-        except Exception as e:
-            print(repr(e))
-            return False
-        else:
-            print(res)
-            return res
-
-    def test(self):
-        message = "{authCode}为您的注册验证码,请于1分钟内填写。如非本人操作,请忽略本短信。".format(authCode=1234)
-        qsm = QSmsObject(phone='13119657713', msg=message)
-        qres = qsm.sms()
-        qcode = qres.get('result', None)
-        if qcode == 0:
-            return
-        else:
-            return
-
-
-message = "{authCode}为您的注册验证码,请于2分钟内填写。如非本人操作,请忽略本短信。".format(authCode=str(123456))
-
-qsm = QSmsObject(phone='13119657713', msg=message)
-qsm.sms()

+ 2 - 2
Service/CommonService.py

@@ -186,6 +186,6 @@ class CommonService:
     # 获取utc时间戳
     @staticmethod
     def get_utc():
-        nowutcdatetime = datetime.datetime.utcnow()
-        un_time = time.mktime(nowutcdatetime.timetuple())
+        nowdtm = datetime.datetime.utcnow()
+        un_time = time.mktime(nowdtm.timetuple())
         return int(un_time)

+ 0 - 1
Service/DeviceOperation.py

@@ -188,4 +188,3 @@ class DeviceOperation:
         }
 
         return data[search_class]
-# print(DeviceOperation.getOperation(type='0x10019'))