• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.touch函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pulp.devel.unit.util.touch函数的典型用法代码示例。如果您正苦于以下问题:Python touch函数的具体用法?Python touch怎么用?Python touch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_process_main_only_publish_directory_contents

    def test_process_main_only_publish_directory_contents(self):
        source_dir = os.path.join(self.working_directory, 'source')
        master_dir = os.path.join(self.working_directory, 'master')
        publish_dir = os.path.join(self.working_directory, 'publish', 'bar')
        publish_dir += '/'
        step = publish_step.AtomicDirectoryPublishStep(
            source_dir, [('/', publish_dir)], master_dir, only_publish_directory_contents=True)
        step.parent = Mock(timestamp=str(time.time()))

        # create some files to test
        sub_file = os.path.join(source_dir, 'bar.html')
        touch(sub_file)

        # create an existing file that will be maintained
        existing_file = os.path.join(source_dir, 'bar.html')
        touch(existing_file)

        # Create an old directory to test
        old_dir = os.path.join(master_dir, 'foo')
        os.makedirs(old_dir)
        step.process_main()

        target_file = os.path.join(publish_dir, 'bar.html')
        self.assertEquals(True, os.path.exists(target_file))
        self.assertTrue(os.path.exists(existing_file))
        self.assertEquals(1, len(os.listdir(master_dir)))
开发者ID:goosemania,项目名称:pulp,代码行数:26,代码来源:test_publish_step.py


示例2: test_create_symlink_link_exists_not_link

    def test_create_symlink_link_exists_not_link(self):
        source_path = os.path.join(self.working_dir, 'source')
        link_path = os.path.join(self.published_dir, 'link')

        touch(source_path)
        touch(link_path)

        self.assertRaises(RuntimeError, PublishStep._create_symlink, source_path, link_path)
开发者ID:aweiteka,项目名称:pulp,代码行数:8,代码来源:test_publish_step.py


示例3: test_create_symlink

    def test_create_symlink(self):
        source_path = os.path.join(self.working_dir, "source")
        link_path = os.path.join(self.published_dir, "link")
        touch(source_path)

        self.assertFalse(os.path.exists(link_path))
        misc.create_symlink(source_path, link_path)
        self.assertTrue(os.path.exists(link_path))
开发者ID:pcreech,项目名称:pulp,代码行数:8,代码来源:test_misc.py


示例4: test_create_symlink_link_exists_not_link

    def test_create_symlink_link_exists_not_link(self):
        source_path = os.path.join(self.working_dir, "source")
        link_path = os.path.join(self.published_dir, "link")

        touch(source_path)
        touch(link_path)

        self.assertRaises(RuntimeError, misc.create_symlink, source_path, link_path)
开发者ID:pcreech,项目名称:pulp,代码行数:8,代码来源:test_misc.py


示例5: existing_files_saved

    def existing_files_saved(self):
        existing_file = os.path.join(self.destination_dir, 'foo.txt')
        touch(existing_file)
        new_dir = os.path.join(self.source_dir, 'bar')
        os.makedirs(new_dir)
        installdistributor.PuppetModuleInstallDistributor.\
            _move_to_destination_directory(self.source_dir, self.destination_dir)

        self.assertTrue(os.path.exists(existing_file))
开发者ID:hjensas,项目名称:pulp_puppet,代码行数:9,代码来源:test_install_distributor.py


示例6: test_create_symlink_no_link_parent

    def test_create_symlink_no_link_parent(self):
        source_path = os.path.join(self.working_dir, 'source')
        link_path = os.path.join(self.published_dir, 'foo/bar/baz/link')

        touch(source_path)
        self.assertFalse(os.path.exists(os.path.dirname(link_path)))

        PublishStep._create_symlink(source_path, link_path)

        self.assertTrue(os.path.exists(link_path))
开发者ID:aweiteka,项目名称:pulp,代码行数:10,代码来源:test_publish_step.py


示例7: test_clean_ophaned_leaf

 def test_clean_ophaned_leaf(self):
     """
     Test that an orphaned leaf is removed.
     """
     leaf = os.path.join(self.publish_base, 'a', 'b', 'c', 'listing')
     leaf_dir = os.path.dirname(leaf)
     util.touch(leaf)
     self.assertTrue(os.path.isfile(leaf))
     migration.clean_simple_hosting_directories(leaf_dir, self.publish_base)
     self.assertFalse(os.path.isdir(os.path.join(self.publish_base, 'a')))
开发者ID:ATIX-AG,项目名称:pulp_rpm,代码行数:10,代码来源:test_0021_clean_http_directories.py


