Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def retrieve(self, request, **kwargs):
"""
__Method__: `GET`
__URL__: $LINK:composerpm-detail:compose_id$
This API end-point allows retrieving RPM manifest for a given compose.
It will return the exact same data as was imported.
"""
compose = get_object_or_404(Compose, compose_id=kwargs['compose_id'])
crpms = ComposeRPM.objects.filter(variant_arch__variant__compose=compose) \
.select_related('variant_arch__variant', 'variant_arch__arch', 'rpm', 'path') \
.prefetch_related('sigkey', 'content_category')
manifest = Rpms()
manifest.compose.date = compose.compose_date.strftime('%Y%m%d')
manifest.compose.id = compose.compose_id
manifest.compose.respin = compose.compose_respin
manifest.compose.type = compose.compose_type.name
for crpm in crpms:
arch = crpm.variant_arch.arch.name
path = (os.path.join(crpm.path.path, crpm.rpm.filename)
if crpm.path and crpm.rpm.filename
else None)
if crpm.rpm.arch == 'src':
srpm_nevra = None
else:
srpm_nevra = crpm.rpm.srpm_nevra
def compose__import_rpms(request, release_id, composeinfo, rpm_manifest):
release_obj = release_models.Release.objects.get(release_id=release_id)
ci = productmd.composeinfo.ComposeInfo()
common_hacks.deserialize_wrapper(ci.deserialize, composeinfo)
rm = Rpms()
common_hacks.deserialize_wrapper(rm.deserialize, rpm_manifest)
_maybe_raise_inconsistency_error(ci, rm, 'rpms')
compose_date = "%s-%s-%s" % (ci.compose.date[:4], ci.compose.date[4:6], ci.compose.date[6:])
compose_type = models.ComposeType.objects.get(name=ci.compose.type)
acceptance_status = models.ComposeAcceptanceTestingState.objects.get(name='untested')
compose_obj, created = lib._logged_get_or_create(
request, models.Compose,
release=release_obj,
compose_id=ci.compose.id,
compose_date=compose_date,
compose_type=compose_type,
compose_respin=ci.compose.respin,
compose_label=ci.compose.label or None,
acceptance_testing=acceptance_status,