OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import datetime | 5 import datetime |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import shutil | 8 import shutil |
9 import tempfile | 9 import tempfile |
10 import threading | 10 import threading |
(...skipping 26 matching lines...) Expand all Loading... |
37 self._devices = [] | 37 self._devices = [] |
38 self._concurrent_adb = args.enable_concurrent_adb | 38 self._concurrent_adb = args.enable_concurrent_adb |
39 self._enable_device_cache = args.enable_device_cache | 39 self._enable_device_cache = args.enable_device_cache |
40 self._logcat_monitors = [] | 40 self._logcat_monitors = [] |
41 self._logcat_output_dir = args.logcat_output_dir | 41 self._logcat_output_dir = args.logcat_output_dir |
42 self._logcat_output_file = args.logcat_output_file | 42 self._logcat_output_file = args.logcat_output_file |
43 self._max_tries = 1 + args.num_retries | 43 self._max_tries = 1 + args.num_retries |
44 self._skip_clear_data = args.skip_clear_data | 44 self._skip_clear_data = args.skip_clear_data |
45 self._target_devices_file = args.target_devices_file | 45 self._target_devices_file = args.target_devices_file |
46 self._tool_name = args.tool | 46 self._tool_name = args.tool |
47 | 47 self._logdog_butler_pref = args.logdog_butler_prefix |
| 48 self._logdog_butler_dir = args.logdog_butler_dir |
| 49 self._logdog_butler_project = args.logdog_butler_project |
48 #override | 50 #override |
49 def SetUp(self): | 51 def SetUp(self): |
50 device_arg = 'default' | 52 device_arg = 'default' |
51 if self._target_devices_file: | 53 if self._target_devices_file: |
52 device_arg = device_list.GetPersistentDeviceList( | 54 device_arg = device_list.GetPersistentDeviceList( |
53 self._target_devices_file) | 55 self._target_devices_file) |
54 if not device_arg: | 56 if not device_arg: |
55 logging.warning('No target devices specified. Falling back to ' | 57 logging.warning('No target devices specified. Falling back to ' |
56 'running on all available devices.') | 58 'running on all available devices.') |
57 device_arg = 'default' | 59 device_arg = 'default' |
58 elif self._device_serial: | 60 elif self._device_serial: |
59 device_arg = self._device_serial | 61 device_arg = self._device_serial |
60 | 62 |
61 self._devices = device_utils.DeviceUtils.HealthyDevices( | 63 self._devices = device_utils.DeviceUtils.HealthyDevices( |
62 self._blacklist, enable_device_files_cache=self._enable_device_cache, | 64 self._blacklist, enable_device_files_cache=self._enable_device_cache, |
63 default_retries=self._max_tries - 1, device_arg=device_arg) | 65 default_retries=self._max_tries - 1, device_arg=device_arg) |
64 if not self._devices: | 66 if not self._devices: |
65 raise device_errors.NoDevicesError | 67 raise device_errors.NoDevicesError |
66 | 68 |
67 if self._enable_device_cache: | 69 if self._enable_device_cache: |
68 for d in self._devices: | 70 for d in self._devices: |
69 cache_path = _DeviceCachePath(d) | 71 cache_path = _DeviceCachePath(d) |
70 if os.path.exists(cache_path): | 72 if os.path.exists(cache_path): |
71 logging.info('Using device cache: %s', cache_path) | 73 logging.info('Using device cache: %s', cache_path) |
72 with open(cache_path) as f: | 74 with open(cache_path) as f: |
73 d.LoadCacheData(f.read()) | 75 d.LoadCacheData(f.read()) |
74 # Delete cached file so that any exceptions cause it to be cleared. | 76 # Delete cached file so that any exceptions cause it to be cleared. |
75 os.unlink(cache_path) | 77 os.unlink(cache_path) |
| 78 # Add in logdog stuff |
| 79 # subprocess.POpen(self._logdog_pref+'logdog_butler', '-project |
| 80 # {0}'.format(self._logdog_butler_project), '-prefix |
| 81 # {0}'.format(self._logdog_butler_pref), '-output', 'logdog', |
| 82 |
| 83 |
76 if self._logcat_output_file: | 84 if self._logcat_output_file: |
77 self._logcat_output_dir = tempfile.mkdtemp() | 85 self._logcat_output_dir = tempfile.mkdtemp() |
78 if self._logcat_output_dir: | 86 if self._logcat_output_dir: |
79 for d in self._devices: | 87 for d in self._devices: |
| 88 logdog_name = None |
| 89 if self._logdog_butler_pref: |
| 90 logdog_name = 'swarming/device{0}'.format(d.adb.GetDeviceSerial()) |
80 logcat_file = os.path.join( | 91 logcat_file = os.path.join( |
81 self._logcat_output_dir, | 92 self._logcat_output_dir, |
82 '%s_%s' % (d.adb.GetDeviceSerial(), | 93 '%s_%s' % (d.adb.GetDeviceSerial(), |
83 datetime.datetime.utcnow().strftime('%Y%m%dT%H%M%S'))) | 94 datetime.datetime.utcnow().strftime('%Y%m%dT%H%M%S'))) |
84 monitor = logcat_monitor.LogcatMonitor( | 95 monitor = logcat_monitor.LogcatMonitor( |
85 d.adb, clear=True, output_file=logcat_file) | 96 d.adb, clear=True, output_file=logcat_file) |
| 97 # logdog_prefix=self._logdog_butler_pref, |
| 98 # logdog_name=logdog_name) |
86 self._logcat_monitors.append(monitor) | 99 self._logcat_monitors.append(monitor) |
87 monitor.Start() | 100 monitor.Start() |
88 | 101 |
89 @property | 102 @property |
90 def concurrent_adb(self): | 103 def concurrent_adb(self): |
91 return self._concurrent_adb | 104 return self._concurrent_adb |
92 | 105 |
93 @property | 106 @property |
94 def devices(self): | 107 def devices(self): |
95 if not self._devices: | 108 if not self._devices: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 [m.output_file for m in self._logcat_monitors]) | 144 [m.output_file for m in self._logcat_monitors]) |
132 shutil.rmtree(self._logcat_output_dir) | 145 shutil.rmtree(self._logcat_output_dir) |
133 | 146 |
134 def BlacklistDevice(self, device, reason='local_device_failure'): | 147 def BlacklistDevice(self, device, reason='local_device_failure'): |
135 device_serial = device.adb.GetDeviceSerial() | 148 device_serial = device.adb.GetDeviceSerial() |
136 if self._blacklist: | 149 if self._blacklist: |
137 self._blacklist.Extend([device_serial], reason=reason) | 150 self._blacklist.Extend([device_serial], reason=reason) |
138 with self._devices_lock: | 151 with self._devices_lock: |
139 self._devices = [d for d in self._devices if str(d) != device_serial] | 152 self._devices = [d for d in self._devices if str(d) != device_serial] |
140 | 153 |
OLD | NEW |