Projects STRLCPY got-your-back Commits 9d95cdbc
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    gyb.py
    skipped 562 lines
    563 563   e = e.args[0]
    564 564   systemErrorExit(5, e)
    565 565   
    566  -def callGAPI(service, function, soft_errors=False, throw_reasons=[], **kwargs):
     566 +def callGAPI(service, function, soft_errors=False, throw_reasons=[], retry_reasons=[], **kwargs):
    567 567   retries = 10
    568 568   parameters = kwargs.copy()
    569 569   parameters.update(extra_args)
    skipped 19 lines
    589 589   message = error['error']['errors'][0]['message']
    590 590   except (KeyError, json.decoder.JSONDecodeError):
    591 591   http_status = int(e.resp['status'])
    592  - reason = e.content
     592 + reason = http_status
    593 593   message = e.content
    594 594   if reason in throw_reasons:
    595 595   raise
    596 596   if n != retries and (http_status >= 500 or
    597  - reason in ['rateLimitExceeded', 'userRateLimitExceeded', 'backendError']):
     597 + reason in ['rateLimitExceeded', 'userRateLimitExceeded', 'backendError'] or
     598 + reason in retry_reasons):
    598 599   wait_on_fail = (2 ** n) if (2 ** n) < 60 else 60
    599 600   randomness = float(random.randint(1,1000)) / 1000
    600 601   wait_on_fail += randomness
    skipped 404 lines
    1005 1006   cache_discovery=False,
    1006 1007   discoveryServiceUrl=googleapiclient.discovery.V2_DISCOVERY_URI)
    1007 1008   print('Creating Service Account')
     1009 + sa_body = {
     1010 + 'accountId': project_id,
     1011 + 'serviceAccount': {
     1012 + 'displayName': 'GYB Project Service Account'
     1013 + }
     1014 + }
    1008 1015   service_account = callGAPI(iam.projects().serviceAccounts(), 'create',
    1009 1016   name='projects/%s' % project_id,
    1010  - body={'accountId': project_id, 'serviceAccount': {'displayName': 'GYB Project Service Account'}})
     1017 + body=sa_body)
     1018 + key_body = {
     1019 + 'privateKeyType': 'TYPE_GOOGLE_CREDENTIALS_FILE',
     1020 + 'keyAlgorithm': 'KEY_ALG_RSA_2048'
     1021 + }
    1011 1022   key = callGAPI(iam.projects().serviceAccounts().keys(), 'create',
    1012  - name=service_account['name'], body={'privateKeyType': 'TYPE_GOOGLE_CREDENTIALS_FILE', 'keyAlgorithm': 'KEY_ALG_RSA_2048'})
     1023 + name=service_account['name'], body=key_body, retry_reasons=[404])
    1013 1024   oauth2service_data = base64.b64decode(key['privateKeyData'])
    1014 1025   writeFile(service_account_file, oauth2service_data, continueOnError=False)
    1015 1026   _createClientSecretsOauth2service(project_id)
    skipped 1197 lines
Please wait...
Page is in error, reload to recover