| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 from recipe_engine import recipe_api | 5 from recipe_engine import recipe_api |
| 6 | 6 |
| 7 | 7 |
| 8 class DiskApi(recipe_api.RecipeApi): | 8 class DiskApi(recipe_api.RecipeApi): |
| 9 """DiskApi contains helper functions for reading disk info.""" | 9 """DiskApi contains helper functions for reading disk info.""" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 mark the step as WARNING. Defaults to 0.9. | 23 mark the step as WARNING. Defaults to 0.9. |
| 24 previous_result (dict): previous result of space_usage call. If passed, | 24 previous_result (dict): previous result of space_usage call. If passed, |
| 25 delta is displayed in step text. | 25 delta is displayed in step text. |
| 26 name (str): step name. Defaults to "disk space usage". | 26 name (str): step name. Defaults to "disk space usage". |
| 27 | 27 |
| 28 Returns: | 28 Returns: |
| 29 A dict with disk usage info or None if step fails. Dict keys: | 29 A dict with disk usage info or None if step fails. Dict keys: |
| 30 * capacity (float): disk capacity, in MiB. | 30 * capacity (float): disk capacity, in MiB. |
| 31 * used (float): disk usage, in MiB. | 31 * used (float): disk usage, in MiB. |
| 32 """ | 32 """ |
| 33 path = path or self.m.infra_paths['slave_build'] | 33 path = path or self.m.path['slave_build'] |
| 34 name = name or 'disk space usage' | 34 name = name or 'disk space usage' |
| 35 warning_level = warning_level or 0.9 | 35 warning_level = warning_level or 0.9 |
| 36 kwargs.setdefault( | 36 kwargs.setdefault( |
| 37 'step_test_data', | 37 'step_test_data', |
| 38 lambda: self.m.json.test_api.output_stream( | 38 lambda: self.m.json.test_api.output_stream( |
| 39 self.test_api.space_usage_result())) | 39 self.test_api.space_usage_result())) |
| 40 | 40 |
| 41 if self.m.platform.is_win: | 41 if self.m.platform.is_win: |
| 42 # Not supported. Feel free to implement. | 42 # Not supported. Feel free to implement. |
| 43 return | 43 return |
| (...skipping 22 matching lines...) Expand all Loading... |
| 66 } | 66 } |
| 67 except Exception as ex: | 67 except Exception as ex: |
| 68 # Do not fail entire build because of a disk space step failure. | 68 # Do not fail entire build because of a disk space step failure. |
| 69 if step: | 69 if step: |
| 70 step.presentation.logs['exception'] = ['%r' % ex] | 70 step.presentation.logs['exception'] = ['%r' % ex] |
| 71 step.presentation.status = self.m.step.WARNING | 71 step.presentation.status = self.m.step.WARNING |
| 72 if can_fail_build: | 72 if can_fail_build: |
| 73 raise recipe_api.StepFailure('Could not get disk info: %s' % ex) | 73 raise recipe_api.StepFailure('Could not get disk info: %s' % ex) |
| 74 return | 74 return |
| 75 | 75 |
| OLD | NEW |