mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-04 04:41:35 +00:00
handle ToS not accepted yet for project create
This commit is contained in:
71
src/gam.py
71
src/gam.py
@@ -6753,12 +6753,15 @@ def getUserAttributes(i, cd, updateCmd=False):
|
|||||||
return (body, admin_body)
|
return (body, admin_body)
|
||||||
|
|
||||||
def doCreateProject():
|
def doCreateProject():
|
||||||
while True:
|
try:
|
||||||
hint = raw_input(u'What is your G Suite admin email address? ')
|
hint = sys.argv[3]
|
||||||
if hint.find(u'@') == -1:
|
except KeyError:
|
||||||
print u'Error: that is not a valid email address'
|
while True:
|
||||||
else:
|
hint = raw_input(u'What is your G Suite admin email address? ')
|
||||||
break
|
if hint.find(u'@') == -1:
|
||||||
|
print u'Error: that is not a valid email address'
|
||||||
|
else:
|
||||||
|
break
|
||||||
from oauth2client.contrib.dictionary_storage import DictionaryStorage
|
from oauth2client.contrib.dictionary_storage import DictionaryStorage
|
||||||
project_id = u'gam-project'
|
project_id = u'gam-project'
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
@@ -6784,24 +6787,44 @@ def doCreateProject():
|
|||||||
cache=GC_Values[GC_CACHE_DIR]))
|
cache=GC_Values[GC_CACHE_DIR]))
|
||||||
crm = googleapiclient.discovery.build(u'cloudresourcemanager', u'v1', http=http, cache_discovery=False)
|
crm = googleapiclient.discovery.build(u'cloudresourcemanager', u'v1', http=http, cache_discovery=False)
|
||||||
body = {u'projectId': project_id, u'name': u'GAM Project'}
|
body = {u'projectId': project_id, u'name': u'GAM Project'}
|
||||||
print u'Creating project "%s"...' % body[u'name']
|
while True:
|
||||||
create_operation = callGAPI(crm.projects(), u'create', body=body)
|
create_again = False
|
||||||
operation_name = create_operation[u'name']
|
print u'Creating project "%s"...' % body[u'name']
|
||||||
time.sleep(5) # Google recommends always waiting at least 5 seconds
|
create_operation = callGAPI(crm.projects(), u'create', body=body)
|
||||||
for i in range(1, 5):
|
operation_name = create_operation[u'name']
|
||||||
print u'Checking project status...'
|
time.sleep(5) # Google recommends always waiting at least 5 seconds
|
||||||
status = callGAPI(crm.operations(), u'get', name=operation_name)
|
for i in range(1, 5):
|
||||||
if u'done' in status and status[u'done']:
|
print u'Checking project status...'
|
||||||
break
|
status = callGAPI(crm.operations(), u'get', name=operation_name)
|
||||||
sleep_time = i ** 2
|
print status
|
||||||
print u'Project still being created. Sleeping %s seconds' % sleep_time
|
if u'error' in status:
|
||||||
time.sleep(sleep_time)
|
if u'message' in status[u'error'] and status[u'error'][u'message'].find(u'Callers must accept ToS') != -1:
|
||||||
if not u'done' in status or not status[u'done']:
|
print u'''Please go to:
|
||||||
print u'Failed to create project'
|
|
||||||
sys.exit(1)
|
https://console.developers.google.com
|
||||||
elif u'error' in status:
|
|
||||||
print status[u'error']
|
and accept the Terms of Service (ToS). As soon as you've accepted the ToS popup, you can return here and press enter.'''
|
||||||
sys.exit(2)
|
raw_input()
|
||||||
|
create_again = True
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print status
|
||||||
|
sys.exit(1)
|
||||||
|
if u'done' in status and status[u'done']:
|
||||||
|
break
|
||||||
|
sleep_time = i ** 2
|
||||||
|
print u'Project still being created. Sleeping %s seconds' % sleep_time
|
||||||
|
time.sleep(sleep_time)
|
||||||
|
if create_again:
|
||||||
|
continue
|
||||||
|
if not u'done' in status or not status[u'done']:
|
||||||
|
print u'Failed to create project: %s' % status
|
||||||
|
sys.exit(1)
|
||||||
|
elif u'error' in status:
|
||||||
|
print status[u'error']
|
||||||
|
sys.exit(2)
|
||||||
|
break
|
||||||
|
|
||||||
serveman = googleapiclient.discovery.build(u'servicemanagement', u'v1', http=http, cache_discovery=False)
|
serveman = googleapiclient.discovery.build(u'servicemanagement', u'v1', http=http, cache_discovery=False)
|
||||||
apis = [u'admin-json.googleapis.com', u'appsactivity-json.googleapis.com', u'calendar-json.googleapis.com',
|
apis = [u'admin-json.googleapis.com', u'appsactivity-json.googleapis.com', u'calendar-json.googleapis.com',
|
||||||
u'classroom.googleapis.com', u'drive', u'gmail-json.googleapis.com', u'groupssettings-json.googleapis.com',
|
u'classroom.googleapis.com', u'drive', u'gmail-json.googleapis.com', u'groupssettings-json.googleapis.com',
|
||||||
|
|||||||
Reference in New Issue
Block a user