Exemple #1
0
 def writeSharedFileStream(self, sharedFileName, isProtected=None):
     # the isProtected parameter has no effect on the fileStore
     self._requireValidSharedFileName(sharedFileName)
     with AtomicFileCreate(
             self._getSharedFilePath(sharedFileName)) as tmpSharedFilePath:
         with open(tmpSharedFilePath, 'wb') as f:
             yield f
Exemple #2
0
 def test_atomic_context_error(self):
     outf = self._get_test_out_file(".tar")
     try:
         with AtomicFileCreate(outf) as outf_tmp:
             self._write_test_file(outf_tmp)
             raise Exception("stop!")
     except Exception as ex:
         self.assertEqual(str(ex), "stop!")
     self.assertFalse(os.path.exists(outf))
Exemple #3
0
 def readFile(self, jobStoreFileID, localFilePath, symlink=False):
     # used on non-shared files which will be encrypted if available
     # checking for JobStoreID existence
     if not self.fileExists(jobStoreFileID):
         raise NoSuchFileException(jobStoreFileID)
     with AtomicFileCreate(localFilePath) as tmpPath:
         with open(tmpPath, 'w') as writeable:
             blob = self.bucket.get_blob(compat_bytes(jobStoreFileID), encryption_key=self.sseKey)
             blob.download_to_file(writeable)
Exemple #4
0
 def test_atomic_context_ok(self):
     outf = self._get_test_out_file(".tar")
     with AtomicFileCreate(outf) as outf_tmp:
         self._write_test_file(outf_tmp)
     self.assertTrue(os.path.exists(outf))