#NEWLINE# def get_or_create_mrjob_service_role( conn ) : #NEWLINE# #INDENT# 'Look for a usable service role for EMR, and if there is none,\n    create one.' #NEWLINE# for ( role_name , role_document ) in _yield_roles ( conn ) : #NEWLINE# #INDENT# if ( role_document != _MRJOB_SERVICE_ROLE ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# policy_arns = list ( _yield_attached_role_policies ( conn , role_name ) ) #NEWLINE# if ( policy_arns == [ _EMR_SERVICE_ROLE_POLICY_ARN ] ) : #NEWLINE# #INDENT# return role_name #NEWLINE# #UNINDENT# #UNINDENT# name = _create_mrjob_role_with_attached_policy ( conn , _MRJOB_SERVICE_ROLE , _EMR_SERVICE_ROLE_POLICY_ARN ) #NEWLINE# log . info ( ( 'Auto-created service role %s' % name ) ) #NEWLINE# return policy_arns