| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """ Subclass for all slave-side ChromeOS build steps. """ | 5 """ Subclass for all slave-side ChromeOS build steps. """ |
| 6 | 6 |
| 7 | 7 |
| 8 from build_step import BuildStep, DeviceDirs | 8 from build_step import BuildStep, DeviceDirs |
| 9 from utils import gs_utils | 9 from utils import gs_utils |
| 10 from utils import ssh_utils | 10 from utils import ssh_utils |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 return ssh_utils.RunSSH(self._ssh_username, self._ssh_host, self._ssh_port, | 23 return ssh_utils.RunSSH(self._ssh_username, self._ssh_host, self._ssh_port, |
| 24 ['cat', filepath], echo=False) | 24 ['cat', filepath], echo=False) |
| 25 | 25 |
| 26 def _RemoveDirectoryOnDevice(self, directory): | 26 def _RemoveDirectoryOnDevice(self, directory): |
| 27 """ Delete a directory on the device. """ | 27 """ Delete a directory on the device. """ |
| 28 try: | 28 try: |
| 29 ssh_utils.RunSSH(self._ssh_username, self._ssh_host, self._ssh_port, | 29 ssh_utils.RunSSH(self._ssh_username, self._ssh_host, self._ssh_port, |
| 30 ['rm', '-rf', directory]) | 30 ['rm', '-rf', directory]) |
| 31 except Exception: | 31 except Exception: |
| 32 pass | 32 pass |
| 33 if 'DIRECTORY_EXISTS' in ssh_utils.RunSSH(self._ssh_username, | 33 if self.DevicePathExists(directory): |
| 34 self._ssh_host, self._ssh_port, ['if', '[', '-d', directory, '];', | |
| 35 'then', 'echo', 'DIRECTORY_EXISTS;', | |
| 36 'fi']): | |
| 37 raise Exception('Failed to remove %s' % directory) | 34 raise Exception('Failed to remove %s' % directory) |
| 38 | 35 |
| 39 def _CreateDirectoryOnDevice(self, directory): | 36 def _CreateDirectoryOnDevice(self, directory): |
| 40 """ Create a directory on the device. """ | 37 """ Create a directory on the device. """ |
| 41 ssh_utils.RunSSH(self._ssh_username, self._ssh_host, self._ssh_port, | 38 ssh_utils.RunSSH(self._ssh_username, self._ssh_host, self._ssh_port, |
| 42 ['mkdir', '-p', directory]) | 39 ['mkdir', '-p', directory]) |
| 43 | 40 |
| 44 def PushFileToDevice(self, src, dst): | 41 def PushFileToDevice(self, src, dst): |
| 45 """ Overrides build_step.PushFileToDevice() """ | 42 """ Overrides build_step.PushFileToDevice() """ |
| 46 ssh_utils.PutSCP(src, dst, self._ssh_username, self._ssh_host, | 43 ssh_utils.PutSCP(src, dst, self._ssh_username, self._ssh_host, |
| 47 self._ssh_port) | 44 self._ssh_port) |
| 48 | 45 |
| 46 def DeviceListDir(self, directory): |
| 47 """ Overrides build_step.DeviceListDir() """ |
| 48 return ssh_utils.RunSSH( |
| 49 self._ssh_username, |
| 50 self._ssh_host, |
| 51 self._ssh_port, |
| 52 ['ls', directory], echo=False).split('\n') |
| 53 |
| 54 def DevicePathExists(self, path): |
| 55 """ Overrides build_step.DevicePathExists() """ |
| 56 return 'FILE_EXISTS' in ssh_utils.RunSSH( |
| 57 self._ssh_username, |
| 58 self._ssh_host, |
| 59 self._ssh_port, |
| 60 ['if', '[', '-e', path, '];', 'then', 'echo', 'FILE_EXISTS;', 'fi']) |
| 61 |
| 49 def DevicePathJoin(self, *args): | 62 def DevicePathJoin(self, *args): |
| 50 """ Overrides build_step.DevicePathJoin() """ | 63 """ Overrides build_step.DevicePathJoin() """ |
| 51 return posixpath.sep.join(args) | 64 return posixpath.sep.join(args) |
| 52 | 65 |
| 53 def CreateCleanDirectory(self, directory): | 66 def CreateCleanDirectory(self, directory): |
| 54 self._RemoveDirectoryOnDevice(directory) | 67 self._RemoveDirectoryOnDevice(directory) |
| 55 self._CreateDirectoryOnDevice(directory) | 68 self._CreateDirectoryOnDevice(directory) |
| 56 | 69 |
| 57 def CopyDirectoryContentsToDevice(self, host_dir, device_dir): | 70 def CopyDirectoryContentsToDevice(self, host_dir, device_dir): |
| 58 """ Copy the contents of a host-side directory to a clean directory on the | 71 """ Copy the contents of a host-side directory to a clean directory on the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 72 def __init__(self, args, **kwargs): | 85 def __init__(self, args, **kwargs): |
| 73 self._ssh_host = args['ssh_host'] | 86 self._ssh_host = args['ssh_host'] |
| 74 self._ssh_port = args['ssh_port'] | 87 self._ssh_port = args['ssh_port'] |
| 75 self._ssh_username = 'root' | 88 self._ssh_username = 'root' |
| 76 super(ChromeOSBuildStep, self).__init__(args=args, **kwargs) | 89 super(ChromeOSBuildStep, self).__init__(args=args, **kwargs) |
| 77 prefix = '/usr/local/skiabot/skia_' | 90 prefix = '/usr/local/skiabot/skia_' |
| 78 self._device_dirs = DeviceDirs(perf_data_dir=prefix + 'perf', | 91 self._device_dirs = DeviceDirs(perf_data_dir=prefix + 'perf', |
| 79 gm_actual_dir=prefix + 'gm_actual', | 92 gm_actual_dir=prefix + 'gm_actual', |
| 80 gm_expected_dir=prefix + 'gm_expected', | 93 gm_expected_dir=prefix + 'gm_expected', |
| 81 resource_dir=prefix + 'resources', | 94 resource_dir=prefix + 'resources', |
| 95 skimage_in_dir=prefix + 'skimage_in', |
| 96 skimage_expected_dir=(prefix |
| 97 + 'skimage_expected'), |
| 98 skimage_out_dir=prefix + 'skimage_out', |
| 82 skp_dir=prefix + 'skp', | 99 skp_dir=prefix + 'skp', |
| 83 skp_perf_dir=prefix + 'skp_perf', | 100 skp_perf_dir=prefix + 'skp_perf', |
| 84 skp_out_dir=prefix + 'skp_out', | 101 skp_out_dir=prefix + 'skp_out', |
| 85 tmp_dir=prefix + 'tmp_dir') | 102 tmp_dir=prefix + 'tmp_dir') |
| OLD | NEW |