Skip to content

Commit 0aeb5bc

Browse files
douglas-raillard-armmarcbonnici
authored andcommitted
target: Remove use of ls
Using "ls" in scripts is highly discouraged: http://mywiki.wooledge.org/ParsingLs
1 parent a564050 commit 0aeb5bc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

devlib/target.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,10 @@ def number_of_cpus(self):
168168
@memoized
169169
def number_of_nodes(self):
170170
num_nodes = 0
171-
nodere = re.compile(r'^\s*node\d+\s*$')
172-
output = self.execute('ls /sys/devices/system/node', as_root=self.is_rooted)
173-
for entry in output.split():
171+
nodere = re.compile(r'^\./node\d+\s*$')
172+
cmd = 'cd /sys/devices/system/node && {busybox} find . -maxdepth 1'.format(busybox=quote(self.busybox))
173+
output = self.execute(cmd, as_root=self.is_rooted)
174+
for entry in output.splitlines():
174175
if nodere.match(entry):
175176
num_nodes += 1
176177
return num_nodes

0 commit comments

Comments
 (0)