示例8: test_walk_does_not_recognize_non_leaf

 def test_walk_does_not_recognize_non_leaf(self, mock_clean):
     """
     Test that non orphaned leafs are not cleaned.
     """
     non_orphan = os.path.join(self.publish_base, 'not', 'orphan', 'listing')
     other_file = os.path.join(self.publish_base, 'not', 'orphan', 'notlisting')
     util.touch(non_orphan)
     util.touch(other_file)
     migration.walk_and_clean_directories(self.publish_base)
     self.assertEqual(mock_clean.call_count, 0)
开发者ID:ATIX-AG,项目名称:pulp_rpm,代码行数:10,代码来源:test_0021_clean_http_directories.py


示例9: test_create_symlink_link_parent_bad_permissions

    def test_create_symlink_link_parent_bad_permissions(self):
        source_path = os.path.join(self.working_dir, 'source')
        link_path = os.path.join(self.published_dir, 'foo/bar/baz/link')

        touch(source_path)
        os.makedirs(os.path.dirname(link_path))
        os.chmod(os.path.dirname(link_path), 0000)

        self.assertRaises(OSError, PublishStep._create_symlink, source_path, link_path)

        os.chmod(os.path.dirname(link_path), 0777)
开发者ID:aweiteka,项目名称:pulp,代码行数:11,代码来源:test_publish_step.py


示例10: test_create_symlink_no_link_parent_with_permissions

    def test_create_symlink_no_link_parent_with_permissions(self, mock_makedirs, mock_symlink):
        source_path = os.path.join(self.working_dir, "source")
        link_path = os.path.join(self.published_dir, "foo/bar/baz/link")

        touch(source_path)
        self.assertFalse(os.path.exists(os.path.dirname(link_path)))

        misc.create_symlink(source_path, link_path, directory_permissions=0700)

        mock_makedirs.assert_called_once_with(os.path.dirname(link_path), mode=0700)
        mock_symlink.assert_called_once_with(source_path, link_path)
开发者ID:pcreech,项目名称:pulp,代码行数:11,代码来源:test_misc.py


示例11: test_clean_with_concurrent_file_creation

 def test_clean_with_concurrent_file_creation(self, mock_rmdir, mock_util):
     """
     Clean directories when a dir cannot be removed during orphaned directory removal.
     """
     mock_rmdir.side_effect = OSError()
     listing_file_a = os.path.join(self.publish_base, 'a', 'listing')
     updir = os.path.join(self.publish_base, 'a')
     util.touch(listing_file_a)
     old_symlink = os.path.join(self.publish_base, 'a', 'path_to_removed_symlink')
     self.distributor.clean_simple_hosting_directories(old_symlink, self.publish_base)
     mock_util.generate_listing_files.assert_called_once_with(updir, updir)
开发者ID:hjensas,项目名称:pulp_rpm,代码行数:11,代码来源:test_distributor.py


示例12: test_create_symlink_no_link_parent

    def test_create_symlink_no_link_parent(self, mock_makedirs, mock_symlink):
        source_path = os.path.join(self.working_dir, 'source')
        link_path = os.path.join(self.published_dir, 'foo/bar/baz/link')

        touch(source_path)
        self.assertFalse(os.path.exists(os.path.dirname(link_path)))

        misc.create_symlink(source_path, link_path)

        mock_makedirs.assert_called_once_with(os.path.dirname(link_path), mode=0770)
        mock_symlink.assert_called_once_with(source_path, link_path)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:11,代码来源:test_misc.py


示例13: test_clear_directory

    def test_clear_directory(self):

        for file_name in ('one', 'two', 'three'):
            touch(os.path.join(self.working_dir, file_name))

        os.makedirs(os.path.join(self.working_dir, 'four'))
        self.assertEqual(len(os.listdir(self.working_dir)), 4)

        misc.clear_directory(self.working_dir, ['two'])

        self.assertEqual(len(os.listdir(self.working_dir)), 1)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:11,代码来源:test_misc.py


示例14: test_process_unit

 def test_process_unit(self):
     step = publish_steps.PublishImagesStep()
     fake_image_filename = 'fake-zero-byte-image.qcow2'
     touch(os.path.join(self.content_directory, fake_image_filename))
     unit = Mock(unit_key={'image_checksum': 'd41d8cd98f00b204e9800998ecf8427e'},
                 storage_path=os.path.join(self.content_directory, fake_image_filename))
     step.get_working_dir = Mock(return_value=self.publish_directory)
     step.process_unit(unit)
     # verify symlink
     expected_symlink = os.path.join(self.publish_directory, 'web', fake_image_filename)
     self.assertTrue(os.path.exists(expected_symlink))
