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 |
5 """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 |
6 the try server by either writting to a svn repository or by directly connecting | 7 the try server by either writting to a svn repository or by directly connecting |
7 to the server by HTTP. | 8 to the server by HTTP. |
8 """ | 9 """ |
9 | 10 |
10 import datetime | 11 import datetime |
11 import errno | 12 import errno |
12 import getpass | 13 import getpass |
13 import logging | 14 import logging |
14 import optparse | 15 import optparse |
15 import os | 16 import os |
16 import posixpath | 17 import posixpath |
17 import re | 18 import re |
18 import shutil | 19 import shutil |
19 import sys | 20 import sys |
20 import tempfile | 21 import tempfile |
21 import urllib | 22 import urllib |
22 | 23 |
23 try: | 24 try: |
24 import simplejson as json | 25 import simplejson as json |
25 except ImportError: | 26 except ImportError: |
26 try: | 27 try: |
27 import json | 28 import json |
28 except ImportError: | 29 except ImportError: |
29 json = None | 30 json = None |
30 | 31 |
31 try: | 32 try: |
32 import breakpad | 33 import breakpad # pylint: disable=W0611 |
33 except ImportError: | 34 except ImportError: |
34 pass | 35 pass |
35 | 36 |
36 try: | 37 try: |
37 import gcl | 38 import gcl |
38 except ImportError: | 39 except ImportError: |
39 gcl = None | 40 gcl = None |
40 | 41 |
41 import gclient_utils | 42 import gclient_utils |
42 import scm | 43 import scm |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 # Assumes the svn credential is an email address. | 199 # Assumes the svn credential is an email address. |
199 self.options.email = scm.SVN.GetEmail(self.checkout_root) | 200 self.options.email = scm.SVN.GetEmail(self.checkout_root) |
200 logging.info("SVN(%s)" % self.checkout_root) | 201 logging.info("SVN(%s)" % self.checkout_root) |
201 | 202 |
202 def ReadRootFile(self, filename): | 203 def ReadRootFile(self, filename): |
203 data = SCM.ReadRootFile(self, filename) | 204 data = SCM.ReadRootFile(self, filename) |
204 if data: | 205 if data: |
205 return data | 206 return data |
206 | 207 |
207 # Try to search on the subversion repository for the file. | 208 # Try to search on the subversion repository for the file. |
208 try: | 209 if not gcl: |
209 from gcl import GetCachedFile | |
210 except ImportError: | |
211 return None | 210 return None |
212 data = GetCachedFile(filename) | 211 data = gcl.GetCachedFile(filename) |
213 logging.debug('%s:\n%s' % (filename, data)) | 212 logging.debug('%s:\n%s' % (filename, data)) |
214 return data | 213 return data |
215 | 214 |
216 def GenerateDiff(self): | 215 def GenerateDiff(self): |
217 """Returns a string containing the diff for the given file list. | 216 """Returns a string containing the diff for the given file list. |
218 | 217 |
219 The files in the list should either be absolute paths or relative to the | 218 The files in the list should either be absolute paths or relative to the |
220 given root. | 219 given root. |
221 """ | 220 """ |
222 if not self.files: | 221 if not self.files: |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 print >> sys.stderr, e | 759 print >> sys.stderr, e |
761 return 1 | 760 return 1 |
762 except gclient_utils.Error, e: | 761 except gclient_utils.Error, e: |
763 print >> sys.stderr, e | 762 print >> sys.stderr, e |
764 return 1 | 763 return 1 |
765 return 0 | 764 return 0 |
766 | 765 |
767 | 766 |
768 if __name__ == "__main__": | 767 if __name__ == "__main__": |
769 sys.exit(TryChange(None, [], False)) | 768 sys.exit(TryChange(None, [], False)) |
OLD | NEW |