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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium_android/example.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/recipe_modules/chromium_android/api.py
diff --git a/scripts/slave/recipe_modules/chromium_android/api.py b/scripts/slave/recipe_modules/chromium_android/api.py
index ee277ae329b1cd1860967848e05c8e0c4ddd28d5..2f2b79b81301c0839bfb904c344610103ba3b6f4 100644
--- a/scripts/slave/recipe_modules/chromium_android/api.py
+++ b/scripts/slave/recipe_modules/chromium_android/api.py
@@ -344,21 +344,22 @@ class AndroidApi(recipe_api.RecipeApi):
def revert_device_file_format(self):
# If current device file is jsonified, revert it back to original format.
- with self.m.step.nest('fix_device_file_format'):
- file_contents = self.m.file.read(
- 'read_device_file', self.known_devices_file,
- test_data='device1\ndevice2\ndevice3')
- try:
- devices = json.loads(file_contents)
- self.m.step.active_result.presentation.step_text += (
- 'file format is json, reverting')
- old_format = '\n'.join(devices)
- self.m.file.write(
- 'revert_device_file', self.known_devices_file, old_format)
- except ValueError:
- # File wasn't json, so no need to revert.
- self.m.step.active_result.presentation.step_text += (
- 'file format is compatible')
+ if self.m.path.exists(self.known_devices_file):
+ with self.m.step.nest('fix_device_file_format'):
+ file_contents = self.m.file.read(
+ 'read_device_file', self.known_devices_file,
+ test_data='device1\ndevice2\ndevice3')
+ try:
+ devices = json.loads(file_contents)
+ self.m.step.active_result.presentation.step_text += (
+ 'file format is json, reverting')
+ old_format = '\n'.join(devices)
+ self.m.file.write(
+ 'revert_device_file', self.known_devices_file, old_format)
+ except ValueError:
+ # File wasn't json, so no need to revert.
+ self.m.step.active_result.presentation.step_text += (
+ 'file format is compatible')
def device_status_check(self, restart_usb=False, **kwargs):
# TODO(bpastene): Remove once chromium revisions prior to
« 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