diff mbox series

[13/14] runqemu: get_first_file() rename cmd* to glob*

Message ID 8f10918980e1e7ab6634b687f9c4325b71f1f319.1678709427.git.Martin.Jansa@gmail.com
State Accepted, archived
Commit 7c26e9dcc999a7d6a365831c39d25d98890be6d0
Headers show
Series [01/14] git-submodule-test: disable upstream version check | expand

Commit Message

Martin Jansa March 13, 2023, 12:15 p.m. UTC
* to better indicate how it's used in get_first_file

* cmd* is used in other places for actual shell commands
  to execute

* RunQemuError('KERNEL not found: %s, %s or %s' % cmds)
  also looked weird to me, but that works (to my python-noob surprise)

[YOCTO #12937]

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 scripts/runqemu | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/scripts/runqemu b/scripts/runqemu
index 58b0c191e1..32b0c5699c 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -116,10 +116,10 @@  def check_tun():
     if not os.access(dev_tun, os.W_OK):
         raise RunQemuError("TUN control device %s is not writable, please fix (e.g. sudo chmod 666 %s)" % (dev_tun, dev_tun))
 
-def get_first_file(cmds):
-    """Return first file found in wildcard cmds"""
-    for cmd in cmds:
-        all_files = glob.glob(cmd)
+def get_first_file(globs):
+    """Return first file found in wildcard globs"""
+    for g in globs:
+        all_files = glob.glob(g)
         if all_files:
             for f in all_files:
                 if not os.path.isdir(f):
@@ -676,12 +676,12 @@  class BaseConfig(object):
                     self.rootfs, self.get('MACHINE'),
                     self.fstype)
         elif not self.rootfs:
-            cmd_name = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_NAME'), self.fstype)
-            cmd_link = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_LINK_NAME'), self.fstype)
-            cmds = (cmd_name, cmd_link)
-            self.rootfs = get_first_file(cmds)
+            glob_name = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_NAME'), self.fstype)
+            glob_link = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_LINK_NAME'), self.fstype)
+            globs = (glob_name, glob_link)
+            self.rootfs = get_first_file(globs)
             if not self.rootfs:
-                raise RunQemuError("Failed to find rootfs: %s or %s" % cmds)
+                raise RunQemuError("Failed to find rootfs: %s or %s" % globs)
 
         if not os.path.exists(self.rootfs):
             raise RunQemuError("Can't find rootfs: %s" % self.rootfs)
@@ -741,10 +741,10 @@  class BaseConfig(object):
             kernel_match_name = "%s/%s" % (deploy_dir_image, kernel_name)
             kernel_match_link = "%s/%s" % (deploy_dir_image, self.get('KERNEL_IMAGETYPE'))
             kernel_startswith = "%s/%s*" % (deploy_dir_image, self.get('KERNEL_IMAGETYPE'))
-            cmds = (kernel_match_name, kernel_match_link, kernel_startswith)
-            self.kernel = get_first_file(cmds)
+            globs = (kernel_match_name, kernel_match_link, kernel_startswith)
+            self.kernel = get_first_file(globs)
             if not self.kernel:
-                raise RunQemuError('KERNEL not found: %s, %s or %s' % cmds)
+                raise RunQemuError('KERNEL not found: %s, %s or %s' % globs)
 
         if not os.path.exists(self.kernel):
             raise RunQemuError("KERNEL %s not found" % self.kernel)
@@ -761,13 +761,13 @@  class BaseConfig(object):
         dtb = self.get('QB_DTB')
         if dtb:
             deploy_dir_image = self.get('DEPLOY_DIR_IMAGE')
-            cmd_match = "%s/%s" % (deploy_dir_image, dtb)
-            cmd_startswith = "%s/%s*" % (deploy_dir_image, dtb)
-            cmd_wild = "%s/*.dtb" % deploy_dir_image
-            cmds = (cmd_match, cmd_startswith, cmd_wild)
-            self.dtb = get_first_file(cmds)
+            glob_match = "%s/%s" % (deploy_dir_image, dtb)
+            glob_startswith = "%s/%s*" % (deploy_dir_image, dtb)
+            glob_wild = "%s/*.dtb" % deploy_dir_image
+            globs = (glob_match, glob_startswith, glob_wild)
+            self.dtb = get_first_file(globs)
             if not os.path.exists(self.dtb):
-                raise RunQemuError('DTB not found: %s, %s or %s' % cmds)
+                raise RunQemuError('DTB not found: %s, %s or %s' % globs)
 
     def check_bios(self):
         """Check and set bios"""