#NEWLINE# def main( project , bucket , zone , instance_name , wait = True ) : #NEWLINE# #INDENT# credentials = GoogleCredentials . get_application_default ( ) #NEWLINE# compute = discovery . build ( 'compute' , 'v1' , credentials = credentials ) #NEWLINE# print ( 'Creating instance.' ) #NEWLINE# operation = create_instance ( compute , project , zone , instance_name , bucket ) #NEWLINE# wait_for_operation ( compute , project , zone , operation [ 'name' ] ) #NEWLINE# instances = list_instances ( compute , project , zone ) #NEWLINE# print ( ( 'Instances in project %s and zone %s:' % ( project , zone ) ) ) #NEWLINE# for instance in instances : #NEWLINE# #INDENT# print ( ( ' - ' + instance [ 'name' ] ) ) #NEWLINE# #UNINDENT# print ( '\nInstance created.\nIt will take a minute or two for the instance to complete work.\nCheck this URL: http://storage.googleapis.com/{}/output.png\nOnce the image is uploaded press enter to delete the instance.\n' . format ( bucket ) ) #NEWLINE# if wait : #NEWLINE# #INDENT# input ( ) #NEWLINE# #UNINDENT# print ( 'Deleting instance.' ) #NEWLINE# operation = delete_instance ( compute , project , zone , instance_name ) #NEWLINE# wait_for_operation ( compute , project , zone , operation [ 'name' ] )