當前位置: 首頁>>代碼示例>>Python>>正文


Python YumDistributor.handle_symlinks方法代碼示例

本文整理匯總了Python中yum_distributor.distributor.YumDistributor.handle_symlinks方法的典型用法代碼示例。如果您正苦於以下問題:Python YumDistributor.handle_symlinks方法的具體用法?Python YumDistributor.handle_symlinks怎麽用?Python YumDistributor.handle_symlinks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yum_distributor.distributor.YumDistributor的用法示例。


在下文中一共展示了YumDistributor.handle_symlinks方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_handle_symlinks

# 需要導入模塊: from yum_distributor.distributor import YumDistributor [as 別名]
# 或者: from yum_distributor.distributor.YumDistributor import handle_symlinks [as 別名]
    def test_handle_symlinks(self):
        distributor = YumDistributor()
        units = []
        symlink_dir = os.path.join(self.temp_dir, "symlinks")
        num_links = 5
        for index in range(0,num_links):
            relpath = "file_%s.rpm" % (index)
            sp = os.path.join(self.pkg_dir, relpath)
            open(sp, "a") # Create an empty file
            if index % 2 == 0:
                # Ensure we can support symlinks in subdirs
                relpath = os.path.join("a", "b", "c", relpath)
            u = Unit("rpm", "unit_key_%s" % (index), {"relativepath":relpath}, sp)
            units.append(u)

        status, errors = distributor.handle_symlinks(units, symlink_dir)
        self.assertTrue(status)
        self.assertEqual(len(errors), 0)
        for u in units:
            symlink_path = os.path.join(symlink_dir, u.metadata["relativepath"])
            self.assertTrue(os.path.exists(symlink_path))
            self.assertTrue(os.path.islink(symlink_path))
            target = os.readlink(symlink_path)
            self.assertEqual(target, u.storage_path)
        # Test republish is successful
        status, errors = distributor.handle_symlinks(units, symlink_dir)
        self.assertTrue(status)
        self.assertEqual(len(errors), 0)
        for u in units:
            symlink_path = os.path.join(symlink_dir, u.metadata["relativepath"])
            self.assertTrue(os.path.exists(symlink_path))
            self.assertTrue(os.path.islink(symlink_path))
            target = os.readlink(symlink_path)
            self.assertEqual(target, u.storage_path)
        # Simulate a package is deleted
        os.unlink(units[0].storage_path)
        status, errors = distributor.handle_symlinks(units, symlink_dir)
        self.assertFalse(status)
        self.assertEqual(len(errors), 1)
開發者ID:ehelms,項目名稱:pulp,代碼行數:41,代碼來源:test_distributor.py


注:本文中的yum_distributor.distributor.YumDistributor.handle_symlinks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。