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

Unified Diff: tools/get_archive.py

Issue 10867005: Made get_archive.py resilient to 403 forbidden errors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/get_archive.py
===================================================================
--- tools/get_archive.py (revision 11075)
+++ tools/get_archive.py (working copy)
@@ -71,7 +71,7 @@
"""Execute a command in a subprocess."""
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = pipe.communicate()
- return pipe.returncode, output
+ return pipe.returncode, output, error
def ExecuteCommandVisible(*cmd):
@@ -154,13 +154,25 @@
while not foundURL:
# Test to ensure this URL exists because the dartium-archive builds can
# have unusual numbering (a range of CL numbers) sometimes.
- result, out = Gsutil('ls', permanent_prefix % {'osname' : osname,
+ result, out, _ = Gsutil('ls', permanent_prefix % {'osname' : osname,
'num1': '*', 'num2': revision_num })
if result == 0:
# First try to find one with the the second number the same as the
# requested number.
latest = out.split()[0]
- foundURL = True
+ # Now test that the permissions are correct so you can actually
+ # download it.
+ temp_dir = tempfile.mkdtemp()
+ temp_zip = os.path.join(temp_dir, 'foo.zip')
+ returncode, out, err = Gsutil('cp', latest, 'file://' + temp_zip)
vsm 2012/08/22 18:08:09 It doesn't look like you're using err here.
+ if returncode == 0:
+ foundURL = True
+ else:
+ # Unable to download this item (most likely because something went
+ # wrong on the upload and the permissions are bad). Keep looking for
+ # a different URL.
+ revision_num = int(revision_num) - 1
+ shutil.rmtree(temp_dir)
else:
# Now try to find one with a nearby CL num.
revision_num = int(revision_num) - 1
@@ -233,7 +245,7 @@
# Query for the lastest version
pattern = latest_pattern % { 'osname' : osname }
- result, out = Gsutil('ls', pattern)
+ result, out, _ = Gsutil('ls', pattern)
if result == 0:
# use permanent link instead, just in case the latest zip entry gets deleted
# while we are downloading it.
@@ -268,7 +280,7 @@
# The Python zip utility does not preserve executable permissions, but
# this does not seem to be a problem for Windows, which does not have a
# built in zip utility. :-/
- result, out = ExecuteCommand('unzip', temp_zip, '-d', temp_dir)
+ result, out, _ = ExecuteCommand('unzip', temp_zip, '-d', temp_dir)
if result != 0:
raise Exception('Execution of "unzip %s -d %s" failed: %s' %
(temp_zip, temp_dir, str(out)))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698