<s> import os <EOL> import configparser <EOL> from aws_requests_auth . aws_auth import AWSRequestsAuth <EOL> from botocore . credentials import InstanceMetadataProvider , InstanceMetadataFetcher <EOL> class Auth ( object ) : <EOL> def __call__ ( self , host , username , password , aws_region , boto_profile ) : <EOL> """<STR_LIT>""" <EOL> if username and password : <EOL> return username + '<STR_LIT::>' + password <EOL> if not aws_region : <EOL> return None <EOL> if boto_profile : <EOL> config = configparser . ConfigParser ( ) <EOL> config . read ( os . path . expanduser ( '<STR_LIT>' ) + '<STR_LIT>' ) <EOL> aws_access_key_id = str ( config [ boto_profile ] [ '<STR_LIT>' ] ) <EOL> aws_secret_access_key = str ( config [ boto_profile ] [ '<STR_LIT>' ] ) <EOL> aws_token = None <EOL> else : <EOL> provider = InstanceMetadataProvider ( <EOL> iam_role_fetcher = InstanceMetadataFetcher ( timeout = <NUM_LIT:1000> , num_attempts = <NUM_LIT:2> ) ) <EOL> aws_credentials = provider . load ( ) <EOL> aws_access_key_id = str ( aws_credentials . access_key ) <EOL> aws_secret_access_key = str ( aws_credentials . secret_key ) <EOL> aws_token = str ( aws_credentials . token ) <EOL> return AWSRequestsAuth ( aws_access_key = aws_access_key_id , <EOL> aws_secret_access_key = aws_secret_access_key , <EOL> aws_token = aws_token , <EOL> aws_host = host , <EOL> aws_region = aws_region , <EOL> aws_service = '<STR_LIT>' ) </s>
