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


Python Gluster_DiskFile.get_data_file_size方法代码示例

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


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

示例1: test_get_data_file_size_os_err

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import get_data_file_size [as 别名]
 def test_get_data_file_size_os_err(self):
     td = tempfile.mkdtemp()
     the_path = os.path.join(td, "vol0", "bar")
     the_file = os.path.join(the_path, "z")
     try:
         os.makedirs(the_path)
         with open(the_file, "wb") as fd:
             fd.write("1234")
         gdf = Gluster_DiskFile(td, "vol0", "p57", "ufo47", "bar",
                                "z", self.lg)
         assert gdf._obj == "z"
         assert gdf.data_file == the_file
         assert not gdf._is_dir
         stats = os.stat(the_path)
         os.chmod(the_path, 0)
         __os_path_getsize = os.path.getsize
         os.path.getsize = _mock_getsize_eaccess_err
         try:
             s = gdf.get_data_file_size()
         except OSError as err:
             assert err.errno == errno.EACCES
         else:
             self.fail("Expected OSError exception")
         finally:
             os.path.getsize = __os_path_getsize
             os.chmod(the_path, stats.st_mode)
     finally:
         shutil.rmtree(td)
开发者ID:ajarr,项目名称:gluster-swift,代码行数:30,代码来源:test_diskfile.py

示例2: test_get_data_file_size_dne

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import get_data_file_size [as 别名]
 def test_get_data_file_size_dne(self):
     assert not os.path.exists("/tmp/foo")
     gdf = Gluster_DiskFile("/tmp/foo", "vol0", "p57", "ufo47", "bar", "/b/a/z/", self.lg)
     try:
         s = gdf.get_data_file_size()
     except DiskFileNotExist:
         pass
     else:
         self.fail("Expected DiskFileNotExist exception")
开发者ID:portante,项目名称:glusterfs,代码行数:11,代码来源:test_diskfile.py

示例3: test_get_data_file_size_dir

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import get_data_file_size [as 别名]
 def test_get_data_file_size_dir(self):
     td = tempfile.mkdtemp()
     the_path = os.path.join(td, "vol0", "bar")
     the_dir = os.path.join(the_path, "d")
     try:
         os.makedirs(the_dir)
         gdf = Gluster_DiskFile(td, "vol0", "p57", "ufo47", "bar", "d", self.lg, keep_data_fp=True)
         assert gdf._obj == "d"
         assert gdf.data_file == the_dir
         assert gdf._is_dir
         assert 0 == gdf.get_data_file_size()
     finally:
         shutil.rmtree(td)
开发者ID:portante,项目名称:glusterfs,代码行数:15,代码来源:test_diskfile.py

示例4: test_get_data_file_size

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import get_data_file_size [as 别名]
 def test_get_data_file_size(self):
     td = tempfile.mkdtemp()
     the_path = os.path.join(td, "vol0", "bar")
     the_file = os.path.join(the_path, "z")
     try:
         os.makedirs(the_path)
         with open(the_file, "wb") as fd:
             fd.write("1234")
         gdf = Gluster_DiskFile(td, "vol0", "p57", "ufo47", "bar", "z", self.lg)
         assert gdf._obj == "z"
         assert gdf.data_file == the_file
         assert not gdf._is_dir
         assert 4 == gdf.get_data_file_size()
     finally:
         shutil.rmtree(td)
开发者ID:portante,项目名称:glusterfs,代码行数:17,代码来源:test_diskfile.py

示例5: test_get_data_file_size_dne_os_err

# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import get_data_file_size [as 别名]
 def test_get_data_file_size_dne_os_err(self):
     td = tempfile.mkdtemp()
     the_path = os.path.join(td, "vol0", "bar")
     the_file = os.path.join(the_path, "z")
     try:
         os.makedirs(the_path)
         with open(the_file, "wb") as fd:
             fd.write("1234")
         gdf = Gluster_DiskFile(td, "vol0", "p57", "ufo47", "bar", "z", self.lg)
         assert gdf._obj == "z"
         assert gdf.data_file == the_file
         assert not gdf._is_dir
         gdf.data_file = gdf.data_file + ".dne"
         try:
             s = gdf.get_data_file_size()
         except DiskFileNotExist:
             pass
         else:
             self.fail("Expected DiskFileNotExist exception")
     finally:
         shutil.rmtree(td)
开发者ID:portante,项目名称:glusterfs,代码行数:23,代码来源:test_diskfile.py


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