Skip to content

Commit

Permalink
target: Remove use of ls
Browse files Browse the repository at this point in the history
Using "ls" in scripts is highly discouraged:
http://mywiki.wooledge.org/ParsingLs
  • Loading branch information
douglas-raillard-arm authored and marcbonnici committed Jan 22, 2020
1 parent a564050 commit 0aeb5bc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions devlib/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ def number_of_cpus(self):
@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
Expand Down

0 comments on commit 0aeb5bc

Please sign in to comment.