本文整理匯總了Python中yum_importer.importer.YumImporter._sync_repo方法的典型用法代碼示例。如果您正苦於以下問題:Python YumImporter._sync_repo方法的具體用法?Python YumImporter._sync_repo怎麽用?Python YumImporter._sync_repo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yum_importer.importer.YumImporter
的用法示例。
在下文中一共展示了YumImporter._sync_repo方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_repo_scratchpad_settings
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _sync_repo [as 別名]
def test_repo_scratchpad_settings(self):
global repo_scratchpad
repo_scratchpad = {}
def set_repo_scratchpad(data):
global repo_scratchpad
repo_scratchpad = data
def get_repo_scratchpad():
global repo_scratchpad
return repo_scratchpad
feed_url = "http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/test_drpm_repo/"
importer = YumImporter()
repo = mock.Mock(spec=Repository)
repo.working_dir = self.working_dir
repo.id = "test_repo_scratchpad"
sync_conduit = importer_mocks.get_sync_conduit(pkg_dir=self.pkg_dir)
sync_conduit.set_repo_scratchpad = mock.Mock()
sync_conduit.set_repo_scratchpad.side_effect = set_repo_scratchpad
sync_conduit.get_repo_scratchpad = mock.Mock()
sync_conduit.get_repo_scratchpad.side_effect = get_repo_scratchpad
config = importer_mocks.get_basic_config(feed_url=feed_url)
importer._sync_repo(repo, sync_conduit, config)
print "SCRATCHPAD %s" % repo_scratchpad
self.assertEquals(repo_scratchpad['checksum_type'], 'sha256')
self.assertTrue(repo_scratchpad.has_key("repodata"))
self.assertTrue(repo_scratchpad["repodata"].has_key("prestodelta"))
示例2: test_progress_sync
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _sync_repo [as 別名]
def test_progress_sync(self):
global updated_progress
updated_progress = None
def set_progress(progress):
global updated_progress
updated_progress = progress
feed_url = "http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/pulp_unittest/"
importer = YumImporter()
repo = mock.Mock(spec=Repository)
repo.working_dir = self.working_dir
repo.id = "test_progress_sync"
sync_conduit = importer_mocks.get_sync_conduit(pkg_dir=self.pkg_dir)
sync_conduit.set_progress = mock.Mock()
sync_conduit.set_progress.side_effect = set_progress
config = importer_mocks.get_basic_config(feed_url=feed_url)
status, summary, details = importer._sync_repo(repo, sync_conduit, config)
self.assertTrue(status)
self.assertEquals(summary["packages"]["num_synced_new_rpms"], 3)
self.assertTrue(updated_progress is not None)
self.assertTrue("metadata" in updated_progress)
self.assertTrue(updated_progress["metadata"].has_key("state"))
self.assertTrue("errata" in updated_progress)
self.assertTrue(updated_progress["errata"].has_key("state"))
self.assertTrue("content" in updated_progress)
self.assertTrue(updated_progress["content"].has_key("state"))
self.assertEquals(updated_progress["content"]["state"], "FINISHED")
for key in importer_rpm.PROGRESS_REPORT_FIELDS:
self.assertTrue(key in updated_progress["content"])
示例3: test_skip_packagegroups
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _sync_repo [as 別名]
def test_skip_packagegroups(self):
global updated_progress
updated_progress = None
def set_progress(progress):
global updated_progress
updated_progress = progress
yi = YumImporter()
skip = ["packagegroup"]
repo_src_dir = os.path.join(self.data_dir, "pulp_unittest")
feed_url = "file://%s" % (repo_src_dir)
config = importer_mocks.get_basic_config(feed_url=feed_url,skip_content_types=skip)
repo = mock.Mock(spec=Repository)
repo.working_dir = self.working_dir
repo.id = "test_skip_packagegroup"
# Simulate a repo sync, copy the source contents to the repo.working_dir
self.simulate_sync(repo, repo_src_dir)
sync_conduit = importer_mocks.get_sync_conduit(pkg_dir=self.pkg_dir)
sync_conduit.set_progress = mock.Mock()
sync_conduit.set_progress = set_progress
status, summary, details = yi._sync_repo(repo, sync_conduit, config)
self.assertTrue(status)
self.assertEqual(updated_progress["comps"]["state"], "SKIPPED")
示例4: test_feedless_repo_sync
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _sync_repo [as 別名]
def test_feedless_repo_sync(self):
repo = mock.Mock(spec=Repository)
repo.working_dir = self.working_dir
repo.id = "test_feedless_repo_sync"
sync_conduit = importer_mocks.get_sync_conduit(type_id=TYPE_ID_RPM, pkg_dir=self.pkg_dir)
sync_conduit.set_progress = mock.Mock()
config = importer_mocks.get_basic_config()
importer = YumImporter()
status, summary, details = importer._sync_repo(repo, sync_conduit, config)
self.assertFalse(status)
self.assertEquals(summary['error'], "Cannot perform repository sync on a repository with no feed")
示例5: setup_source_repo
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _sync_repo [as 別名]
def setup_source_repo(self):
# Sync a sample repository to populate and setup up Source Repo
source_repo = mock.Mock(spec=Repository)
source_repo.id = "repo_a"
source_repo.working_dir = os.path.join(self.working_dir, source_repo.id)
importer = YumImporter()
feed_url = "file://%s/pulp_unittest/" % (self.data_dir)
config = importer_mocks.get_basic_config(feed_url=feed_url)
sync_conduit = importer_mocks.get_sync_conduit(existing_units=[], pkg_dir=self.pkg_dir)
status, summary, details = importer._sync_repo(source_repo, sync_conduit, config)
self.assertTrue(status)
self.assertEquals(summary["packages"]["num_synced_new_rpms"], 3)
# Confirm regular RPM files exist under self.pkg_dir
pkgs = self.get_files_in_dir("*.rpm", self.pkg_dir)
self.assertEquals(len(pkgs), 3)
for p in pkgs:
self.assertTrue(os.path.isfile(p))
# Confirm symlinks to RPMs exist under repo.working_dir
sym_links = self.get_files_in_dir("*.rpm", source_repo.working_dir)
self.assertEquals(len(pkgs), 3)
for link in sym_links:
self.assertTrue(os.path.islink(link))
#
# Now we have some test data in the source repo
#
# Simulate what import_conduit.get_source_repos would return
#
metadata = {}
source_units = []
storage_path = '%s/pulp-dot-2.0-test/0.1.2/1.fc11/x86_64/435d92e6c09248b501b8d2ae786f92ccfad69fab8b1bc774e2b66ff6c0d83979/pulp-dot-2.0-test-0.1.2-1.fc11.x86_64.rpm' % (self.pkg_dir)
filename = os.path.basename(storage_path)
unit_key = {"filename":filename}
source_units.append(Unit(TYPE_ID_RPM, unit_key, metadata, storage_path))
storage_path = '%s/pulp-test-package/0.3.1/1.fc11/x86_64/6bce3f26e1fc0fc52ac996f39c0d0e14fc26fb8077081d5b4dbfb6431b08aa9f/pulp-test-package-0.3.1-1.fc11.x86_64.rpm' % (self.pkg_dir)
filename = os.path.basename(storage_path)
unit_key = {"filename":filename}
source_units.append(Unit(TYPE_ID_RPM, unit_key, metadata, storage_path))
storage_path = '%s/pulp-test-package/0.2.1/1.fc11/x86_64/4dbde07b4a8eab57e42ed0c9203083f1d61e0b13935d1a569193ed8efc9ecfd7/pulp-test-package-0.2.1-1.fc11.x86_64.rpm' % (self.pkg_dir)
filename = os.path.basename(storage_path)
unit_key = {"filename":filename}
source_units.append(Unit(TYPE_ID_RPM, unit_key, metadata, storage_path))
# Pass in the simulated source_units to the import_conduit
import_conduit = importer_mocks.get_import_conduit(source_units=source_units)
return importer, source_repo, source_units, import_conduit, config
示例6: test_errors_with_local_sync
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _sync_repo [as 別名]
def test_errors_with_local_sync(self):
if os.getuid() == 0:
# skip if running as root
return
global updated_progress
updated_progress = None
def set_progress(progress):
global updated_progress
updated_progress = progress
importer = YumImporter()
feed_url = "file://%s/local_errors/" % (self.data_dir)
repo = mock.Mock(spec=Repository)
repo.working_dir = self.working_dir
repo.id = "test_errors_with_local_sync"
sync_conduit = importer_mocks.get_sync_conduit(existing_units=[], pkg_dir=self.pkg_dir)
sync_conduit.set_progress = mock.Mock()
sync_conduit.set_progress.side_effect = set_progress
config = importer_mocks.get_basic_config(feed_url=feed_url)
test_rpm_with_error = os.path.join(self.data_dir, "local_errors", "pulp-test-package-0.3.1-1.fc11.x86_64.rpm")
orig_stat = os.stat(test_rpm_with_error)
try:
os.chmod(test_rpm_with_error, 0000)
self.assertFalse(os.access(test_rpm_with_error, os.R_OK))
status, summary, details = importer._sync_repo(repo, sync_conduit, config)
finally:
os.chmod(test_rpm_with_error, orig_stat.st_mode)
self.assertFalse(status)
self.assertTrue(summary is not None)
self.assertTrue(details is not None)
self.assertEquals(summary["packages"]["num_not_synced_rpms"], 1)
self.assertEquals(details["packages"]["size_total"], 6791)
# Confirm regular RPM files exist under self.pkg_dir
pkgs = self.get_files_in_dir("*.rpm", self.pkg_dir)
self.assertEquals(len(pkgs), 2)
sym_links = self.get_files_in_dir("*.rpm", repo.working_dir)
self.assertEquals(len(pkgs), 2)
expected_details = {
'rpm':
{
'num_success': 2, 'total_count': 3, 'items_left': 0,
'size_left': 0.0, 'total_size_bytes': 6791, 'num_error': 1
}
}
self.assertTrue(updated_progress.has_key("metadata"))
self.assertEqual(updated_progress["metadata"]["state"], "FINISHED")
self.assertTrue(updated_progress.has_key("errata"))
self.assertEqual(updated_progress["errata"]["state"], "FINISHED")
self.assertEqual(updated_progress["errata"]["num_errata"], 52)
self.assertTrue(updated_progress.has_key("content"))
self.assertEqual(updated_progress["content"]["state"], "FINISHED")
self.assertEqual(updated_progress["content"]["items_total"], 3)
self.assertEqual(updated_progress["content"]["items_left"], 0)
self.assertEqual(updated_progress["content"]["num_success"], 2)
self.assertEqual(updated_progress["content"]["num_error"], 1)
self.assertEqual(updated_progress["content"]["size_total"], 6791)
self.assertEqual(updated_progress["content"]["size_left"], 0)
for type_id in (BaseFetch.FILE, BaseFetch.TREE_FILE, BaseFetch.DELTA_RPM):
self.assertTrue(updated_progress["content"]["details"].has_key(type_id))
self.assertEqual(updated_progress["content"]["details"][type_id]["num_success"], 0)
self.assertEqual(updated_progress["content"]["details"][type_id]["num_error"], 0)
self.assertEqual(updated_progress["content"]["details"][type_id]["size_total"], 0)
self.assertEqual(updated_progress["content"]["details"][type_id]["size_left"], 0)
self.assertEqual(updated_progress["content"]["details"][type_id]["items_total"], 0)
self.assertEqual(updated_progress["content"]["details"][type_id]["items_left"], 0)
# 'rpm': {'num_success': 2, 'size_total': 6791, 'items_left': 0,
# 'items_total': 3, 'size_left': 0.0, 'num_error': 1}
self.assertTrue(updated_progress["content"]["details"].has_key("rpm"))
self.assertEqual(updated_progress["content"]["details"]["rpm"]["num_success"], 2)
self.assertEqual(updated_progress["content"]["details"]["rpm"]["num_error"], 1)
self.assertEqual(updated_progress["content"]["details"]["rpm"]["size_total"], 6791)
self.assertEqual(updated_progress["content"]["details"]["rpm"]["size_left"], 0)
self.assertEqual(updated_progress["content"]["details"]["rpm"]["items_total"], 3)
self.assertEqual(updated_progress["content"]["details"]["rpm"]["items_left"], 0)
#
# Check error_details
# error has keys of: {"error_type", "traceback", "value", "exception"}
#
self.assertEqual(len(updated_progress["content"]["error_details"]), 1)
error = updated_progress["content"]["error_details"][0]
self.assertEqual(error["filename"], "pulp-test-package-0.3.1-1.fc11.x86_64.rpm")
self.assertEqual(error["value"],
'(37, "Couldn\'t open file %s")' % (test_rpm_with_error))
self.assertTrue('pycurl.error' in error["error_type"])
self.assertTrue(isinstance(error["exception"], basestring))
self.assertTrue(len(error["traceback"]) > 0)
示例7: setup_source_repo
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _sync_repo [as 別名]
def setup_source_repo(self):
# Sync a sample repository to populate and setup up Source Repo
source_repo = mock.Mock(spec=Repository)
source_repo.id = "repo_a"
source_repo.working_dir = os.path.join(self.working_dir, source_repo.id)
importer = YumImporter()
feed_url = "file://%s/pulp_unittest/" % (self.data_dir)
config = importer_mocks.get_basic_config(feed_url=feed_url)
sync_conduit = importer_mocks.get_sync_conduit(existing_units=[], pkg_dir=self.pkg_dir)
status, summary, details = importer._sync_repo(source_repo, sync_conduit, config)
self.assertTrue(status)
self.assertEquals(summary["packages"]["num_synced_new_rpms"], 3)
#
# Now we have some test data in the source repo
#
# Simulate what import_conduit.get_source_repos would return
#
source_units = []
storage_path = '%s/pulp-dot-2.0-test/0.1.2/1.fc11/x86_64/435d92e6c09248b501b8d2ae786f92ccfad69fab8b1bc774e2b66ff6c0d83979/pulp-dot-2.0-test-0.1.2-1.fc11.x86_64.rpm' % (self.pkg_dir)
filename = os.path.basename(storage_path)
unit_key = {
'name':'pulp-dot-2.0-test',
'version':'0.1.2',
'release':'1.fc11',
'epoch':'0',
'arch':'x86_64',
'checksum':'435d92e6c09248b501b8d2ae786f92ccfad69fab8b1bc774e2b66ff6c0d83979',
'checksumtype':'sha256',
}
metadata = {
'filename':filename
}
source_units.append(Unit(TYPE_ID_RPM, unit_key, metadata, storage_path))
storage_path = '%s/pulp-test-package/0.3.1/1.fc11/x86_64/6bce3f26e1fc0fc52ac996f39c0d0e14fc26fb8077081d5b4dbfb6431b08aa9f/pulp-test-package-0.3.1-1.fc11.x86_64.rpm' % (self.pkg_dir)
filename = os.path.basename(storage_path)
unit_key = {
'name':'pulp-test-package',
'version':'0.3.1',
'release':'1.fc11',
'epoch':'0',
'arch':'x86_64',
'checksum':'6bce3f26e1fc0fc52ac996f39c0d0e14fc26fb8077081d5b4dbfb6431b08aa9f',
'checksumtype':'sha256',
}
metadata = {
'filename':filename
}
source_units.append(Unit(TYPE_ID_RPM, unit_key, metadata, storage_path))
storage_path = '%s/pulp-test-package/0.2.1/1.fc11/x86_64/4dbde07b4a8eab57e42ed0c9203083f1d61e0b13935d1a569193ed8efc9ecfd7/pulp-test-package-0.2.1-1.fc11.x86_64.rpm' % (self.pkg_dir)
filename = os.path.basename(storage_path)
unit_key = {
'name':'pulp-test-package',
'version':'0.2.1',
'release':'1.fc11',
'epoch':'0',
'arch':'x86_64',
'checksum':'4dbde07b4a8eab57e42ed0c9203083f1d61e0b13935d1a569193ed8efc9ecfd7',
'checksumtype':'sha256',
}
metadata = {
'filename':filename
}
source_units.append(Unit(TYPE_ID_RPM, unit_key, metadata, storage_path))
# Pass in the simulated source_units to the import_conduit
import_conduit = importer_mocks.get_import_conduit(source_units=source_units, existing_units=source_units)
return importer, source_repo, source_units, import_conduit, config