1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

target: Remove use of ls

Using "ls" in scripts is highly discouraged:
http://mywiki.wooledge.org/ParsingLs
This commit is contained in:
Douglas RAILLARD 2020-01-20 17:15:58 +00:00 committed by Marc Bonnici
parent a5640502ac
commit 0aeb5bc409

View File

@ -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