remote_access: finish RunCommand->run rename
We keep seeing new users show up with the old API, so finish the
migration to the new API.
BUG=chromium:1006587
TEST=`./run_tests` passes
Change-Id: I9c54060561276d4a79702e0e7e1343ec56136b38
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2128728
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/deploy_chrome.py b/scripts/deploy_chrome.py
index 47eb7a3..06db7f7 100644
--- a/scripts/deploy_chrome.py
+++ b/scripts/deploy_chrome.py
@@ -112,7 +112,7 @@
self.chrome_dir = _CHROME_DIR
def _GetRemoteMountFree(self, remote_dir):
- result = self.device.RunCommand(DF_COMMAND % remote_dir)
+ result = self.device.run(DF_COMMAND % remote_dir)
line = result.output.splitlines()[1]
value = line.split()[3]
multipliers = {
@@ -123,8 +123,8 @@
return int(value.rstrip('GMK')) * multipliers.get(value[-1], 1)
def _GetRemoteDirSize(self, remote_dir):
- result = self.device.RunCommand('du -ks %s' % remote_dir,
- capture_output=True, encoding='utf-8')
+ result = self.device.run('du -ks %s' % remote_dir,
+ capture_output=True, encoding='utf-8')
return int(result.output.split()[0])
def _GetStagingDirSize(self):
@@ -134,9 +134,8 @@
return int(result.output.split()[0])
def _ChromeFileInUse(self):
- result = self.device.RunCommand(LSOF_COMMAND_CHROME %
- (self.options.target_dir,),
- check=False, capture_output=True)
+ result = self.device.run(LSOF_COMMAND_CHROME % (self.options.target_dir,),
+ check=False, capture_output=True)
return result.returncode == 0
def _Reboot(self):
@@ -161,7 +160,7 @@
cmd = ('/usr/share/vboot/bin/make_dev_ssd.sh --partitions %d '
'--remove_rootfs_verification --force')
for partition in (KERNEL_A_PARTITION, KERNEL_B_PARTITION):
- self.device.RunCommand(cmd % partition, check=False)
+ self.device.run(cmd % partition, check=False)
self._Reboot()
@@ -178,8 +177,8 @@
# <job_name> <status> ['process' <pid>].
# <status> is in the format <goal>/<state>.
try:
- result = self.device.RunCommand('status ui', capture_output=True,
- encoding='utf-8')
+ result = self.device.run('status ui', capture_output=True,
+ encoding='utf-8')
except cros_build_lib.RunCommandError as e:
if 'Unknown job' in e.result.error:
return False
@@ -191,7 +190,7 @@
def _KillProcsIfNeeded(self):
if self._CheckUiJobStarted():
logging.info('Shutting down Chrome...')
- self.device.RunCommand('stop ui')
+ self.device.run('stop ui')
# Developers sometimes run session_manager manually, in which case we'll
# need to help shut the chrome processes down.
@@ -201,8 +200,7 @@
logging.warning('The chrome binary on the device is in use.')
logging.warning('Killing chrome and session_manager processes...\n')
- self.device.RunCommand("pkill 'chrome|session_manager'",
- check=False)
+ self.device.run("pkill 'chrome|session_manager'", check=False)
# Wait for processes to actually terminate
time.sleep(POST_KILL_WAIT)
logging.info('Rechecking the chrome binary...')
@@ -222,8 +220,8 @@
check: See remote.RemoteAccess.RemoteSh for details.
"""
# TODO: Should migrate to use the remount functions in remote_access.
- result = self.device.RunCommand(MOUNT_RW_COMMAND, check=check,
- capture_output=True, encoding='utf-8')
+ result = self.device.run(MOUNT_RW_COMMAND, check=check,
+ capture_output=True, encoding='utf-8')
if result.returncode and not self.device.IsDirWritable('/'):
self._root_dir_is_still_readonly.set()
@@ -233,7 +231,7 @@
# Any valid /opt directory should already exist so avoid the remote call.
if os.path.commonprefix([target_dir, '/opt']) == '/opt':
return
- self.device.RunCommand(['mkdir', '-p', '--mode', '0775', target_dir])
+ self.device.run(['mkdir', '-p', '--mode', '0775', target_dir])
def _GetDeviceInfo(self):
"""Returns the disk space used and available for the target diectory."""
@@ -288,28 +286,28 @@
# getting deployed, and only on SELinux supported devices.
if (self.device.IsSELinuxAvailable() and
_CHROME_DIR in (self.options.target_dir, self.options.mount_dir)):
- self.device.RunCommand(['restorecon', '-R', _CHROME_DIR])
+ self.device.run(['restorecon', '-R', _CHROME_DIR])
for p in self.copy_paths:
if p.mode:
# Set mode if necessary.
- self.device.RunCommand('chmod %o %s/%s' % (
+ self.device.run('chmod %o %s/%s' % (
p.mode, self.options.target_dir, p.src if not p.dest else p.dest))
# Send SIGHUP to dbus-daemon to tell it to reload its configs. This won't
# pick up major changes (bus type, logging, etc.), but all we care about is
# getting the latest policy from /opt/google/chrome/dbus so that Chrome will
# be authorized to take ownership of its service names.
- self.device.RunCommand(DBUS_RELOAD_COMMAND, check=False)
+ self.device.run(DBUS_RELOAD_COMMAND, check=False)
if self.options.startui:
logging.info('Starting UI...')
- self.device.RunCommand('start ui')
+ self.device.run('start ui')
def _CheckConnection(self):
try:
logging.info('Testing connection to the device...')
- self.device.RunCommand('true')
+ self.device.run('true')
except cros_build_lib.RunCommandError as ex:
logging.error('Error connecting to the test device.')
raise DeployFailure(ex)
@@ -337,26 +335,26 @@
logging.info('Mounting Chrome...')
# Create directory if does not exist.
- self.device.RunCommand(_MKDIR_P_CMD % self.options.mount_dir)
+ self.device.run(_MKDIR_P_CMD % self.options.mount_dir)
try:
# Umount the existing mount on mount_dir if present first.
- self.device.RunCommand(_UMOUNT_DIR_IF_MOUNTPOINT_CMD %
- {'dir': self.options.mount_dir})
+ self.device.run(_UMOUNT_DIR_IF_MOUNTPOINT_CMD %
+ {'dir': self.options.mount_dir})
except cros_build_lib.RunCommandError as e:
logging.error('Failed to umount %s', self.options.mount_dir)
# If there is a failure, check if some processs is using the mount_dir.
- result = self.device.RunCommand(LSOF_COMMAND % (self.options.mount_dir,),
- check=False, capture_output=True,
- encoding='utf-8')
+ result = self.device.run(LSOF_COMMAND % (self.options.mount_dir,),
+ check=False, capture_output=True,
+ encoding='utf-8')
logging.error('lsof %s -->', self.options.mount_dir)
logging.error(result.stdout)
raise e
- self.device.RunCommand(_BIND_TO_FINAL_DIR_CMD % (self.options.target_dir,
- self.options.mount_dir))
+ self.device.run(_BIND_TO_FINAL_DIR_CMD % (self.options.target_dir,
+ self.options.mount_dir))
# Chrome needs partition to have exec and suid flags set
- self.device.RunCommand(_SET_MOUNT_FLAGS_CMD % (self.options.mount_dir,))
+ self.device.run(_SET_MOUNT_FLAGS_CMD % (self.options.mount_dir,))
def Cleanup(self):
"""Clean up RemoteDevice."""
@@ -398,7 +396,7 @@
if not self.device.IsDirWritable(self.options.target_dir):
if self.options.startui:
logging.info('Restarting Chrome...')
- self.device.RunCommand('start ui')
+ self.device.run('start ui')
raise DeployFailure('Target location is not writable. Aborting.')
if self.options.mount_dir is not None:
@@ -697,7 +695,7 @@
options = _ParseCommandLine(argv)
_PostParseCheck(options)
- # Set cros_build_lib debug level to hide RunCommand spew.
+ # Set cros_build_lib debug level to hide run spew.
if options.verbose:
logging.getLogger().setLevel(logging.DEBUG)
else: