| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 """Client-side script to send a try job to the try server. It communicates to | 5 """Client-side script to send a try job to the try server. It communicates to |
| 6 the try server by either writting to a svn repository or by directly connecting | 6 the try server by either writting to a svn repository or by directly connecting |
| 7 to the server by HTTP. | 7 to the server by HTTP. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import datetime | 10 import datetime |
| 11 import errno | 11 import errno |
| 12 import getpass | 12 import getpass |
| 13 import logging | 13 import logging |
| 14 import optparse | 14 import optparse |
| 15 import os | 15 import os |
| 16 import posixpath | 16 import posixpath |
| 17 import re | 17 import re |
| 18 import shutil | 18 import shutil |
| 19 import sys | 19 import sys |
| 20 import tempfile | 20 import tempfile |
| 21 import urllib | 21 import urllib |
| 22 | 22 |
| 23 try: | 23 try: |
| 24 import simplejson as json |
| 25 except ImportError: |
| 26 try: |
| 27 import json |
| 28 except ImportError: |
| 29 json = None |
| 30 |
| 31 try: |
| 24 import breakpad | 32 import breakpad |
| 25 except ImportError: | 33 except ImportError: |
| 26 pass | 34 pass |
| 27 | 35 |
| 28 import gclient_utils | 36 import gclient_utils |
| 29 import scm | 37 import scm |
| 30 | 38 |
| 31 __version__ = '1.2' | 39 __version__ = '1.2' |
| 32 | 40 |
| 33 | 41 |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 if options.files: | 622 if options.files: |
| 615 parser.error('You cannot specify files and --url at the same time.') | 623 parser.error('You cannot specify files and --url at the same time.') |
| 616 options.diff = urllib.urlopen(options.url).read() | 624 options.diff = urllib.urlopen(options.url).read() |
| 617 elif options.diff: | 625 elif options.diff: |
| 618 if options.files: | 626 if options.files: |
| 619 parser.error('You cannot specify files and --diff at the same time.') | 627 parser.error('You cannot specify files and --diff at the same time.') |
| 620 options.diff = gclient_utils.FileRead(options.diff, 'rb') | 628 options.diff = gclient_utils.FileRead(options.diff, 'rb') |
| 621 elif options.issue and options.patchset is None: | 629 elif options.issue and options.patchset is None: |
| 622 # Retrieve the patch from rietveld when the diff is not specified. | 630 # Retrieve the patch from rietveld when the diff is not specified. |
| 623 # When patchset is specified, it's because it's done by gcl/git-try. | 631 # When patchset is specified, it's because it's done by gcl/git-try. |
| 624 try: | 632 if json is None: |
| 625 import simplejson | 633 parser.error('json or simplejson library is missing, please install.') |
| 626 except ImportError: | |
| 627 parser.error('simplejson library is missing, please install.') | |
| 628 api_url = '%s/api/%d' % (options.rietveld_url, options.issue) | 634 api_url = '%s/api/%d' % (options.rietveld_url, options.issue) |
| 629 logging.debug(api_url) | 635 logging.debug(api_url) |
| 630 contents = simplejson.loads(urllib.urlopen(api_url).read()) | 636 contents = json.loads(urllib.urlopen(api_url).read()) |
| 631 options.patchset = contents['patchsets'][-1] | 637 options.patchset = contents['patchsets'][-1] |
| 632 diff_url = ('%s/download/issue%d_%d.diff' % | 638 diff_url = ('%s/download/issue%d_%d.diff' % |
| 633 (options.rietveld_url, options.issue, options.patchset)) | 639 (options.rietveld_url, options.issue, options.patchset)) |
| 634 diff = GetMungedDiff('', urllib.urlopen(diff_url).readlines()) | 640 diff = GetMungedDiff('', urllib.urlopen(diff_url).readlines()) |
| 635 options.diff = ''.join(diff) | 641 options.diff = ''.join(diff) |
| 636 else: | 642 else: |
| 637 # Use this as the base. | 643 # Use this as the base. |
| 638 root = checkouts[0].checkout_root | 644 root = checkouts[0].checkout_root |
| 639 diffs = [] | 645 diffs = [] |
| 640 for checkout in checkouts: | 646 for checkout in checkouts: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 except (InvalidScript, NoTryServerAccess), e: | 700 except (InvalidScript, NoTryServerAccess), e: |
| 695 if swallow_exception: | 701 if swallow_exception: |
| 696 return 1 | 702 return 1 |
| 697 print e | 703 print e |
| 698 return 1 | 704 return 1 |
| 699 return 0 | 705 return 0 |
| 700 | 706 |
| 701 | 707 |
| 702 if __name__ == "__main__": | 708 if __name__ == "__main__": |
| 703 sys.exit(TryChange(None, [], False)) | 709 sys.exit(TryChange(None, [], False)) |
| OLD | NEW |