#696 Raise a ValueError with details if module not found in PDC.
Closed 6 years ago by lsedlar. Opened 6 years ago by ralph.
ralph/pungi warn-if-no-module  into  master

@@ -83,12 +83,10 @@ 

  

  

  @retry(wait_on=IOError)

- def get_module(session, module_info, strict=False):

+ def get_module(session, module_info)

      """

      :param session : PDCClient instance

      :param module_info: pdc variant_dict, str, mmd or module dict

-     :param strict: Normally this function returns None if no module can be

-            found.  If strict=True, then a ValueError is raised.

  

      :return final list of module_info which pass repoclosure

      """
@@ -105,12 +103,9 @@ 

  

      retval = session['unreleasedvariants'](page_size=-1, **query)

  

-     # Error handling

+     # Error reporting

      if not retval:

-         if strict:

-             raise ValueError("Failed to find module in PDC %r" % query)

-         else:

-             return None

+         raise ValueError("Failed to find module in PDC %r" % query)

  

      module = None

      # If we specify 'variant_release', we expect only single module to be
@@ -179,7 +174,7 @@ 

          # to compose_tags list.

          if session:

              for module in variant.get_modules():

-                 pdc_module = get_module(session, module["name"], strict=True)

+                 pdc_module = get_module(session, module["name"])

                  mmd = modulemd.ModuleMetadata()

                  mmd.loads(pdc_module["modulemd"])

  

Currently, this will fail two lines later when we try to access
pdc_module['modulemd'] with an unhelpful TypeError since
pdc_module is None.

Signed-off-by: Ralph Bean rbean@redhat.com

Looks good to me. Should strict=True be the default? Or maybe the only option?

Nothing else here uses it... so we could simplify, yes. Will patch.

1 new commit added

  • Make strict the only option.
6 years ago

rebased

6 years ago

I just merged this outside of Pagure with a fix for the tests.

Pull-Request has been closed by lsedlar

6 years ago