1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

target.py: Track connected_as_root in the connection

Move from tracking of `connected_as_root` from the target to the
connection to allow it to perform it's own caching.
This commit is contained in:
Marc Bonnici 2019-08-27 14:24:50 +01:00
parent 4e36bad2ab
commit 5601fdb108

View File

@ -108,10 +108,7 @@ class Target(object):
@property @property
def connected_as_root(self): def connected_as_root(self):
if self._connected_as_root is None: return self.conn and self.conn.connected_as_root
result = self.execute('id')
self._connected_as_root = 'uid=0(' in result
return self._connected_as_root
@property @property
def is_rooted(self): def is_rooted(self):
@ -214,7 +211,6 @@ class Target(object):
conn_cls=None, conn_cls=None,
is_container=False is_container=False
): ):
self._connected_as_root = None
self._is_rooted = 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)
@ -324,7 +320,7 @@ class Target(object):
timeout = max(timeout - reset_delay, 10) timeout = max(timeout - reset_delay, 10)
if self.has('boot'): if self.has('boot'):
self.boot() # pylint: disable=no-member self.boot() # pylint: disable=no-member
self._connected_as_root = None self.conn.connected_as_root = None
if connect: if connect:
self.connect(timeout=timeout) self.connect(timeout=timeout)
@ -519,7 +515,7 @@ class Target(object):
except (DevlibTransientError, subprocess.CalledProcessError): except (DevlibTransientError, subprocess.CalledProcessError):
# on some targets "reboot" doesn't return gracefully # on some targets "reboot" doesn't return gracefully
pass pass
self._connected_as_root = None self.conn.connected_as_root = None
def check_responsive(self, explode=True): def check_responsive(self, explode=True):
try: try:
@ -1191,7 +1187,7 @@ class AndroidTarget(Target):
except (DevlibTransientError, subprocess.CalledProcessError): except (DevlibTransientError, subprocess.CalledProcessError):
# on some targets "reboot" doesn't return gracefully # on some targets "reboot" doesn't return gracefully
pass pass
self._connected_as_root = None self.conn.connected_as_root = None
def wait_boot_complete(self, timeout=10): def wait_boot_complete(self, timeout=10):
start = time.time() start = time.time()