From 9661c6bff31c5a26a7d3d396550a7d4238eb4856 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Mon, 20 Jan 2020 17:19:34 +0000 Subject: [PATCH] target: Handle non-existing /sys/devices/system/node Some systems (ARM 32bits it seems) don't have this file in sysfs. Assume 1 node in that case. --- devlib/target.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/devlib/target.py b/devlib/target.py index 42fac2c..a75b4d0 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -167,14 +167,18 @@ class Target(object): @property @memoized def number_of_nodes(self): - num_nodes = 0 - 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 + try: + output = self.execute(cmd, as_root=self.is_rooted) + except TargetStableError: + return 1 + else: + nodere = re.compile(r'^\./node\d+\s*$') + num_nodes = 0 + for entry in output.splitlines(): + if nodere.match(entry): + num_nodes += 1 + return num_nodes @property @memoized