From 0aeb5bc4095c9d3b676b16337ffed4502ae94360 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Mon, 20 Jan 2020 17:15:58 +0000 Subject: [PATCH] target: Remove use of ls Using "ls" in scripts is highly discouraged: http://mywiki.wooledge.org/ParsingLs --- devlib/target.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devlib/target.py b/devlib/target.py index 92c2633..42fac2c 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -168,9 +168,10 @@ class Target(object): @memoized def number_of_nodes(self): num_nodes = 0 - nodere = re.compile(r'^\s*node\d+\s*$') - output = self.execute('ls /sys/devices/system/node', as_root=self.is_rooted) - for entry in output.split(): + nodere = re.compile(r'^\./node\d+\s*$') + cmd = 'cd /sys/devices/system/node && {busybox} find . -maxdepth 1'.format(busybox=quote(self.busybox)) + output = self.execute(cmd, as_root=self.is_rooted) + for entry in output.splitlines(): if nodere.match(entry): num_nodes += 1 return num_nodes