Adding more assertions.
Fixing utility to actually work when presented with a file based acl instead
of a canonical one.
BUG=None
TEST=None
TBR=djmm
Review URL: http://codereview.chromium.org/2872025
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/gsd_generate_index@51237 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gsd_generate_index.py b/gsd_generate_index.py
index ff4bd89..435ca0f 100755
--- a/gsd_generate_index.py
+++ b/gsd_generate_index.py
@@ -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.