예제 #1
0
 def GET(self, *arg, **params):
     LogFolder = Log.getLogDataPath()
     ecsPath   = LogFolder + '/ecs.log'
     esFolder  = LogFolder + '/logs'
     intent = ''.join(arg)
     if intent == 'ecs':
         return WebFunc.DownloadFile(ecsPath)
     elif intent == 'es':
         return WebFunc.DownloadFolderZip(esFolder)
     
     return WebFunc.DownloadFolderZip(LogFolder)
예제 #2
0
    def GET(self, *arg, **params):
        extInfo = UtilFunc.getOptParamsInfo(params)
        intent = params.get('intent', None)
        if intent == 'traversal':
            return self._getTraversalResult(arg, params)
        elif intent == 'typeFile':
            return self._getLibraryGroupByType(params)
        elif arg and arg[0] == 'stream':
            return UtilFunc.mediaPlay(''.join(arg[1:]))
        path = self._formatPath(arg, params)
        if intent == 'props':
            return WebFunc.jsonResult(UtilFunc.getFileInfo(
                path, extInfo, True))
        elif intent == 'folderZip':
            return WebFunc.DownloadFolderZip(path)
        if os.path.isdir(path):
            files = UtilFunc.getFileList(path, extInfo)
        else:
            headers = {
                key.lower(): val
                for key, val in cherrypy.request.headers.iteritems()
            }
            lastEtag = headers.get('if-none-match', None)
            etag = UtilFunc.getFileEtag(path)
            if lastEtag:
                if lastEtag == etag:
                    cherrypy.response.status = 304
                    return
            matchEtag = headers.get('if-match', None)
            if matchEtag:
                if matchEtag != etag:
                    raise cherrypy.HTTPError(412)
            return WebFunc.DownloadFile(path)

        return WebFunc.jsonResult({
            'total': len(files),
            'files': files,
            'offset': extInfo['offset'],
            'limit': extInfo['limit']
        })