1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 02:40:50 +01:00

target.py: Un-memoize the is_rooted property

Un-memoize the `is_rooted` property of the connection and perform our
own caching instead as the state can be changed depending on the
connection status.
This commit is contained in:
Marc Bonnici 2019-08-27 14:28:23 +01:00
parent 72e4443b7d
commit 4e36bad2ab

View File

@ -114,15 +114,15 @@ class Target(object):
return self._connected_as_root
@property
@memoized
def is_rooted(self):
if self.connected_as_root:
return True
try:
self.execute('ls /', timeout=5, as_root=True)
return True
except (TargetStableError, TimeoutError):
return False
if self._is_rooted is None:
try:
self.execute('ls /', timeout=5, as_root=True)
self._is_rooted = True
except (TargetStableError, TimeoutError):
self._is_rooted = False
return self._is_rooted or self.connected_as_root
@property
@memoized
@ -215,6 +215,7 @@ class Target(object):
is_container=False
):
self._connected_as_root = None
self._is_rooted = None
self.connection_settings = connection_settings or {}
# Set self.platform: either it's given directly (by platform argument)
# or it's given in the connection_settings argument