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. |