本文整理汇总了Python中bzrlib.lockdir.LockDir.peek方法的典型用法代码示例。如果您正苦于以下问题:Python LockDir.peek方法的具体用法?Python LockDir.peek怎么用?Python LockDir.peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bzrlib.lockdir.LockDir
的用法示例。
在下文中一共展示了LockDir.peek方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_21_peek_readonly
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_21_peek_readonly(self):
"""Peek over a readonly transport"""
t = self.get_transport()
lf1 = LockDir(t, 'test_lock')
lf1.create()
lf2 = LockDir(self.get_readonly_transport(), 'test_lock')
self.assertEqual(lf2.peek(), None)
lf1.attempt_lock()
info2 = lf2.peek()
self.assertTrue(info2)
self.assertEqual(info2['nonce'], lf1.nonce)
示例2: test_missing_lockdir_info
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_missing_lockdir_info(self):
"""We can cope with absent info files."""
t = self.get_transport()
t.mkdir('test_lock')
t.mkdir('test_lock/held')
lf = LockDir(t, 'test_lock')
# In this case we expect the 'not held' result from peek, because peek
# cannot be expected to notice that there is a 'held' directory with no
# 'info' file.
self.assertEqual(None, lf.peek())
# And lock/unlock may work or give LockContention (but not any other
# error).
try:
lf.attempt_lock()
except LockContention:
# LockContention is ok, and expected on Windows
pass
else:
# no error is ok, and expected on POSIX (because POSIX allows
# os.rename over an empty directory).
lf.unlock()
# Currently raises TokenMismatch, but LockCorrupt would be reasonable
# too.
self.assertRaises(
(errors.TokenMismatch, errors.LockCorrupt),
lf.validate_token, 'fake token')
示例3: test_uses_lockdir
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_uses_lockdir(self):
"""WorkingTreeFormat4 uses its own LockDir:
- lock is a directory
- when the WorkingTree is locked, LockDir can see that
"""
# this test could be factored into a subclass of tests common to both
# format 3 and 4, but for now its not much of an issue as there is only one in common.
t = self.get_transport()
tree = self.make_workingtree()
self.assertIsDirectory('.bzr', t)
self.assertIsDirectory('.bzr/checkout', t)
self.assertIsDirectory('.bzr/checkout/lock', t)
our_lock = LockDir(t, '.bzr/checkout/lock')
self.assertEquals(our_lock.peek(), None)
tree.lock_write()
self.assertTrue(our_lock.peek())
tree.unlock()
self.assertEquals(our_lock.peek(), None)
示例4: test_uses_lockdir
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_uses_lockdir(self):
"""WorkingTreeFormat3 uses its own LockDir:
- lock is a directory
- when the WorkingTree is locked, LockDir can see that
"""
t = self.get_transport()
url = self.get_url()
dir = bzrdir.BzrDirMetaFormat1().initialize(url)
repo = dir.create_repository()
branch = dir.create_branch()
try:
tree = workingtree_3.WorkingTreeFormat3().initialize(dir)
except errors.NotLocalUrl:
raise TestSkipped('Not a local URL')
self.assertIsDirectory('.bzr', t)
self.assertIsDirectory('.bzr/checkout', t)
self.assertIsDirectory('.bzr/checkout/lock', t)
our_lock = LockDir(t, '.bzr/checkout/lock')
self.assertEquals(our_lock.peek(), None)
tree.lock_write()
self.assertTrue(our_lock.peek())
tree.unlock()
self.assertEquals(our_lock.peek(), None)
示例5: test_44_break_already_released
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_44_break_already_released(self):
"""Lock break races with regular release"""
t = self.get_transport()
lf1 = LockDir(t, 'test_lock')
lf1.create()
lf1.attempt_lock()
# someone else sees it's still locked
lf2 = LockDir(t, 'test_lock')
holder_info = lf2.peek()
# in the interim the lock is released
lf1.unlock()
# break should succeed
lf2.force_break(holder_info)
# now we should be able to take it
lf2.attempt_lock()
lf2.confirm()
示例6: test_43_break
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_43_break(self):
"""Break a lock whose caller has forgotten it"""
t = self.get_transport()
lf1 = LockDir(t, 'test_lock')
lf1.create()
lf1.attempt_lock()
# we incorrectly discard the lock object without unlocking it
del lf1
# someone else sees it's still locked
lf2 = LockDir(t, 'test_lock')
holder_info = lf2.peek()
self.assertTrue(holder_info)
lf2.force_break(holder_info)
# now we should be able to take it
lf2.attempt_lock()
lf2.confirm()
示例7: test_20_lock_peek
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_20_lock_peek(self):
"""Peek at the state of a lock"""
t = self.get_transport()
lf1 = LockDir(t, 'test_lock')
lf1.create()
lf1.attempt_lock()
# lock is held, should get some info on it
info1 = lf1.peek()
self.assertEqual(set(info1.keys()),
set(['user', 'nonce', 'hostname', 'pid', 'start_time']))
# should get the same info if we look at it through a different
# instance
info2 = LockDir(t, 'test_lock').peek()
self.assertEqual(info1, info2)
# locks which are never used should be not-held
self.assertEqual(LockDir(t, 'other_lock').peek(), None)
示例8: test_no_lockdir_info
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_no_lockdir_info(self):
"""We can cope with empty info files."""
# This seems like a fairly common failure case - see
# <https://bugs.launchpad.net/bzr/+bug/185103> and all its dupes.
# Processes are often interrupted after opening the file
# before the actual contents are committed.
t = self.get_transport()
t.mkdir('test_lock')
t.mkdir('test_lock/held')
t.put_bytes('test_lock/held/info', '')
lf = LockDir(t, 'test_lock')
info = lf.peek()
formatted_info = info.to_readable_dict()
self.assertEquals(
dict(user='<unknown>', hostname='<unknown>', pid='<unknown>',
time_ago='(unknown)'),
formatted_info)
示例9: test_45_break_mismatch
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_45_break_mismatch(self):
"""Lock break races with someone else acquiring it"""
t = self.get_transport()
lf1 = LockDir(t, 'test_lock')
lf1.create()
lf1.attempt_lock()
# someone else sees it's still locked
lf2 = LockDir(t, 'test_lock')
holder_info = lf2.peek()
# in the interim the lock is released
lf1.unlock()
lf3 = LockDir(t, 'test_lock')
lf3.attempt_lock()
# break should now *fail*
self.assertRaises(LockBreakMismatch, lf2.force_break,
holder_info)
lf3.unlock()
示例10: test_03_readonly_peek
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_03_readonly_peek(self):
lf = LockDir(self.get_readonly_transport(), 'test_lock')
self.assertEqual(lf.peek(), None)
示例11: test_02_unlocked_peek
# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import peek [as 别名]
def test_02_unlocked_peek(self):
lf = LockDir(self.get_transport(), 'test_lock')
self.assertEqual(lf.peek(), None)