[OE-core] [PATCH 2/4] runqemu: use glob rather than calling out to ls
Robert Yang
liezhi.yang at windriver.com
Mon Sep 5 14:51:34 UTC 2016
On 09/05/2016 09:59 PM, Joshua Lock wrote:
> Use the Python glob module to find files matching a pattern, rather
> than calling out to ls and parsing the output.
>
> Signed-off-by: Joshua Lock <joshua.g.lock at intel.com>
> ---
> scripts/runqemu | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/runqemu b/scripts/runqemu
> index 72c6352..1599848 100755
> --- a/scripts/runqemu
> +++ b/scripts/runqemu
> @@ -528,11 +528,10 @@ class BaseConfig(object):
> self.qemuboot = "%s/%s-%s.qemuboot.conf" % (deploy_dir_image,
> self.rootfs, machine)
> else:
> - cmd = 'ls -t %s/*.qemuboot.conf' % deploy_dir_image
> - logger.info('Running %s...' % cmd)
> - qbs = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
> + import glob
> + qbs = glob.glob('%s/*.qemuboot.conf' % deploy_dir_image)
I'm not sure about this, "ls -lt" will sort by time and we will use the
latest one when the user run "runqemu core-image-minimal qemux86", but
glob.glob() seems can't do this.
I have to go to sleep now, have a good day, talk to you tomorrow.
// Robert
> if qbs:
> - self.qemuboot = qbs.split()[0]
> + self.qemuboot = qbs.split[0]
>
> if not os.path.exists(self.qemuboot):
> raise Exception("Failed to find <image>.qemuboot.conf!")
>
More information about the Openembedded-core
mailing list