better way to handle per-API batch

This commit is contained in:
Jay Lee
2018-03-28 15:12:09 -04:00
parent a9025e2aba
commit 6a70a1412b

View File

@ -5461,8 +5461,7 @@ def doDeleteLabel(users):
bcount = 0 bcount = 0
j = 0 j = 0
del_me_count = len(del_labels) del_me_count = len(del_labels)
batch_uri = gmail._rootDesc['rootUrl'] + gmail._rootDesc['batchPath'] dbatch = gmail.new_batch_http_request()
dbatch = googleapiclient.http.BatchHttpRequest(batch_uri=batch_uri)
for del_me in del_labels: for del_me in del_labels:
j += 1 j += 1
print u' deleting label %s (%s/%s)' % (del_me[u'name'], j, del_me_count) print u' deleting label %s (%s/%s)' % (del_me[u'name'], j, del_me_count)
@ -5470,7 +5469,7 @@ def doDeleteLabel(users):
bcount += 1 bcount += 1
if bcount == 10: if bcount == 10:
dbatch.execute() dbatch.execute()
dbatch = googleapiclient.http.BatchHttpRequest(batch_uri=batch_uri) dbatch = gmail.new_batch_http_request()
bcount = 0 bcount = 0
if bcount > 0: if bcount > 0:
dbatch.execute() dbatch.execute()
@ -8846,8 +8845,7 @@ def doGetUserInfo(user_email=None):
if getLicenses: if getLicenses:
print u'Licenses:' print u'Licenses:'
lic = buildGAPIObject(u'licensing') lic = buildGAPIObject(u'licensing')
batch_uri = lic._rootDesc['rootUrl'] + lic._rootDesc['batchPath'] lbatch = lic.new_batch_http_request(callback=user_lic_result)
lbatch = googleapiclient.http.BatchHttpRequest(callback=user_lic_result, batch_uri=batch_uri)
user_licenses = [] user_licenses = []
for sku in skus: for sku in skus:
productId, skuId = getProductAndSKU(sku) productId, skuId = getProductAndSKU(sku)