Created
March 23, 2015 12:47
-
-
Save makeittotop/c39aebc59e2a1796755a to your computer and use it in GitHub Desktop.
List a google nearline bucket contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import boto | |
| import gcs_oauth2_boto_plugin | |
| import os, sys, glob | |
| # URI scheme for Google Cloud Storage. | |
| GOOGLE_STORAGE = 'gs' | |
| # URI scheme for accessing local files. | |
| LOCAL_FILE = 'file' | |
| # Your project ID can be found at https://console.developers.google.com/ | |
| # If there is no domain for your project, then project_id = 'YOUR_PROJECT' | |
| project_id = 'iron-atom-89306' | |
| header_values = {"x-goog-project-id": project_id} | |
| for bucket in (sys.argv[1:]): | |
| uri = boto.storage_uri(bucket, GOOGLE_STORAGE) | |
| for obj in uri.get_bucket(): | |
| print '%s://%s/%s' % (uri.scheme, uri.bucket_name, obj.name) | |
| print ' "%s"' % obj.get_contents_as_string() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment