forked from GoogleCloudPlatform/python-docs-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
24 lines (19 loc) · 687 Bytes
/
Copy pathutils.py
File metadata and controls
24 lines (19 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from time import sleep
from googleapiclient.discovery import build
import httplib2
from oauth2client.client import GoogleCredentials
def build_client():
return build('cloudresourcemanager',
'v1beta1',
credentials=GoogleCredentials.get_application_default(),
# Use long timeout for create requests
http=httplib2.Http(timeout=90))
def wait_for_active(client, project):
timeout = 1
while project['lifecycleState'] != 'ACTIVE':
sleep(timeout)
timeout = timeout*2
project = client.projects().get(
projectId=project['projectId']
).execute()
return project