Skip to content

Commit 51af821

Browse files
yangmvyangmv
authored andcommitted
edit
1 parent 7c80648 commit 51af821

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed
-113 Bytes
Binary file not shown.
98 Bytes
Binary file not shown.

apps/assets/views/server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def get(self, request ,format=None):
9191
# 从OSS获取
9292
oss_obj = initOSS_obj()
9393
if oss_obj:
94-
data = oss_obj.getObj(log.record_name)
94+
record_date = log.start_time.strftime('%Y%m%d')
95+
data = oss_obj.getObj(log.record_name,record_date)
9596
ret['data'] = data
9697
else:
9798
# 从Mysql获取
@@ -260,12 +261,12 @@ def get(self, request ,format=None):
260261
ret = dict(status=False,msg=None,data=None)
261262
if sid:
262263
# username = request.query_params.get('username')
263-
# username = 'yangmingwei' if username == 'yangmv' else username
264264
# 改用后端验证登录用户信息
265265
auth_key = request.COOKIES.get('auth_key', None)
266266
if not auth_key:return Response('未登陆',status=401)
267267
user_info = jwt.decode(auth_key, verify=False)
268268
username = user_info['data']['username'] if 'data' in user_info else 'guest'
269+
username = 'yangmingwei' if username == 'yangmv' else username
269270
rule_obj = models.ServerAuthRule.objects.filter(user__contains=username)
270271
for rule in rule_obj:
271272
server_obj = rule.server.filter(id=sid)

deploy.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ spec:
2020
# postStart:
2121
# exec:
2222
# command: ['/bin/sh', '-c', 'sed -i "s/s_hostname/$(hostname)/" /data1/www/templates/app.html']
23+
resources:
24+
limits:
25+
cpu: 0.5
26+
memory: 512Mi
27+
requests:
28+
cpu: 0.3
29+
memory: 256Mi
2330
ports:
2431
- name: http
2532
containerPort: 80
63 Bytes
Binary file not shown.

libs/Aliyun/oss.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import oss2
1010
import datetime
1111
import shortuuid
12+
import json
1213

1314
class OSSApi():
1415
def __init__(self,key,secret,region,bucket_name,base_dir):
@@ -42,20 +43,20 @@ def setObj(self,data):
4243
except Exception as e:
4344
print(e)
4445

45-
def getObj(self,filename):
46+
def getObj(self,filename,record_date):
4647
'''获取str对象'''
4748
try:
48-
object_stream = self.bucket.get_object('%s/%s/%s'%(self.base_dir,self.date,filename))
49+
object_stream = self.bucket.get_object('%s/%s/%s'%(self.base_dir,record_date,filename))
4950
#print('[Success] Get obj success!')
5051
return object_stream.read().decode()
5152
except oss2.exceptions.NoSuchKey as e:
52-
print('[Error] 文件不存在!')
53+
return json.dumps({'0.0029790401458740234':'[Error] OSS录像文件不存在!'})
5354
except oss2.exceptions.ServerError as e:
54-
print('[Error] 服务器拒绝, 请检查[KEY][SECRET][存储桶]是否正确!')
55+
return json.dumps({'0.0029790401458740234':'[Error] 请检查[KEY][SECRET][存储桶]是否正确!'})
5556
except oss2.exceptions.AccessDenied as e:
56-
print('[Error] 操作拒绝,请检查key是否有权限上传!')
57+
return json.dumps({'0.0029790401458740234':'[Error] 操作拒绝,请检查key是否有权限上传!'})
5758
except Exception as e:
58-
print(e)
59+
return json.dumps({'0.0029790401458740234':'[Error]--->%s'%e})
5960

6061
if __name__ == '__main__':
6162
oss_config = {

0 commit comments

Comments
 (0)