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:
parent
72e4443b7d
commit
4e36bad2ab
@ -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
|
||||
if self._is_rooted is None:
|
||||
try:
|
||||
self.execute('ls /', timeout=5, as_root=True)
|
||||
return True
|
||||
self._is_rooted = True
|
||||
except (TargetStableError, TimeoutError):
|
||||
return False
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user