Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: scripts/slave/recipe_modules/chromium_android/api.py

Issue 2103553002: Check that device file exists first before reverting. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium_android/example.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 datetime 6 import datetime
7 import json 7 import json
8 import os 8 import os
9 import re 9 import re
10 import sys 10 import sys
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 max_battery_temp=max_battery_temp, 337 max_battery_temp=max_battery_temp,
338 remove_system_webview=remove_system_webview) 338 remove_system_webview=remove_system_webview)
339 339
340 @property 340 @property
341 def blacklist_file(self): 341 def blacklist_file(self):
342 return self.out_path.join('bad_devices.json') 342 return self.out_path.join('bad_devices.json')
343 343
344 344
345 def revert_device_file_format(self): 345 def revert_device_file_format(self):
346 # If current device file is jsonified, revert it back to original format. 346 # If current device file is jsonified, revert it back to original format.
347 with self.m.step.nest('fix_device_file_format'): 347 if self.m.path.exists(self.known_devices_file):
348 file_contents = self.m.file.read( 348 with self.m.step.nest('fix_device_file_format'):
349 'read_device_file', self.known_devices_file, 349 file_contents = self.m.file.read(
350 test_data='device1\ndevice2\ndevice3') 350 'read_device_file', self.known_devices_file,
351 try: 351 test_data='device1\ndevice2\ndevice3')
352 devices = json.loads(file_contents) 352 try:
353 self.m.step.active_result.presentation.step_text += ( 353 devices = json.loads(file_contents)
354 'file format is json, reverting') 354 self.m.step.active_result.presentation.step_text += (
355 old_format = '\n'.join(devices) 355 'file format is json, reverting')
356 self.m.file.write( 356 old_format = '\n'.join(devices)
357 'revert_device_file', self.known_devices_file, old_format) 357 self.m.file.write(
358 except ValueError: 358 'revert_device_file', self.known_devices_file, old_format)
359 # File wasn't json, so no need to revert. 359 except ValueError:
360 self.m.step.active_result.presentation.step_text += ( 360 # File wasn't json, so no need to revert.
361 'file format is compatible') 361 self.m.step.active_result.presentation.step_text += (
362 'file format is compatible')
362 363
363 def device_status_check(self, restart_usb=False, **kwargs): 364 def device_status_check(self, restart_usb=False, **kwargs):
364 # TODO(bpastene): Remove once chromium revisions prior to 365 # TODO(bpastene): Remove once chromium revisions prior to
365 # crrev.com/1faecde0c03013b6cd725da413339c60223f8948 are no longer tested. 366 # crrev.com/1faecde0c03013b6cd725da413339c60223f8948 are no longer tested.
366 # See crbug.com/619707 for context. 367 # See crbug.com/619707 for context.
367 self.revert_device_file_format() 368 self.revert_device_file_format()
368 369
369 # TODO(phajdan.jr): Remove path['build'] usage, http://crbug.com/437264 . 370 # TODO(phajdan.jr): Remove path['build'] usage, http://crbug.com/437264 .
370 args = [ 371 args = [
371 '--adb-path', self.m.adb.adb_path(), 372 '--adb-path', self.m.adb.adb_path(),
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 script = self.c.test_runner 1360 script = self.c.test_runner
1360 if wrapper_script_suite_name: 1361 if wrapper_script_suite_name:
1361 script = self.m.chromium.output_dir.join('bin', 'run_%s' % 1362 script = self.m.chromium.output_dir.join('bin', 'run_%s' %
1362 wrapper_script_suite_name) 1363 wrapper_script_suite_name)
1363 else: 1364 else:
1364 env = kwargs.get('env', {}) 1365 env = kwargs.get('env', {})
1365 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', 1366 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR',
1366 self.m.chromium.output_dir) 1367 self.m.chromium.output_dir)
1367 kwargs['env'] = env 1368 kwargs['env'] = env
1368 return self.m.python(step_name, script, args, **kwargs) 1369 return self.m.python(step_name, script, args, **kwargs)
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium_android/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698