def get_snapshot(self): """ Extracts the release and returns a Snapshot. A temporary folder is created for the snapshot. The initializer is expected to clean up after usage with `snapshot.clean_up()`. This will delete the associated temporary folder. """ tar_path = os.path.join(self.data_dir, self.archive_name) tmp_path = utils.temp_dir() tar_file = tarfile.open(tar_path) tar_file.extractall(tmp_path) tar_file.close() return parser.Snapshot(tmp_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 get_snapshot(self): ##### ARE THESE METHODS EVEN NECESSARY? CLEAN IT UP. """ Returns the path of a temporary directory containing the pulled source. """ return utils.temp_dir(self.pull())