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


Python LockDir.peek方法代码示例

本文整理汇总了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)
开发者ID:c0ns0le,项目名称:cygwin,代码行数:13,代码来源:test_lockdir.py

示例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')
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:28,代码来源:test_lockdir.py

示例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)
开发者ID:c0ns0le,项目名称:cygwin,代码行数:21,代码来源:test_workingtree_4.py

示例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)
开发者ID:Distrotech,项目名称:bzr,代码行数:26,代码来源:test_workingtree.py

示例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()
开发者ID:c0ns0le,项目名称:cygwin,代码行数:18,代码来源:test_lockdir.py

示例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()
开发者ID:c0ns0le,项目名称:cygwin,代码行数:18,代码来源:test_lockdir.py

示例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)
开发者ID:c0ns0le,项目名称:cygwin,代码行数:18,代码来源:test_lockdir.py

示例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)
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:19,代码来源:test_lockdir.py

示例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()
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:19,代码来源:test_lockdir.py

示例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)
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:5,代码来源:test_lockdir.py

示例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)
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:5,代码来源:test_lockdir.py


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