| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Enables directory-specific presubmit checks to run at upload and/or commit. | 6 """Enables directory-specific presubmit checks to run at upload and/or commit. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 __version__ = '1.8.0' | 9 __version__ = '1.8.0' |
| 10 | 10 |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 | 1013 |
| 1014 Args: | 1014 Args: |
| 1015 script_text: The text of the presubmit script. | 1015 script_text: The text of the presubmit script. |
| 1016 presubmit_path: Project script to run. | 1016 presubmit_path: Project script to run. |
| 1017 project: Project name to pass to presubmit script for bot selection. | 1017 project: Project name to pass to presubmit script for bot selection. |
| 1018 | 1018 |
| 1019 Return: | 1019 Return: |
| 1020 A list of try slaves. | 1020 A list of try slaves. |
| 1021 """ | 1021 """ |
| 1022 context = {} | 1022 context = {} |
| 1023 main_path = os.getcwd() |
| 1023 try: | 1024 try: |
| 1025 os.chdir(os.path.dirname(presubmit_path)) |
| 1024 exec script_text in context | 1026 exec script_text in context |
| 1025 except Exception, e: | 1027 except Exception, e: |
| 1026 raise PresubmitFailure('"%s" had an exception.\n%s' % (presubmit_path, e)) | 1028 raise PresubmitFailure('"%s" had an exception.\n%s' % (presubmit_path, e)) |
| 1029 finally: |
| 1030 os.chdir(main_path) |
| 1027 | 1031 |
| 1028 function_name = 'GetPreferredTrySlaves' | 1032 function_name = 'GetPreferredTrySlaves' |
| 1029 if function_name in context: | 1033 if function_name in context: |
| 1030 get_preferred_try_slaves = context[function_name] | 1034 get_preferred_try_slaves = context[function_name] |
| 1031 function_info = inspect.getargspec(get_preferred_try_slaves) | 1035 function_info = inspect.getargspec(get_preferred_try_slaves) |
| 1032 if len(function_info[0]) == 1: | 1036 if len(function_info[0]) == 1: |
| 1033 result = get_preferred_try_slaves(project) | 1037 result = get_preferred_try_slaves(project) |
| 1034 elif len(function_info[0]) == 2: | 1038 elif len(function_info[0]) == 2: |
| 1035 result = get_preferred_try_slaves(project, change) | 1039 result = get_preferred_try_slaves(project, change) |
| 1036 else: | 1040 else: |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 except PresubmitFailure, e: | 1607 except PresubmitFailure, e: |
| 1604 print >> sys.stderr, e | 1608 print >> sys.stderr, e |
| 1605 print >> sys.stderr, 'Maybe your depot_tools is out of date?' | 1609 print >> sys.stderr, 'Maybe your depot_tools is out of date?' |
| 1606 print >> sys.stderr, 'If all fails, contact maruel@' | 1610 print >> sys.stderr, 'If all fails, contact maruel@' |
| 1607 return 2 | 1611 return 2 |
| 1608 | 1612 |
| 1609 | 1613 |
| 1610 if __name__ == '__main__': | 1614 if __name__ == '__main__': |
| 1611 fix_encoding.fix_encoding() | 1615 fix_encoding.fix_encoding() |
| 1612 sys.exit(Main(None)) | 1616 sys.exit(Main(None)) |
| OLD | NEW |