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

Unified Diff: gsd_generate_index/gsd_generate_index.py

Issue 2872025: Adding more assertions.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/
Patch Set: Created 10 years, 6 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: gsd_generate_index/gsd_generate_index.py
===================================================================
--- gsd_generate_index/gsd_generate_index.py (revision 51169)
+++ gsd_generate_index/gsd_generate_index.py (working copy)
@@ -51,6 +51,7 @@
cmd = [options.gsutil, 'ls', '-l', path]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
p_stdout, _ = p.communicate()
+ assert p.returncode == 0
# Extract intersting fields.
fields = {}
fields['size'] = FixupSize(re.search('\tObject size:\t([0-9]+)\n',
@@ -110,10 +111,10 @@
index += '</html>'
# Check current state.
cmd = [options.gsutil, 'cat', posixpath.join(path, GENERATED_INDEX)]
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p_stdout, _ = p.communicate()
- # Done if it's alrady right.
- if p_stdout == index and not options.force:
+ # Done if it's alrady right (and the cat worked).
+ if p.returncode == 0 and p_stdout == index and not options.force:
print '%s -- skipping, up to date' % path
return
# Write to a file.
@@ -123,11 +124,17 @@
f.flush()
# Upload index.
cmd = [options.gsutil, 'cp']
- if options.acl:
- cmd += ['-a', options.acl]
cmd += [filename, posixpath.join(path, GENERATED_INDEX)]
p = subprocess.Popen(cmd)
p.communicate()
+ assert p.returncode == 0
+ # Optionally update acl.
+ if options.acl:
+ cmd = [options.gsutil, 'setacl', options.acl]
+ cmd += [posixpath.join(path, GENERATED_INDEX)]
+ p = subprocess.Popen(cmd)
+ p.communicate()
+ assert p.returncode == 0
print '%s -- updated index' % path
@@ -137,6 +144,7 @@
cmd = [options.gsutil, 'ls', posixpath.join(path, '*')]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
p_stdout, _ = p.communicate()
+ assert p.returncode == 0
objects = str(p_stdout).splitlines()
objects = [o for o in objects if posixpath.basename(o) != GENERATED_INDEX]
# Find common prefixes.
« 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