| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Generic utils.""" | 5 """Generic utils.""" |
| 6 | 6 |
| 7 import codecs | 7 import codecs |
| 8 import cStringIO | 8 import cStringIO |
| 9 import datetime | 9 import datetime |
| 10 import logging | 10 import logging |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 raise | 705 raise |
| 706 | 706 |
| 707 if rv == 0: | 707 if rv == 0: |
| 708 return output.getvalue() | 708 return output.getvalue() |
| 709 if not retry: | 709 if not retry: |
| 710 break | 710 break |
| 711 print ("WARNING: subprocess %s failed; will retry after a short nap..." % | 711 print ("WARNING: subprocess %s failed; will retry after a short nap..." % |
| 712 debug_child_info) | 712 debug_child_info) |
| 713 time.sleep(sleep_interval) | 713 time.sleep(sleep_interval) |
| 714 sleep_interval *= 2 | 714 sleep_interval *= 2 |
| 715 raise subprocess42.CalledProcessError( | 715 # TODO(tandrii): change this to subprocess.CalledProcessError, |
| 716 # beacuse subprocess42 doesn't have a class unlike subprocess2. |
| 717 raise subprocess2.CalledProcessError( |
| 716 rv, args, kwargs.get('cwd', None), None, None) | 718 rv, args, kwargs.get('cwd', None), None, None) |
| 717 | 719 |
| 718 | 720 |
| 719 class GitFilter(object): | 721 class GitFilter(object): |
| 720 """A filter_fn implementation for quieting down git output messages. | 722 """A filter_fn implementation for quieting down git output messages. |
| 721 | 723 |
| 722 Allows a custom function to skip certain lines (predicate), and will throttle | 724 Allows a custom function to skip certain lines (predicate), and will throttle |
| 723 the output of percentage completed lines to only output every X seconds. | 725 the output of percentage completed lines to only output every X seconds. |
| 724 """ | 726 """ |
| 725 PERCENT_RE = re.compile('(.*) ([0-9]{1,3})% .*') | 727 PERCENT_RE = re.compile('(.*) ([0-9]{1,3})% .*') |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 # Just incase we have some ~/blah paths. | 1399 # Just incase we have some ~/blah paths. |
| 1398 target = os.path.abspath(os.path.expanduser(target)) | 1400 target = os.path.abspath(os.path.expanduser(target)) |
| 1399 if os.path.isfile(target) and os.access(target, os.X_OK): | 1401 if os.path.isfile(target) and os.access(target, os.X_OK): |
| 1400 return target | 1402 return target |
| 1401 if sys.platform.startswith('win'): | 1403 if sys.platform.startswith('win'): |
| 1402 for suffix in ('.bat', '.cmd', '.exe'): | 1404 for suffix in ('.bat', '.cmd', '.exe'): |
| 1403 alt_target = target + suffix | 1405 alt_target = target + suffix |
| 1404 if os.path.isfile(alt_target) and os.access(alt_target, os.X_OK): | 1406 if os.path.isfile(alt_target) and os.access(alt_target, os.X_OK): |
| 1405 return alt_target | 1407 return alt_target |
| 1406 return None | 1408 return None |
| OLD | NEW |