本文整理汇总了Python中iso_distributor.distributor.ISODistributor.cleanup方法的典型用法代码示例。如果您正苦于以下问题:Python ISODistributor.cleanup方法的具体用法?Python ISODistributor.cleanup怎么用?Python ISODistributor.cleanup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iso_distributor.distributor.ISODistributor
的用法示例。
在下文中一共展示了ISODistributor.cleanup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_generate_isos
# 需要导入模块: from iso_distributor.distributor import ISODistributor [as 别名]
# 或者: from iso_distributor.distributor.ISODistributor import cleanup [as 别名]
def test_generate_isos(self):
repo = mock.Mock(spec=Repository)
repo.id = "test_repo_for_export"
repo.working_dir = self.repo_iso_working_dir
global progress_status
progress_status = None
def set_progress(progress):
global progress_status
progress_status = progress
publish_conduit = distributor_mocks.get_publish_conduit(pkg_dir=self.pkg_dir)
config = distributor_mocks.get_basic_config(
https_publish_dir=self.https_publish_dir,
http_publish_dir=self.http_publish_dir,
generate_metadata=True,
http=True,
https=False,
prefix="test-isos",
)
distributor = ISODistributor()
def cleanup():
return
distributor.cleanup = mock.Mock()
distributor.cleanup.side_effect = cleanup
publish_conduit.set_progress = mock.Mock()
publish_conduit.set_progress.side_effect = set_progress
progress_status = distributor.init_progress()
distributor.publish_repo(repo, publish_conduit, config)
repo.id = "test_mock_iso_prefix"
distributor.generate_isos(repo.working_dir, "%s/%s" % (self.http_publish_dir, repo.id), prefix="test-isos")
self.assertTrue("isos" in progress_status)
self.assertTrue(progress_status["isos"].has_key("state"))
self.assertEqual(progress_status["isos"]["state"], "FINISHED")
self.assertEqual(progress_status["isos"]["num_success"], 1)
self.assertTrue(progress_status["isos"]["size_total"] is not None)
self.assertEqual(progress_status["isos"]["size_left"], 0)
self.assertEqual(progress_status["isos"]["items_total"], 1)
self.assertEqual(progress_status["isos"]["items_left"], 0)
print progress_status
self.assertTrue(os.path.exists("%s/%s" % (self.http_publish_dir, repo.id)))
self.assertEquals(len(os.listdir(self.https_publish_dir)), 0)
isos_list = os.listdir("%s/%s" % (self.http_publish_dir, repo.id))
print isos_list
self.assertEqual(len(isos_list), 1)
# make sure the iso name defaults to repoid
self.assertTrue(isos_list[0].startswith("test-isos"))
示例2: test_iso_export_by_date_range
# 需要导入模块: from iso_distributor.distributor import ISODistributor [as 别名]
# 或者: from iso_distributor.distributor.ISODistributor import cleanup [as 别名]
#.........这里部分代码省略.........
'issued': '2010-03-30 08:07:30',
'pkglist': [{'name': 'RHEL Virtualization (v. 5 for 32-bit x86)',
'packages': [{'arch': 'x86_64',
'epoch': '0',
'filename': 'patb-0.1-2.x86_64.rpm',
'name': 'patb',
'release': '2',
'src': '',
'sum': ('sha',
'017c12050a97cf6095892498750c2a39d2bf535e'),
'version': '0.1'},
{'arch': 'x86_64',
'epoch': '0',
'filename': 'emoticons-0.1-2.x86_64.rpm',
'name': 'emoticons',
'release': '2',
'src': '',
'sum': ('sha',
'663c89b0d29bfd5479d8736b716d50eed9495dbb'),
'version': '0.1'}],
'short': 'rhel-i386-server-vt-5'}],
'pushcount': 1,
'reboot_suggested': False,
'references': [],
'release': '',
'rights': '',
'status': 'final',
'summary': '',
'title': 'emoticons enhancement fix and enhancement update',
'updated': '2010-03-30 08:07:30',
'version': '1',
'type' : 'enhancement',
'severity' : 'Low',
'solution' : ''}
unit_key_2 = dict()
unit_key_2['id'] = "RHEA-2008:9999"
mdata_2 = { 'description' : "test",
'from_str': '[email protected]',
'issued': '2008-03-30 00:00:00',
'pkglist': [{'name': 'RHEL Virtualization (v. 5 for 32-bit x86)',
'packages': [{'arch': 'x86_64',
'epoch': '0',
'filename': 'patb-0.1-2.x86_64.rpm',
'name': 'patb',
'release': '2',
'src': '',
'sum': ('sha',
'017c12050a97cf6095892498750c2a39d2bf535e'),
'version': '0.1'},
{'arch': 'x86_64',
'epoch': '0',
'filename': 'emoticons-0.1-2.x86_64.rpm',
'name': 'emoticons',
'release': '2',
'src': '',
'sum': ('sha',
'663c89b0d29bfd5479d8736b716d50eed9495dbb'),
'version': '0.1'}],
'short': 'rhel-i386-server-vt-5'}],
'pushcount': 1,
'reboot_suggested': False,
'references': [],
'release': '',
'rights': '',
'status': 'final',
'summary': '',
'title': 'emoticons enhancement fix and enhancement update',
'updated': '2008-03-30 00:00:00',
'version': '1',
'type' : 'enhancement',
'severity' : 'Low',
'solution' : ''}
errata_unit = [Unit(TYPE_ID_ERRATA, unit_key, mdata, ''), Unit(TYPE_ID_ERRATA, unit_key_2, mdata_2, '')]
existing_units += errata_unit
print existing_units
repo.working_dir = "%s/%s" % (self.repo_working_dir, "export")
iso_distributor = ISODistributor()
publish_conduit = distributor_mocks.get_publish_conduit(existing_units=existing_units, pkg_dir=self.pkg_dir)
# test http publish
config = distributor_mocks.get_basic_config(http_publish_dir=self.http_publish_dir, https_publish_dir=self.https_publish_dir, http=True, https=False,
start_date="2009-03-30 08:07:30", end_date="2012-03-30 08:07:30", generate_metadata=True)
def cleanup():
return
iso_distributor.cleanup = mock.Mock()
iso_distributor.cleanup.side_effect = cleanup
report = iso_distributor.publish_repo(repo, publish_conduit, config)
ftypes = util.get_repomd_filetypes("%s/%s" % (repo.working_dir, "repodata/repomd.xml"))
self.assertTrue("updateinfo" in ftypes)
updateinfo_path = "%s/%s" % (repo.working_dir, "updateinfo.xml")
self.assertTrue(os.path.exists(updateinfo_path))
elist = updateinfo.get_errata(updateinfo_path)
self.assertEquals(len(elist), 1)
self.assertTrue(unit_key_2['id'] not in elist[0])
self.assertEquals(elist[0]['id'], unit_key['id'])
self.assertEquals(elist[0]['issued'], mdata['issued'])
self.assertTrue(os.path.exists("%s/%s" % (self.http_publish_dir, repo.id)))
self.assertEquals(len(os.listdir(self.https_publish_dir)), 0)
isos_list = os.listdir("%s/%s" % (self.http_publish_dir, repo.id))
self.assertEqual(len(isos_list), 1)
示例3: test_iso_export_by_date_range
# 需要导入模块: from iso_distributor.distributor import ISODistributor [as 别名]
# 或者: from iso_distributor.distributor.ISODistributor import cleanup [as 别名]
#.........这里部分代码省略.........
],
"pushcount": 1,
"reboot_suggested": False,
"references": [],
"release": "",
"rights": "",
"status": "final",
"summary": "",
"title": "emoticons enhancement fix and enhancement update",
"updated": "2010-03-30 08:07:30",
"version": "1",
"type": "enhancement",
"severity": "Low",
"solution": "",
}
unit_key_2 = dict()
unit_key_2["id"] = "RHEA-2008:9999"
mdata_2 = {
"description": "test",
"from_str": "[email protected]",
"issued": "2008-03-30 00:00:00",
"pkglist": [
{
"name": "RHEL Virtualization (v. 5 for 32-bit x86)",
"packages": [
{
"arch": "x86_64",
"epoch": "0",
"filename": "patb-0.1-2.x86_64.rpm",
"name": "patb",
"release": "2",
"src": "",
"sum": ("sha", "017c12050a97cf6095892498750c2a39d2bf535e"),
"version": "0.1",
},
{
"arch": "x86_64",
"epoch": "0",
"filename": "emoticons-0.1-2.x86_64.rpm",
"name": "emoticons",
"release": "2",
"src": "",
"sum": ("sha", "663c89b0d29bfd5479d8736b716d50eed9495dbb"),
"version": "0.1",
},
],
"short": "rhel-i386-server-vt-5",
}
],
"pushcount": 1,
"reboot_suggested": False,
"references": [],
"release": "",
"rights": "",
"status": "final",
"summary": "",
"title": "emoticons enhancement fix and enhancement update",
"updated": "2008-03-30 00:00:00",
"version": "1",
"type": "enhancement",
"severity": "Low",
"solution": "",
}
errata_unit = [Unit(TYPE_ID_ERRATA, unit_key, mdata, ""), Unit(TYPE_ID_ERRATA, unit_key_2, mdata_2, "")]
existing_units += errata_unit
print existing_units
repo.working_dir = "%s/%s" % (self.repo_working_dir, "export")
iso_distributor = ISODistributor()
publish_conduit = distributor_mocks.get_publish_conduit(existing_units=existing_units, pkg_dir=self.pkg_dir)
# test http publish
config = distributor_mocks.get_basic_config(
http_publish_dir=self.http_publish_dir,
https_publish_dir=self.https_publish_dir,
http=True,
https=False,
start_date="2009-03-30 08:07:30",
end_date="2012-03-30 08:07:30",
generate_metadata=True,
)
def cleanup():
return
iso_distributor.cleanup = mock.Mock()
iso_distributor.cleanup.side_effect = cleanup
report = iso_distributor.publish_repo(repo, publish_conduit, config)
ftypes = util.get_repomd_filetypes("%s/%s" % (repo.working_dir, "repodata/repomd.xml"))
self.assertTrue("updateinfo" in ftypes)
updateinfo_path = "%s/%s" % (repo.working_dir, "updateinfo.xml")
self.assertTrue(os.path.exists(updateinfo_path))
elist = updateinfo.get_errata(updateinfo_path)
self.assertEquals(len(elist), 1)
self.assertTrue(unit_key_2["id"] not in elist[0])
self.assertEquals(elist[0]["id"], unit_key["id"])
self.assertEquals(elist[0]["issued"], mdata["issued"])
self.assertTrue(os.path.exists("%s/%s" % (self.http_publish_dir, repo.id)))
self.assertEquals(len(os.listdir(self.https_publish_dir)), 0)
isos_list = os.listdir("%s/%s" % (self.http_publish_dir, repo.id))
self.assertEqual(len(isos_list), 1)