async def run(self): """ Build and emit `DeclarativeContent` from the Manifest data. If a cookbook specifier is set in the remote, cookbooks are filtered using this specifier. """ with ProgressBar(message="Downloading Metadata", total=1) as pb: downloader = self.remote.get_downloader(url=urljoin(self.remote.url + "/", "universe")) result = await downloader.run() pb.increment() cookbook_names = self.remote.specifier_cookbook_names() with ProgressBar(message="Parsing Metadata") as pb: universe = Universe(result.path) for entry in universe.read(): if cookbook_names and entry.name not in cookbook_names: continue cookbook = CookbookPackageContent( name=entry.name, version=entry.version, dependencies=entry.dependencies ) artifact = Artifact() da = DeclarativeArtifact( artifact=artifact, url=entry.download_url, relative_path=cookbook.relative_path(), remote=self.remote, deferred_download=not self.download_artifacts, ) dc = DeclarativeContent(content=cookbook, d_artifacts=[da]) pb.increment() await self.put(dc)
def publish(repository_version_pk): """ Create a Publication based on a RepositoryVersion. Args: repository_version_pk (str): Create a publication from this repository version. """ repository_version = RepositoryVersion.objects.get( pk=repository_version_pk) log.info( _("Publishing: repository=%(repository)s, version=%(version)d"), { "repository": repository_version.repository.name, "version": repository_version.number }, ) with tempfile.TemporaryDirectory("."): with ProgressReport(message="Publishing Content", code="publishing.content") as progress_report: with CookbookPublication.create(repository_version) as publication: universe = Universe("__universe__") universe.write( populate(publication, progress_report=progress_report)) PublishedMetadata.create_from_file( relative_path=os.path.basename(universe.relative_path), publication=publication, file=File(open(universe.relative_path, "rb")), ) log.info(_("Publication: %(publication)s created"), {"publication": publication.pk})
def publish(publisher_pk, repository_version_pk): """ Use provided publisher to create a Publication based on a RepositoryVersion. Args: publisher_pk (str): Use the publish settings provided by this publisher. repository_version_pk (str): Create a publication from this repository version. """ publisher = CookbookPublisher.objects.get(pk=publisher_pk) repository_version = RepositoryVersion.objects.get( pk=repository_version_pk) log.info( _('Publishing: repository=%(repository)s, version=%(version)d, publisher=%(publisher)s' ), { 'repository': repository_version.repository.name, 'version': repository_version.number, 'publisher': publisher.name, }) with WorkingDirectory(): with Publication.create(repository_version, publisher) as publication: universe = Universe('__universe__') universe.write(populate(publication)) metadata = PublishedMetadata( relative_path=os.path.basename(universe.relative_path), publication=publication, file=File(open(universe.relative_path, 'rb'))) metadata.save() log.info(_('Publication: %(publication)s created'), {'publication': publication.pk})
def publish(repository_version_pk): """ Create a Publication based on a RepositoryVersion. Args: repository_version_pk (str): Create a publication from this repository version. """ repository_version = RepositoryVersion.objects.get( pk=repository_version_pk) log.info( _("Publishing: repository=%(repository)s, version=%(version)d"), { "repository": repository_version.repository.name, "version": repository_version.number }, ) with WorkingDirectory(): with CookbookPublication.create(repository_version) as publication: check_repo_version_constraint(publication) universe = Universe("__universe__") universe.write(populate(publication)) metadata = PublishedMetadata( relative_path=os.path.basename(universe.relative_path), publication=publication, file=File(open(universe.relative_path, "rb")), ) metadata.save() log.info(_("Publication: %(publication)s created"), {"publication": publication.pk})
async def __call__(self, in_q, out_q): """ Build and emit `DeclarativeContent` from the Manifest data. If a cookbook specifier is set in the remote, cookbooks are filtered using this specifier. Args: in_q (asyncio.Queue): Unused because the first stage doesn't read from an input queue. out_q (asyncio.Queue): The out_q to send `DeclarativeContent` objects to """ with ProgressBar(message='Downloading Metadata', total=1) as pb: downloader = self.remote.get_downloader( url=urljoin(self.remote.url + '/', 'universe')) result = await downloader.run() pb.increment() cookbook_names = self.remote.specifier_cookbook_names() with ProgressBar(message='Parsing Metadata') as pb: universe = Universe(result.path) for entry in universe.read(): if cookbook_names and entry.name not in cookbook_names: continue cookbook = CookbookPackageContent( name=entry.name, version=entry.version, dependencies=entry.dependencies) artifact = Artifact() da = DeclarativeArtifact(artifact, entry.download_url, cookbook.relative_path(), self.remote) dc = DeclarativeContent(content=cookbook, d_artifacts=[da]) pb.increment() await out_q.put(dc) await out_q.put(None)