OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 the V8 project authors. All rights reserved. | 2 # Copyright 2013 the V8 project authors. All rights reserved. |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
(...skipping 13 matching lines...) Expand all Loading... |
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 import os | 29 import os |
30 import re | 30 import re |
31 import subprocess | 31 import subprocess |
32 import sys | 32 import sys |
33 import textwrap | 33 import textwrap |
| 34 import urllib2 |
34 | 35 |
35 PERSISTFILE_BASENAME = "PERSISTFILE_BASENAME" | 36 PERSISTFILE_BASENAME = "PERSISTFILE_BASENAME" |
36 TEMP_BRANCH = "TEMP_BRANCH" | 37 TEMP_BRANCH = "TEMP_BRANCH" |
37 BRANCHNAME = "BRANCHNAME" | 38 BRANCHNAME = "BRANCHNAME" |
38 DOT_GIT_LOCATION = "DOT_GIT_LOCATION" | 39 DOT_GIT_LOCATION = "DOT_GIT_LOCATION" |
39 VERSION_FILE = "VERSION_FILE" | 40 VERSION_FILE = "VERSION_FILE" |
40 CHANGELOG_FILE = "CHANGELOG_FILE" | 41 CHANGELOG_FILE = "CHANGELOG_FILE" |
41 CHANGELOG_ENTRY_FILE = "CHANGELOG_ENTRY_FILE" | 42 CHANGELOG_ENTRY_FILE = "CHANGELOG_ENTRY_FILE" |
42 COMMITMSG_FILE = "COMMITMSG_FILE" | 43 COMMITMSG_FILE = "COMMITMSG_FILE" |
43 PATCH_FILE = "PATCH_FILE" | 44 PATCH_FILE = "PATCH_FILE" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 186 |
186 | 187 |
187 # Wrapper for side effects. | 188 # Wrapper for side effects. |
188 class SideEffectHandler(object): | 189 class SideEffectHandler(object): |
189 def Command(self, cmd, args="", prefix="", pipe=True): | 190 def Command(self, cmd, args="", prefix="", pipe=True): |
190 return Command(cmd, args, prefix, pipe) | 191 return Command(cmd, args, prefix, pipe) |
191 | 192 |
192 def ReadLine(self): | 193 def ReadLine(self): |
193 return sys.stdin.readline().strip() | 194 return sys.stdin.readline().strip() |
194 | 195 |
| 196 def ReadURL(self, url): |
| 197 # pylint: disable=E1121 |
| 198 url_fh = urllib2.urlopen(url, None, 60) |
| 199 try: |
| 200 return url_fh.read() |
| 201 finally: |
| 202 url_fh.close() |
| 203 |
195 DEFAULT_SIDE_EFFECT_HANDLER = SideEffectHandler() | 204 DEFAULT_SIDE_EFFECT_HANDLER = SideEffectHandler() |
196 | 205 |
197 | 206 |
198 class Step(object): | 207 class Step(object): |
199 def __init__(self, text="", requires=None): | 208 def __init__(self, text="", requires=None): |
200 self._text = text | 209 self._text = text |
201 self._number = -1 | 210 self._number = -1 |
202 self._options = None | 211 self._options = None |
203 self._requires = requires | 212 self._requires = requires |
204 self._side_effect_handler = DEFAULT_SIDE_EFFECT_HANDLER | 213 self._side_effect_handler = DEFAULT_SIDE_EFFECT_HANDLER |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 else: | 253 else: |
245 return self._side_effect_handler.ReadLine() | 254 return self._side_effect_handler.ReadLine() |
246 | 255 |
247 def Git(self, args="", prefix="", pipe=True): | 256 def Git(self, args="", prefix="", pipe=True): |
248 return self._side_effect_handler.Command("git", args, prefix, pipe) | 257 return self._side_effect_handler.Command("git", args, prefix, pipe) |
249 | 258 |
250 def Editor(self, args): | 259 def Editor(self, args): |
251 return self._side_effect_handler.Command(os.environ["EDITOR"], args, | 260 return self._side_effect_handler.Command(os.environ["EDITOR"], args, |
252 pipe=False) | 261 pipe=False) |
253 | 262 |
| 263 def ReadURL(self, url): |
| 264 return self._side_effect_handler.ReadURL(url) |
| 265 |
254 def Die(self, msg=""): | 266 def Die(self, msg=""): |
255 if msg != "": | 267 if msg != "": |
256 print "Error: %s" % msg | 268 print "Error: %s" % msg |
257 print "Exiting" | 269 print "Exiting" |
258 raise Exception(msg) | 270 raise Exception(msg) |
259 | 271 |
260 def DieInForcedMode(self, msg=""): | 272 def DieInForcedMode(self, msg=""): |
261 if self._options and self._options.f: | 273 if self._options and self._options.f: |
262 msg = msg or "Not implemented in forced mode." | 274 msg = msg or "Not implemented in forced mode." |
263 self.Die(msg) | 275 self.Die(msg) |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 step.SetNumber(number) | 444 step.SetNumber(number) |
433 step.SetConfig(config) | 445 step.SetConfig(config) |
434 step.SetOptions(options) | 446 step.SetOptions(options) |
435 step.SetState(state) | 447 step.SetState(state) |
436 step.SetSideEffectHandler(side_effect_handler) | 448 step.SetSideEffectHandler(side_effect_handler) |
437 steps.append(step) | 449 steps.append(step) |
438 number += 1 | 450 number += 1 |
439 | 451 |
440 for step in steps[options.s:]: | 452 for step in steps[options.s:]: |
441 step.Run() | 453 step.Run() |
OLD | NEW |