| 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 """Print prettier and more detailed exceptions. Copied from Telemetry.""" | 5 """Print prettier and more detailed exceptions. Copied from Telemetry.""" |
| 6 | 6 |
| 7 import math | 7 import math |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 import traceback | 10 import traceback |
| 11 | 11 |
| 12 import path_util | 12 from gpu_tests import path_util |
| 13 | 13 |
| 14 from telemetry.core import exceptions | 14 from telemetry.core import exceptions |
| 15 | 15 |
| 16 | 16 |
| 17 def PrintFormattedException(exception_class=None, exception=None, tb=None, | 17 def PrintFormattedException(exception_class=None, exception=None, tb=None, |
| 18 msg=None): | 18 msg=None): |
| 19 assert bool(exception_class) == bool(exception) == bool(tb), ( | 19 assert bool(exception_class) == bool(exception) == bool(tb), ( |
| 20 'Must specify all or none of exception_class, exception, and tb') | 20 'Must specify all or none of exception_class, exception, and tb') |
| 21 | 21 |
| 22 if not exception_class: | 22 if not exception_class: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 if max_length < 0: | 96 if max_length < 0: |
| 97 raise ValueError('Must provide positive max_length') | 97 raise ValueError('Must provide positive max_length') |
| 98 if len(middle) > max_length: | 98 if len(middle) > max_length: |
| 99 raise ValueError('middle must not be greater than max_length') | 99 raise ValueError('middle must not be greater than max_length') |
| 100 | 100 |
| 101 if len(target) <= max_length: | 101 if len(target) <= max_length: |
| 102 return target | 102 return target |
| 103 half_length = (max_length - len(middle)) / 2. | 103 half_length = (max_length - len(middle)) / 2. |
| 104 return (target[:int(math.floor(half_length))] + middle + | 104 return (target[:int(math.floor(half_length))] + middle + |
| 105 target[-int(math.ceil(half_length)):]) | 105 target[-int(math.ceil(half_length)):]) |
| OLD | NEW |