Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(602)

Side by Side Diff: dart/tools/bots/bot_utils.py

Issue 70223002: Only archive apidocs if they are not already there (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/editor/build/build.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 6
7 import hashlib 7 import hashlib
8 import imp 8 import imp
9 import os 9 import os
10 import subprocess 10 import subprocess
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 self.bucket = 'gs://dartlang-api-docs' 173 self.bucket = 'gs://dartlang-api-docs'
174 174
175 def docs_dirpath(self, revision): 175 def docs_dirpath(self, revision):
176 assert len('%s' % revision) > 0 176 assert len('%s' % revision) > 0
177 return '%s/channels/%s/%s' % (self.bucket, self.channel, revision) 177 return '%s/channels/%s/%s' % (self.bucket, self.channel, revision)
178 178
179 def docs_latestpath(self, revision): 179 def docs_latestpath(self, revision):
180 assert len('%s' % revision) > 0 180 assert len('%s' % revision) > 0
181 return '%s/channels/%s/latest.txt' % (self.bucket, self.channel) 181 return '%s/channels/%s/latest.txt' % (self.bucket, self.channel)
182 182
183 def run(command, env=None, shell=False): 183 def run(command, env=None, shell=False, throw_on_error=True):
184 print "Running command: ", command 184 print "Running command: ", command
185 185
186 p = subprocess.Popen(command, stdout=subprocess.PIPE, 186 p = subprocess.Popen(command, stdout=subprocess.PIPE,
187 stderr=subprocess.PIPE, env=env, shell=shell) 187 stderr=subprocess.PIPE, env=env, shell=shell)
188 (stdout, stderr) = p.communicate() 188 (stdout, stderr) = p.communicate()
189 if p.returncode != 0: 189 if throw_on_error and p.returncode != 0:
190 print >> sys.stderr, "Failed to execute '%s'. Exit code: %s." % ( 190 print >> sys.stderr, "Failed to execute '%s'. Exit code: %s." % (
191 command, p.returncode) 191 command, p.returncode)
192 print >> sys.stderr, "stdout: ", stdout 192 print >> sys.stderr, "stdout: ", stdout
193 print >> sys.stderr, "stderr: ", stderr 193 print >> sys.stderr, "stderr: ", stderr
194 raise Exception("Failed to execute %s." % command) 194 raise Exception("Failed to execute %s." % command)
195 return (stdout, stderr, p.returncode)
195 196
196 class GSUtil(object): 197 class GSUtil(object):
197 GSUTIL_IS_SHELL_SCRIPT = False 198 GSUTIL_IS_SHELL_SCRIPT = False
198 GSUTIL_PATH = None 199 GSUTIL_PATH = None
199 200
200 def _layzCalculateGSUtilPath(self): 201 def _layzCalculateGSUtilPath(self):
201 if not GSUtil.GSUTIL_PATH: 202 if not GSUtil.GSUTIL_PATH:
202 buildbot_gsutil = utils.GetBuildbotGSUtilPath() 203 buildbot_gsutil = utils.GetBuildbotGSUtilPath()
203 if os.path.isfile(buildbot_gsutil): 204 if os.path.isfile(buildbot_gsutil):
204 GSUtil.GSUTIL_IS_SHELL_SCRIPT = True 205 GSUtil.GSUTIL_IS_SHELL_SCRIPT = True
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 if not mangled_filename: 276 if not mangled_filename:
276 mangled_filename = os.path.basename(filename) 277 mangled_filename = os.path.basename(filename)
277 278
278 checksum = CalculateChecksum(filename) 279 checksum = CalculateChecksum(filename)
279 checksum_filename = '%s.md5sum' % filename 280 checksum_filename = '%s.md5sum' % filename
280 281
281 with open(checksum_filename, 'w') as f: 282 with open(checksum_filename, 'w') as f:
282 f.write('%s *%s' % (checksum, mangled_filename)) 283 f.write('%s *%s' % (checksum, mangled_filename))
283 284
284 return checksum_filename 285 return checksum_filename
OLDNEW
« no previous file with comments | « dart/editor/build/build.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698