コード例 #1
0
ファイル: root.py プロジェクト: pombredanne/crest-1
    def get(self, request, cu, roleIds = None, fileId = None,
            repos = None, **kwargs):
        sha1, isConfig = repquery.getFileSha1(cu, roleIds, fileId)
        if sha1 is None:
            return response.Response(status=404)

        localPath = repos.repos.contentsStore.hashToPath(sha1)
        bzippedFile = gzip.GzipFile(localPath, "r")
        uncompressedFile = util.BZ2File(bzippedFile)

        return CompressFileResponse(uncompressedFile)
コード例 #2
0
ファイル: root.py プロジェクト: pombredanne/crest-1
    def content(self, request, cu, roleIds = None, fileId = None,
                repos = None, **kwargs):
        sha1, isConfig = repquery.getFileSha1(cu, roleIds, fileId)
        if sha1 is None:
            return response.Response(status=404)

        localPath = repos.repos.contentsStore.hashToPath(sha1)
        if request.unparsedPath:
            remotePath = os.path.basename(request.unparsedPath)
        else:
            remotePath = sha1
        return FileResponse(localPath, gzipped=True, remotePath=remotePath,
                download=not isConfig)
コード例 #3
0
    def get(self,
            request,
            cu,
            roleIds=None,
            fileId=None,
            repos=None,
            **kwargs):
        sha1, isConfig = repquery.getFileSha1(cu, roleIds, fileId)
        if sha1 is None:
            return response.Response(status=404)

        localPath = repos.repos.contentsStore.hashToPath(sha1)
        bzippedFile = gzip.GzipFile(localPath, "r")
        uncompressedFile = util.BZ2File(bzippedFile)

        return CompressFileResponse(uncompressedFile)
コード例 #4
0
    def content(self,
                request,
                cu,
                roleIds=None,
                fileId=None,
                repos=None,
                **kwargs):
        sha1, isConfig = repquery.getFileSha1(cu, roleIds, fileId)
        if sha1 is None:
            return response.Response(status=404)

        localPath = repos.repos.contentsStore.hashToPath(sha1)
        if request.unparsedPath:
            remotePath = os.path.basename(request.unparsedPath)
        else:
            remotePath = sha1
        return FileResponse(localPath,
                            gzipped=True,
                            remotePath=remotePath,
                            download=not isConfig)