| 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 """Client-side script to send a try job to the try server. It communicates to | 6 """Client-side script to send a try job to the try server. It communicates to |
| 7 the try server by either writting to a svn/git repository or by directly | 7 the try server by either writting to a svn/git repository or by directly |
| 8 connecting to the server by HTTP. | 8 connecting to the server by HTTP. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 @contextlib.contextmanager | 493 @contextlib.contextmanager |
| 494 def _TempFilename(name, contents=None): | 494 def _TempFilename(name, contents=None): |
| 495 """Create a temporary directory, append the specified name and yield. | 495 """Create a temporary directory, append the specified name and yield. |
| 496 | 496 |
| 497 In contrast to NamedTemporaryFile, does not keep the file open. | 497 In contrast to NamedTemporaryFile, does not keep the file open. |
| 498 Deletes the file on __exit__. | 498 Deletes the file on __exit__. |
| 499 """ | 499 """ |
| 500 temp_dir = tempfile.mkdtemp(prefix=name) | 500 temp_dir = tempfile.mkdtemp(prefix=name) |
| 501 try: | 501 try: |
| 502 path = os.path.join(temp_dir, name) | 502 path = os.path.join(temp_dir, name) |
| 503 if contents: | 503 if contents is not None: |
| 504 with open(path, 'wb') as f: | 504 with open(path, 'wb') as f: |
| 505 f.write(contents) | 505 f.write(contents) |
| 506 yield path | 506 yield path |
| 507 finally: | 507 finally: |
| 508 shutil.rmtree(temp_dir, True) | 508 shutil.rmtree(temp_dir, True) |
| 509 | 509 |
| 510 | 510 |
| 511 @contextlib.contextmanager | 511 @contextlib.contextmanager |
| 512 def _PrepareDescriptionAndPatchFiles(description, options): | 512 def _PrepareDescriptionAndPatchFiles(description, options): |
| 513 """Creates temporary files with description and patch. | 513 """Creates temporary files with description and patch. |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 return 1 | 1118 return 1 |
| 1119 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1119 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1120 print >> sys.stderr, e | 1120 print >> sys.stderr, e |
| 1121 return 1 | 1121 return 1 |
| 1122 return 0 | 1122 return 0 |
| 1123 | 1123 |
| 1124 | 1124 |
| 1125 if __name__ == "__main__": | 1125 if __name__ == "__main__": |
| 1126 fix_encoding.fix_encoding() | 1126 fix_encoding.fix_encoding() |
| 1127 sys.exit(TryChange(None, None, False)) | 1127 sys.exit(TryChange(None, None, False)) |
| OLD | NEW |