示例#1
0
def imported_htmldata(request, data_file):
    proj = current_project(request)

    log_path = Path(SITE.RAW_DATA_DIR, proj.proposal, data_file)

    if not log_path.is_file():
        return HttpResponseNotFound()

    return HttpResponse(read_proj_file(proj, log_path))
示例#2
0
def htmldata(request, data_file):
    project = current_project(request)

    log_path = Path(project.project_dir, data_file)

    if not log_path.is_file():
        return HttpResponseNotFound()

    return HttpResponse(read_proj_file(project, log_path))
示例#3
0
    def test_read_proj_file(self):
        """
        test read_proj_file() on un-encrypted project
        """
        # write test file
        _write_file(self.file_path)

        # check that plaintext file is read correctly
        data = read_proj_file(self.proj, self.file_path)
        self.assertEqual(data, DUMMY_DATA)
示例#4
0
def download(request, log_file):
    project = current_project(request)
    log_path = Path(project.project_dir, log_file)

    if not log_path.is_file():
        return _log_not_found_resp(log_file)

    return HttpResponse(
        read_proj_file(project, log_path),
        content_type="application/octet-stream",
    )
示例#5
0
    def test_read_proj_file(self):
        """
        test open_proj_file() on encrypted project
        """
        # write test file
        with encryption.EncryptedFile(self.project.encryption_key,
                                      self.file_path) as f:
            f.write(DUMMY_DATA)

        # check that encrypted file is decrypted correctly
        data = read_proj_file(self.project, self.file_path)
        self.assertEqual(data, DUMMY_DATA)
示例#6
0
def binary_http_response(proj, file_path, content_type):
    return HttpResponse(read_proj_file(proj, file_path), content_type=content_type)
示例#7
0
 def _file_data(proj, file_path):
     yield read_proj_file(proj, file_path)