1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00: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 return self._connected_as_root
@property @property
@memoized
def is_rooted(self): def is_rooted(self):
if self.connected_as_root: if self._is_rooted is None:
return True try:
try: self.execute('ls /', timeout=5, as_root=True)
self.execute('ls /', timeout=5, as_root=True) self._is_rooted = True
return True except (TargetStableError, TimeoutError):
except (TargetStableError, TimeoutError): self._is_rooted = False
return False
return self._is_rooted or self.connected_as_root
@property @property
@memoized @memoized
@ -215,6 +215,7 @@ class Target(object):
is_container=False is_container=False
): ):
self._connected_as_root = None self._connected_as_root = None
self._is_rooted = None
self.connection_settings = connection_settings or {} self.connection_settings = connection_settings or {}
# Set self.platform: either it's given directly (by platform argument) # Set self.platform: either it's given directly (by platform argument)
# or it's given in the connection_settings argument # or it's given in the connection_settings argument