[OE-core] [PATCH 2/4] runqemu: use glob rather than calling out to ls
Joshua Lock
joshuagloe at gmail.com
Mon Sep 5 15:51:01 UTC 2016
On 5 September 2016 at 15:51, Robert Yang <liezhi.yang at windriver.com> wrote:
>
>
> 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.
>
We could ensure the list returned by glob is sorted, whilst I prefer to
avoid calling out to the shell unnecessarily I'm not really attached to
this change and can drop it for v2 of the series.
> I have to go to sleep now, have a good day, talk to you tomorrow.
>
Thanks for the review!
> // 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!")
>>
>>
--
Joshua Lock <joshua.g.lock at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20160905/2f7d8c6e/attachment-0002.html>
More information about the Openembedded-core
mailing list