开发者ID:pombreda,项目名称:pulp_openstack,代码行数:11,代码来源:test_publish_steps.py


示例15: test_create_symlink

    def test_create_symlink(self):
        source_path = os.path.join(self.working_dir, 'source')
        link_path = os.path.join(self.published_dir, 'link')

        touch(source_path)
        self.assertFalse(os.path.exists(link_path))

        PublishStep._create_symlink(source_path, link_path)

        self.assertTrue(os.path.exists(link_path))
        self.assertTrue(os.path.islink(link_path))
        self.assertEqual(os.readlink(link_path), source_path)
开发者ID:aweiteka,项目名称:pulp,代码行数:12,代码来源:test_publish_step.py


示例16: test_distributor_removed

    def test_distributor_removed(self, mock_repo_dir):
        mock_repo_dir.return_value = os.path.join(self.working_dir, 'repo')
        os.makedirs(mock_repo_dir.return_value)
        working_dir = os.path.join(self.working_dir, 'working')
        repo = Mock(id='bar', working_dir=working_dir)
        config = {}
        touch(os.path.join(working_dir, 'bar.json'))
        touch(os.path.join(mock_repo_dir.return_value, 'bar.tar'))
        self.distributor.distributor_removed(repo, config)

        self.assertEquals(0, len(os.listdir(mock_repo_dir.return_value)))
        self.assertEquals(1, len(os.listdir(self.working_dir)))
开发者ID:bowlofeggs,项目名称:pulp_docker,代码行数:12,代码来源:test_distributor_export.py


示例17: test_distributor_removed

    def test_distributor_removed(self, mock_web, mock_master, mock_app, m_repo_objects):
        m_repo_objects.get_repo_or_missing_resource.return_value = Mock(repo_id='bar')
        mock_app.return_value = os.path.join(self.working_dir)
        mock_web.return_value = os.path.join(self.working_dir, 'web')
        mock_master.return_value = os.path.join(self.working_dir, 'master')
        os.makedirs(mock_web.return_value)
        os.makedirs(mock_master.return_value)
        repo = Mock(id='bar')
        config = {}
        touch(os.path.join(self.working_dir, 'bar.json'))
        self.distributor.distributor_removed(repo, config)

        self.assertEquals(0, len(os.listdir(self.working_dir)))
开发者ID:jeremycline,项目名称:pulp_docker,代码行数:13,代码来源:test_distributor_web.py


示例18: test_process_main

    def test_process_main(self):
        source_dir = os.path.join(self.working_directory, 'source')
        os.makedirs(source_dir)
        target_file = os.path.join(self.working_directory, 'target', 'target.tar')
        step = publish_step.SaveTarFilePublishStep(source_dir, target_file)

        touch(os.path.join(source_dir, 'foo.txt'))
        step.process_main()

        with contextlib.closing(tarfile.open(target_file)) as tar_file:
            names = tar_file.getnames()
            # the first item is either '' or '.' depending on if this is py2.7 or py2.6
            self.assertEquals(names[1:], ['foo.txt'])
开发者ID:goosemania,项目名称:pulp,代码行数:13,代码来源:test_publish_step.py


示例19: test_create_symlink_link_exists_and_is_correct

    def test_create_symlink_link_exists_and_is_correct(self):
        new_source_path = os.path.join(self.working_dir, 'new_source')
        link_path = os.path.join(self.published_dir, 'link')

        touch(new_source_path)

        os.symlink(new_source_path, link_path)

        self.assertEqual(os.readlink(link_path), new_source_path)

        PublishStep._create_symlink(new_source_path, link_path)

        self.assertEqual(os.readlink(link_path), new_source_path)
开发者ID:aweiteka,项目名称:pulp,代码行数:13,代码来源:test_publish_step.py


示例20: test_create_symlink_link_exists_and_is_correct

    def test_create_symlink_link_exists_and_is_correct(self):
        new_source_path = os.path.join(self.working_dir, "new_source")
        link_path = os.path.join(self.published_dir, "link")

        touch(new_source_path)

        os.symlink(new_source_path, link_path)

        self.assertEqual(os.readlink(link_path), new_source_path)

        misc.create_symlink(new_source_path, link_path)

        self.assertEqual(os.readlink(link_path), new_source_path)
开发者ID:pcreech,项目名称:pulp,代码行数:13,代码来源:test_misc.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python repo_publish.RepoPublishConduit类代码示例发布时间:2022-05-25
下一篇:
Python util.compare_dict函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap