OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 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 import contextlib | 5 import contextlib |
6 import fnmatch | 6 import fnmatch |
7 import json | 7 import json |
8 import os | 8 import os |
9 import pipes | 9 import pipes |
10 import shlex | 10 import shlex |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return False | 163 return False |
164 | 164 |
165 | 165 |
166 def IsDeviceReady(): | 166 def IsDeviceReady(): |
167 device_state = CheckOutput(['adb', 'get-state']) | 167 device_state = CheckOutput(['adb', 'get-state']) |
168 return device_state.strip() == 'device' | 168 return device_state.strip() == 'device' |
169 | 169 |
170 | 170 |
171 def CheckZipPath(name): | 171 def CheckZipPath(name): |
172 if os.path.normpath(name) != name: | 172 if os.path.normpath(name) != name: |
173 raise Exception('Non-canonical zip path: %s, %s' % name) | 173 raise Exception('Non-canonical zip path: %s' % name) |
174 if os.path.isabs(name): | 174 if os.path.isabs(name): |
175 raise Exception('Absolute zip path: %s, %s' % name) | 175 raise Exception('Absolute zip path: %s' % name) |
176 | 176 |
177 | 177 |
178 def ExtractAll(zip_path, path=None, no_clobber=True): | 178 def ExtractAll(zip_path, path=None, no_clobber=True): |
179 if path is None: | 179 if path is None: |
180 path = os.getcwd() | 180 path = os.getcwd() |
181 elif not os.path.exists(path): | 181 elif not os.path.exists(path): |
182 MakeDirectory(path) | 182 MakeDirectory(path) |
183 | 183 |
184 with zipfile.ZipFile(zip_path) as z: | 184 with zipfile.ZipFile(zip_path) as z: |
185 for name in z.namelist(): | 185 for name in z.namelist(): |
(...skipping 16 matching lines...) Expand all Loading... |
202 | 202 |
203 | 203 |
204 def PrintWarning(message): | 204 def PrintWarning(message): |
205 print 'WARNING: ' + message | 205 print 'WARNING: ' + message |
206 | 206 |
207 | 207 |
208 def PrintBigWarning(message): | 208 def PrintBigWarning(message): |
209 print '***** ' * 8 | 209 print '***** ' * 8 |
210 PrintWarning(message) | 210 PrintWarning(message) |
211 print '***** ' * 8 | 211 print '***** ' * 8 |
OLD | NEW |