date option added to limit the query of containers

date in format YYYY-MM-DD to limit the query (default is all)
This commit is contained in:
Alexandre Dulaunoy 2013-02-07 16:38:18 +01:00
parent ee10433bd5
commit 8c98ae7524

View file

@ -41,6 +41,7 @@ parser.add_option("-k","--account_key", dest="account_key", help="Microsoft Azur
parser.add_option("-c","--clear", dest="clear", action='store_true', help="Delete blobs and containers after fetching") parser.add_option("-c","--clear", dest="clear", action='store_true', help="Delete blobs and containers after fetching")
parser.add_option("-e","--header", dest="header", action='store_true', help="Remove field header in the output (default is displayed)") parser.add_option("-e","--header", dest="header", action='store_true', help="Remove field header in the output (default is displayed)")
parser.add_option("-f","--format", dest="output_format", help="output txt, json (default is txt)") parser.add_option("-f","--format", dest="output_format", help="output txt, json (default is txt)")
parser.add_option("-t","--date", dest="date", help="date in format YYYY-MM-DD to limit the query (default is all)")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
@ -69,9 +70,11 @@ if header and not options.output_format:
print '\t'.join(str(h) for h in headers) print '\t'.join(str(h) for h in headers)
blob_service = BlobService(account_name, account_key) blob_service = BlobService(account_name, account_key)
for container in blob_service.list_containers(): for container in blob_service.list_containers():
c = container.name c = container.name
if c == "heartbeat": continue if c == "heartbeat": continue
if options.date and not ( c == "processed-"+options.date ): continue
if debug: sys.stderr.write("Processing container: "+str(c)+"\n") if debug: sys.stderr.write("Processing container: "+str(c)+"\n")
for b in blob_service.list_blobs(c): for b in blob_service.list_blobs(c):
if debug: sys.stderr.write("Processing blob: "+str(b.name)+"\n") if debug: sys.stderr.write("Processing blob: "+str(b.name)+"\n")