Add stable/2402 branch and remove stable/2306 branch to docker executor image scripts
[ci-management.git] / docker / scripts / dbld_csit_find_ansible_packages.py
index 2e6c6cf..52ed4c3 100755 (executable)
@@ -1,6 +1,6 @@
 #! /usr/bin/env python3
 
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -39,8 +39,13 @@ class CsitAnsibleYamlStruct:
 def packages_in_csit_ansible_yaml_file(yamlfile: str, distro, arch) -> list:
     with open(yamlfile) as yf:
         csit_ansible_yaml = yaml.safe_load(yf)
+        if csit_ansible_yaml is None:
+            return ""
         cays = CsitAnsibleYamlStruct(**csit_ansible_yaml)
-        packages = [pkg for pkg in cays.packages_base if type(pkg) is str]
+        try:
+            packages = [pkg for pkg in cays.packages_base if type(pkg) is str]
+        except AttributeError:
+            return ""
         if arch in [*cays.packages_by_arch]:
             packages += [pkg for pkg in cays.packages_by_arch[arch]
                          if type(pkg) is str]
@@ -53,7 +58,7 @@ def is_csit_ansible_yaml_file(filename: str):
      (root,ext) = os.path.splitext(filename)
      if ext == '.yaml' \
         and filename.find('csit/') >= 0 \
-        and filename.find('/ansible/') > 0 \
+        and filename.find('ansible/') > 0 \
         and os.path.isfile(filename):
          return True
      else:
@@ -70,8 +75,6 @@ def main(args: List[str]) -> None:
     for arg in args:
         if arg.lower() == '--ubuntu':
             distro = 'ubuntu'
-        elif arg.lower() == '--centos':
-            distro = 'centos'
         elif arg.lower() == '--x86_64':
             arch = 'x86_64'
         elif arg.lower() == '--aarch64':