| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | #!/usr/bin/env python3  # -*- coding: utf-8 -*-  """@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.@AUTHOR: ASJRD018@NAME: Ansjer@software: PyCharm@DATE: 2018/6/8 9:10@Version: python3.6@MODIFY DECORD:ansjer dev@file: SysManage.py@Contact: chanjunkai@163.com"""import osfrom django.http import HttpResponsefrom django.views.decorators.csrf import csrf_exemptfrom django.views.generic.base import Viewfrom Ansjer.config import BASE_DIRfrom Object.ResponseObject import ResponseObjectfrom Object.TokenObject import TokenObjectfrom Service.ModelService import ModelService@csrf_exemptdef updateLog(request):    response = ResponseObject()    request.encoding = 'utf-8'    if request.method == 'GET':        request_dict = request.GET    if request.method == 'POST':        request_dict = request.POST    else:        response.json(404)    token = request_dict.get('token', None)    content = request_dict.get('content', None)    if not content:        return response.json(444, 'content')    tko = TokenObject(token)    response.lang = tko.lang    if tko.code != 0:        return response.json(tko.code)    userID = tko.userID    own_permission = ModelService.check_perm(userID=userID, permID=50)    if own_permission is not True:        return response.json(404)    file_path = os.path.join(BASE_DIR, 'static/Help/version.txt')    try:        with open(file_path, "w", encoding="utf-8") as f:            f.write(content)    except Exception as e:        pass    return response.json(0)class getStatView(View):    def post(self, request, *args, **kwargs):        request.encoding = 'utf-8'        filePath = kwargs.get('filePath', None)        filePath.encode(encoding='utf-8', errors='strict')        response = ResponseObject()        return self.getFile(filePath, response)    def get(self, request, *args, **kwargs):        request.encoding = 'gb2312'        filePath = kwargs.get('filePath', None)        response = ResponseObject()        filePath.encode(encoding='gb2312', errors='strict')        return self.getFile(filePath, response)    def getFile(self, filePath,response):        if filePath:            pass        else:            return response.json(800)        fullPath = os.path.join(BASE_DIR,filePath).replace('\\', '/')        from var_dump import var_dump        var_dump(fullPath)        if os.path.isfile(fullPath):            try:                Imagedata = open(fullPath, 'rb').read()            except Exception as e:                return response.json(906, repr(e))            else:                return HttpResponse(Imagedata, content_type="image/jpeg")
 |