当前位置: 首页>>代码示例>>Python>>正文


Python Gluster_DiskFile.put方法代码示例

本文整理汇总了Python中gluster.swift.common.DiskFile.Gluster_DiskFile.put方法的典型用法代码示例。如果您正苦于以下问题:Python Gluster_DiskFile.put方法的具体用法?Python Gluster_DiskFile.put怎么用?Python Gluster_DiskFile.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gluster.swift.common.DiskFile.Gluster_DiskFile的用法示例。


在下文中一共展示了Gluster_DiskFile.put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_put_obj_path

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import put [as 别名]
    def test_put_obj_path(self):
        the_obj_path = os.path.join("b", "a")
        the_file = os.path.join(the_obj_path, "z")
        td = tempfile.mkdtemp()
        try:
            gdf = Gluster_DiskFile(td, "vol0", "p57", "ufo47", "bar",
                                   the_file, self.lg)
            assert gdf._obj == "z"
            assert gdf._obj_path == the_obj_path
            assert gdf.name == os.path.join("bar", "b", "a")
            assert gdf.datadir == os.path.join(td, "vol0", "bar", "b", "a")
            assert gdf.data_file is None

            body = '1234\n'
            etag = md5()
            etag.update(body)
            etag = etag.hexdigest()
            metadata = {
                'X-Timestamp': '1234',
                'Content-Type': 'file',
                'ETag': etag,
                'Content-Length': '5',
                }

            with gdf.mkstemp() as fd:
                assert gdf.tmppath is not None
                tmppath = gdf.tmppath
                os.write(fd, body)
                gdf.put(fd, metadata)

            assert gdf.data_file == os.path.join(td, "vol0", "bar", "b", "a", "z")
            assert os.path.exists(gdf.data_file)
            assert not os.path.exists(tmppath)
        finally:
            shutil.rmtree(td)
开发者ID:ajarr,项目名称:gluster-swift,代码行数:37,代码来源:test_diskfile.py

示例2: test_put_is_dir

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import put [as 别名]
 def test_put_is_dir(self):
     td = tempfile.mkdtemp()
     the_path = os.path.join(td, "vol0", "bar")
     the_dir = os.path.join(the_path, "dir")
     try:
         os.makedirs(the_dir)
         gdf = Gluster_DiskFile(td, "vol0", "p57", "ufo47", "bar",
                                "dir", self.lg)
         origmd = gdf.metadata.copy()
         origfmd = _metadata[the_dir]
         newmd = gdf.metadata.copy()
         # FIXME: This is a hack to get to the code-path; it is not clear
         # how this can happen normally.
         newmd['Content-Type'] = ''
         newmd['X-Object-Meta-test'] = '1234'
         try:
             gdf.put(None, newmd, extension='.data')
         except AlreadyExistsAsDir:
             pass
         else:
             self.fail("Expected to encounter 'already-exists-as-dir' exception")
         assert gdf.metadata == origmd
         assert _metadata[the_dir] == origfmd
     finally:
         shutil.rmtree(td)
开发者ID:ajarr,项目名称:gluster-swift,代码行数:27,代码来源:test_diskfile.py

示例3: test_put

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import put [as 别名]
    def test_put(self):
        td = tempfile.mkdtemp()
        try:
            gdf = Gluster_DiskFile(td, "vol0", "p57", "ufo47", "bar", "z", self.lg)
            assert gdf._obj == "z"
            assert gdf._obj_path == ""
            assert gdf.name == "bar"
            assert gdf.datadir == os.path.join(td, "vol0", "bar")
            assert gdf.data_file is None

            body = "1234\n"
            etag = md5()
            etag.update(body)
            etag = etag.hexdigest()
            metadata = {"X-Timestamp": "1234", "Content-Type": "file", "ETag": etag, "Content-Length": "5"}

            with gdf.mkstemp() as fd:
                assert gdf.tmppath is not None
                tmppath = gdf.tmppath
                os.write(fd, body)
                gdf.put(fd, metadata)

            assert gdf.data_file == os.path.join(td, "vol0", "bar", "z")
            assert os.path.exists(gdf.data_file)
            assert not os.path.exists(tmppath)
        finally:
            shutil.rmtree(td)
开发者ID:portante,项目名称:glusterfs,代码行数:29,代码来源:test_diskfile.py

示例4: test_put_w_marker_dir_create

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import put [as 别名]
 def test_put_w_marker_dir_create(self):
     td = tempfile.mkdtemp()
     the_path = os.path.join(td, "vol0", "bar")
     the_dir = os.path.join(the_path, "dir")
     try:
         gdf = Gluster_DiskFile(td, "vol0", "p57", "ufo47", "bar", "dir", self.lg)
         assert gdf.metadata == {}
         newmd = {"Content-Length": 0, "ETag": "etag", "X-Timestamp": "ts", "Content-Type": "application/directory"}
         gdf.put(None, newmd, extension=".dir")
         assert gdf.data_file == the_dir
         assert gdf.metadata == newmd
         assert _metadata[the_dir] == newmd
     finally:
         shutil.rmtree(td)
开发者ID:portante,项目名称:glusterfs,代码行数:16,代码来源:test_diskfile.py

示例5: test_put_w_marker_dir_create

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import put [as 别名]
 def test_put_w_marker_dir_create(self):
     td = tempfile.mkdtemp()
     the_path = os.path.join(td, "vol0", "bar")
     the_dir = os.path.join(the_path, "dir")
     try:
         gdf = Gluster_DiskFile(td, "vol0", "p57", "ufo47", "bar",
                                "dir", self.lg)
         assert gdf.metadata == {}
         newmd = {
             'Content-Length': 0,
             'ETag': 'etag',
             'X-Timestamp': 'ts',
             'Content-Type': 'application/directory'}
         gdf.put(None, newmd, extension='.dir')
         assert gdf.data_file == the_dir
         assert gdf.metadata == newmd
         assert _metadata[the_dir] == newmd
     finally:
         shutil.rmtree(td)
开发者ID:ajarr,项目名称:gluster-swift,代码行数:21,代码来源:test_diskfile.py

示例6: test_put_w_marker_dir_create

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import put [as 别名]
 def test_put_w_marker_dir_create(self):
     td = tempfile.mkdtemp()
     the_cont = os.path.join(td, "vol0", "bar")
     the_dir = os.path.join(the_cont, "dir")
     try:
         os.makedirs(the_cont)
         gdf = Gluster_DiskFile(td, "vol0", "p57", "ufo47", "bar",
                                "dir", self.lg)
         assert gdf.metadata == {}
         newmd = {
             'ETag': 'etag',
             'X-Timestamp': 'ts',
             'Content-Type': 'application/directory'}
         gdf.put(None, newmd, extension='.dir')
         assert gdf.data_file == the_dir
         for key,val in newmd.items():
             assert gdf.metadata[key] == val
             assert _metadata[the_dir][key] == val
         assert gdf.metadata[X_OBJECT_TYPE] == DIR_OBJECT
         assert _metadata[the_dir][X_OBJECT_TYPE] == DIR_OBJECT
     finally:
         shutil.rmtree(td)
开发者ID:navidshaikh,项目名称:gluster-swift,代码行数:24,代码来源:test_diskfile.py


注:本文中的gluster.swift.common.DiskFile.Gluster_DiskFile.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。