def start(self, snapshot): self.snapshot = snapshot self.snapshot.run_build_plugins(self) self.snapshot.run_pre_deploy_plugins(self) template_path = os.path.join(settings.STRETCH_CACHE_DIR, 'templates', str(self.environment.pk)) with self.snapshot.mount_templates(template_path): yield utils.clear_path(template_path) self.snapshot.run_post_deploy_plugins(self) utils.delete_path(self.snapshot.path) if self.existing_snapshot: utils.delete_path(self.existing_snapshot.path)
def create(cls, path, system): """ Creates, and processes, and archives a release. Emits a `release_created` signal upon completion. :Parameters: - `path`: the path to create the release from. - `system`: the system to associate the release with. """ release = cls( name=utils.generate_memorable_name(), sha=utils.generate_random_hex(28), system=system ) # Copy to temporary directory tmp_path = utils.temp_dir(path) # Create snapshot snapshot = parser.Snapshot(tmp_path) # Build release from snapshot # Archive the release utils.clear_path(release.data_dir) # Tar release buffer tar_path = os.path.join(release.data_dir, cls.archive_name) tar_file = tarfile.open(tar_path, 'w:gz') tar_file.add(tmp_path, '/') tar_file.close() # Build docker images snapshot.build_and_push(release, system) # Delete snapshot buffer utils.delete_path(tmp_path) # Build finished release.save() signals.release_created.send(sender=release) return release
def create(cls, path, system): """ Creates, and processes, and archives a release. Emits a `release_created` signal upon completion. :Parameters: - `path`: the path to create the release from. - `system`: the system to associate the release with. """ release = cls(name=utils.generate_memorable_name(), sha=utils.generate_random_hex(28), system=system) # Copy to temporary directory tmp_path = utils.temp_dir(path) # Create snapshot snapshot = parser.Snapshot(tmp_path) # Build release from snapshot # Archive the release utils.clear_path(release.data_dir) # Tar release buffer tar_path = os.path.join(release.data_dir, cls.archive_name) tar_file = tarfile.open(tar_path, 'w:gz') tar_file.add(tmp_path, '/') tar_file.close() # Build docker images snapshot.build_and_push(release, system) # Delete snapshot buffer utils.delete_path(tmp_path) # Build finished release.save() signals.release_created.send(sender=release) return release
def clean_up(self): utils.delete_path(self.path)