本文整理汇总了Python中gluster.swift.common.DiskFile.Gluster_DiskFile.unlinkold方法的典型用法代码示例。如果您正苦于以下问题:Python Gluster_DiskFile.unlinkold方法的具体用法?Python Gluster_DiskFile.unlinkold怎么用?Python Gluster_DiskFile.unlinkold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluster.swift.common.DiskFile.Gluster_DiskFile
的用法示例。
在下文中一共展示了Gluster_DiskFile.unlinkold方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unlinkold_is_dir_failure
# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import unlinkold [as 别名]
def test_unlinkold_is_dir_failure(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.data_file == the_dir
assert gdf._is_dir
stats = os.stat(gdf.datadir)
os.chmod(gdf.datadir, 0)
__os_rmdir = os.rmdir
os.rmdir = _mock_do_rmdir_eacces_err
try:
later = float(gdf.metadata['X-Timestamp']) + 1
gdf.unlinkold(normalize_timestamp(later))
finally:
os.chmod(gdf.datadir, stats.st_mode)
os.rmdir = __os_rmdir
assert os.path.isdir(gdf.datadir)
self.assertTrue(gdf.data_file is None)
finally:
shutil.rmtree(td)
示例2: test_unlinkold_file_unlink_error
# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import unlinkold [as 别名]
def test_unlinkold_file_unlink_error(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
later = float(gdf.metadata['X-Timestamp']) + 1
stats = os.stat(the_path)
os.chmod(the_path, stats.st_mode & (~stat.S_IWUSR))
# Handle the case do_unlink() raises an OSError
try:
gdf.unlinkold(normalize_timestamp(later))
except OSError as e:
assert e.errno != errno.ENOENT
else:
self.fail("Excepted an OSError when unlinking file")
finally:
os.chmod(the_path, stats.st_mode)
assert os.path.isdir(gdf.datadir)
assert os.path.exists(os.path.join(gdf.datadir, gdf._obj))
finally:
shutil.rmtree(td)
示例3: test_unlinkold_no_metadata
# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import unlinkold [as 别名]
def test_unlinkold_no_metadata(self):
assert not os.path.exists("/tmp/foo")
gdf = Gluster_DiskFile("/tmp/foo", "vol0", "p57", "ufo47", "bar",
"z", self.lg)
assert gdf.metadata == {}
_saved_rmobjdir = gluster.swift.common.DiskFile.rmobjdir
gluster.swift.common.DiskFile.rmobjdir = _mock_rmobjdir
try:
gdf.unlinkold(None)
except MockException as exp:
self.fail(str(exp))
finally:
gluster.swift.common.DiskFile.rmobjdir = _saved_rmobjdir
示例4: test_unlinkold_same_timestamp
# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import unlinkold [as 别名]
def test_unlinkold_same_timestamp(self):
assert not os.path.exists("/tmp/foo")
gdf = Gluster_DiskFile("/tmp/foo", "vol0", "p57", "ufo47", "bar",
"z", self.lg)
assert gdf.metadata == {}
gdf.metadata['X-Timestamp'] = 1
_saved_rmdirs = gluster.swift.common.DiskFile.rmdirs
gluster.swift.common.DiskFile.rmdirs = _mock_rmdirs
try:
gdf.unlinkold(1)
except MockException as exp:
self.fail(str(exp))
finally:
gluster.swift.common.DiskFile.rmdirs = _saved_rmdirs
示例5: test_unlinkold_is_dir
# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import unlinkold [as 别名]
def test_unlinkold_is_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.data_file == the_dir
assert gdf._is_dir
later = float(gdf.metadata["X-Timestamp"]) + 1
gdf.unlinkold(normalize_timestamp(later))
assert os.path.isdir(gdf.datadir)
assert not os.path.exists(os.path.join(gdf.datadir, gdf._obj))
finally:
shutil.rmtree(td)
示例6: test_unlinkold_file
# 需要导入模块: from gluster.swift.common.DiskFile import Gluster_DiskFile [as 别名]
# 或者: from gluster.swift.common.DiskFile.Gluster_DiskFile import unlinkold [as 别名]
def test_unlinkold_file(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
later = float(gdf.metadata["X-Timestamp"]) + 1
gdf.unlinkold(normalize_timestamp(later))
assert os.path.isdir(gdf.datadir)
assert not os.path.exists(os.path.join(gdf.datadir, gdf._obj))
finally:
shutil.rmtree(td)