#3198 kiwi.result.json support + disk_image format support
Closed 2 years ago by tkopecek. Opened 2 years ago by ignatenkobrain.
ignatenkobrain/koji kiwi  into  master

file modified
+16 -10
@@ -1,5 +1,6 @@ 

  import glob

- # import json

+ import json

+ from json.decoder import JSONDecodeError

  import os

  import xml.dom.minidom

  from fnmatch import fnmatch
@@ -368,11 +369,16 @@ 

          if rv:

              raise koji.GenericError("Kiwi failed")

  

-         # result = json.load(open(joinpath(broot.rootdir(), target_dir[1:], 'kiwi.result'), 'rb'))

-         # nosec comment - we will replace it with json ASAP

-         import pickle

-         result = pickle.load(open(joinpath(broot.rootdir(), target_dir[1:],  # nosec

-                                            'kiwi.result'), 'rb'))

+         resultdir = joinpath(broot.rootdir(), target_dir[1:])

+         try:

+             # new version has json format, older pickle (needs python3-kiwi installed)

+             result_files = json.load(open(joinpath(resultdir, 'kiwi.result.json')))

+         except (FileNotFoundError, JSONDecodeError):

+             # try old variant

+             import pickle

+             result = pickle.load(open(joinpath(resultdir, 'kiwi.result'), 'rb')) # nosec

+             # convert from namedtuple's to normal dict

+             result_files = {k: v._asdict() for k, v in result.result_files.items()}

  

          imgdata = {

              'arch': arch,
@@ -397,11 +403,11 @@ 

          #     img_file = '%s.%s-%s.%s' % (name, version, arch, type)

          #     self.uploadFile(os.path.join(broot.rootdir()), remoteName=img_file)

          #     imgdata['files'].append(img_file)

-         for ftype in ('disk_format_image', 'installation_image'):

-             fdata = result.result_files.get(ftype)

+         for ftype in ('disk_image', 'disk_format_image', 'installation_image'):

+             fdata = result_files.get(ftype)

              if not fdata:

                  continue

-             fpath = os.path.join(broot.rootdir(), fdata.filename[1:])

+             fpath = os.path.join(broot.rootdir(), fdata['filename'][1:])

              img_file = os.path.basename(fpath)

              self.uploadFile(fpath, remoteName=os.path.basename(img_file))

              imgdata['files'].append(img_file)
@@ -410,7 +416,7 @@ 

              if False:

                  # should be used after kiwi update

                  fpath = os.path.join(broot.rootdir(),

-                                      result['result_files']['image_packages'].filename[1:])

+                                      result_files['image_packages'].filename[1:])

                  hdrlist = self.getImagePackages(fpath)

              else:

                  cachepath = os.path.join(broot.rootdir(), 'var/cache/kiwi/dnf')

rebased onto 8fcd8299dee5a6f8125fc3d3154c2c11162c0cac

2 years ago

rebased onto c115b20

2 years ago

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

Metadata Update from @tkopecek:
- Pull-request untagged with: testing-ready

2 years ago

Closing, will be used as part of #3205

Pull-Request has been closed by tkopecek

2 years ago
Metadata