Exemple #1
0
    def main(self):
        manifest = BundleManifest.read_from_fileobj(
            self.args['manifest'], privkey_filename=self.args['privatekey'])

        for part in manifest.image_parts:
            part_path = os.path.join(self.args['source'], part.filename)
            while part_path.startswith('./'):
                part_path = part_path[2:]
            if os.path.exists(part_path):
                part.filename = part_path
            else:
                raise RuntimeError(
                    "bundle part '{0}' does not exist; you may need to use "
                    "-s to specify where to find the bundle's parts"
                    .format(part_path))

        part_reader_out_r, part_reader_out_w = open_pipe_fileobjs()
        part_reader = multiprocessing.Process(
            target=self.__read_bundle_parts,
            args=(manifest, part_reader_out_w))
        part_reader.start()
        part_reader_out_w.close()
        waitpid_in_thread(part_reader.pid)

        image_filename = os.path.join(self.args['destination'],
                                      manifest.image_name)
        with open(image_filename, 'w') as image:
            unbundlestream = UnbundleStream.from_other(
                self, source=part_reader_out_r, dest=image,
                enc_key=manifest.enc_key, enc_iv=manifest.enc_iv,
                image_size=manifest.image_size,
                sha1_digest=manifest.image_digest,
                show_progress=self.args.get('show_progress', False))
            unbundlestream.main()
        return image_filename
 def main(self):
     manifest = self.fetch_manifest(
         self.service, privkey_filename=self.args['privatekey'])
     download_out_r, download_out_w = open_pipe_fileobjs()
     try:
         self.__create_download_pipeline(download_out_w)
     finally:
         download_out_w.close()
     image_filename = self.__open_dest(manifest)
     unbundlestream = UnbundleStream.from_other(
         self, source=download_out_r, dest=self.args['dest'],
         enc_key=manifest.enc_key, enc_iv=manifest.enc_iv,
         image_size=manifest.image_size, sha1_digest=manifest.image_digest,
         show_progress=self.args.get('show_progress', False))
     unbundlestream.main()
     return image_filename
 def main(self):
     manifest = self.fetch_manifest(
         self.service, privkey_filename=self.args['privatekey'])
     download_out_r, download_out_w = open_pipe_fileobjs()
     try:
         self.__create_download_pipeline(download_out_w)
     finally:
         download_out_w.close()
     image_filename = self.__open_dest(manifest)
     unbundlestream = UnbundleStream.from_other(
         self, source=download_out_r, dest=self.args['dest'],
         enc_key=manifest.enc_key, enc_iv=manifest.enc_iv,
         image_size=manifest.image_size, sha1_digest=manifest.image_digest,
         show_progress=self.args.get('show_progress', False))
     unbundlestream.main()
     return image_filename