Esempio n. 1
0
 def _write_data(self, fpath, data, stat):
     """Write Zookeeper data to filesystem.
     """
     zksync_utils.write_data(
         fpath, data, stat.last_modified,
         raise_err=True, tmp_dir=self.tmp_dir
     )
Esempio n. 2
0
def _on_add_trace_event(zk2fs_sync, zkpath):
    """Invoked when trace event is added."""
    fpath = zk2fs_sync.fpath(zkpath)

    # Extract timestamp.
    _name, timestamp, _rest = os.path.basename(fpath).split(',', 2)
    utime = float(timestamp)

    zksync_utils.write_data(
        fpath, None, utime, raise_err=False, tmp_dir=zk2fs_sync.tmp_dir
    )
Esempio n. 3
0
    def test_write_data(self):
        """Tests writing data to filesystem."""
        path_ok = os.path.join(self.root, 'a')
        zksync_utils.write_data(path_ok, None, 12345)
        self.assertTrue(os.path.exists(path_ok))

        path_too_long = os.path.join(self.root, 'a' * 1024)
        self.assertRaises(OSError, zksync_utils.write_data, path_too_long,
                          None, 12345)
        self.assertFalse(os.path.exists(path_too_long))

        zksync_utils.write_data(path_too_long, None, 12345, raise_err=False)
        self.assertFalse(os.path.exists(path_too_long))
Esempio n. 4
0
def _write_data(fpath, data, stat):
    """Write Zookeeper data to filesystem."""
    zksync_utils.write_data(fpath, data, stat.last_modified)