1# Copyright 2016 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5 6from recipe_engine import recipe_api 7 8from . import default 9from . import ssh 10 11 12"""Chromebook flavor, used for running code on Chromebooks.""" 13 14 15class ChromebookFlavor(ssh.SSHFlavor): 16 17 def __init__(self, m, app_name): 18 super(ChromebookFlavor, self).__init__(m, app_name) 19 self.chromeos_homedir = '/home/chronos/user/' 20 self.device_dirs = default.DeviceDirs( 21 bin_dir = self.chromeos_homedir + 'bin', 22 dm_dir = self.chromeos_homedir + 'dm_out', 23 perf_data_dir = self.chromeos_homedir + 'perf', 24 resource_dir = self.chromeos_homedir + 'resources', 25 images_dir = self.chromeos_homedir + 'images', 26 lotties_dir = self.chromeos_homedir + 'lotties', 27 skp_dir = self.chromeos_homedir + 'skps', 28 svg_dir = self.chromeos_homedir + 'svgs', 29 mskp_dir = self.chromeos_homedir + 'mskp', 30 tmp_dir = self.chromeos_homedir, 31 texttraces_dir = '') 32 33 def install(self): 34 super(ChromebookFlavor, self).install() 35 36 # Ensure the home dir is marked executable 37 self.ssh('remount %s as exec' % self.chromeos_homedir, 38 'sudo', 'mount', '-i', '-o', 'remount,exec', '/home/chronos') 39 40 def _copy_dir(self, src, dest): 41 # We can't use rsync to communicate with the chromebooks because the 42 # chromebooks don't have rsync installed on them. 43 self.m.python.inline(str('scp -r %s %s' % (src, dest)), 44 """ 45 import subprocess 46 import sys 47 src = sys.argv[1] + '/*' 48 dest = sys.argv[2] 49 print(subprocess.check_output('scp -r %s %s' % (src, dest), shell=True)) 50 """, args=[src, dest], infra_step=True) 51 52 def copy_directory_contents_to_device(self, host_path, device_path): 53 self._copy_dir(host_path, self.scp_device_path(device_path)) 54 55 def copy_directory_contents_to_host(self, device_path, host_path): 56 self._copy_dir(self.scp_device_path(device_path), host_path) 57