skia2/infra/bots/recipe_modules/flavor/chromebook.py
Ben Wagner 53eab013f5 Factor common SSH logic into a new flavor.
Change-Id: I3e9acc3f8e2690169b3c76f9aec1ac22f6dfc93a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/205620
Commit-Queue: Ben Wagner aka dogben <benjaminwagner@google.com>
Auto-Submit: Ben Wagner aka dogben <benjaminwagner@google.com>
Reviewed-by: Eric Boren <borenet@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2019-04-12 17:37:25 +00:00

55 lines
1.9 KiB
Python

# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from recipe_engine import recipe_api
import default
import ssh
"""Chromebook flavor, used for running code on Chromebooks."""
class ChromebookFlavor(ssh.SSHFlavor):
def __init__(self, m):
super(ChromebookFlavor, self).__init__(m)
self.chromeos_homedir = '/home/chronos/user/'
self.device_dirs = default.DeviceDirs(
bin_dir = self.chromeos_homedir + 'bin',
dm_dir = self.chromeos_homedir + 'dm_out',
perf_data_dir = self.chromeos_homedir + 'perf',
resource_dir = self.chromeos_homedir + 'resources',
images_dir = self.chromeos_homedir + 'images',
lotties_dir = self.chromeos_homedir + 'lotties',
skp_dir = self.chromeos_homedir + 'skps',
svg_dir = self.chromeos_homedir + 'svgs',
tmp_dir = self.chromeos_homedir)
def install(self):
super(ChromebookFlavor, self).install()
# Ensure the home dir is marked executable
self.ssh('remount %s as exec' % self.chromeos_homedir,
'sudo', 'mount', '-i', '-o', 'remount,exec', '/home/chronos')
def _copy_dir(self, src, dest):
# We can't use rsync to communicate with the chromebooks because the
# chromebooks don't have rsync installed on them.
self.m.python.inline(str('scp -r %s %s' % (src, dest)),
"""
import subprocess
import sys
src = sys.argv[1] + '/*'
dest = sys.argv[2]
print subprocess.check_output('scp -r %s %s' % (src, dest), shell=True)
""", args=[src, dest], infra_step=True)
def copy_directory_contents_to_device(self, host_path, device_path):
self._copy_dir(host_path, self.scp_device_path(device_path))
def copy_directory_contents_to_host(self, device_path, host_path):
self._copy_dir(self.scp_device_path(device_path), host_path)