<s> '''<STR_LIT>''' <EOL> import argparse <EOL> import ConfigParser <EOL> import StringIO <EOL> import boto . ec2 <EOL> import boto . ec2 . cloudwatch <EOL> def parseArguments ( ) : <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , choices = [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> default = "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> return parser . parse_args ( ) <EOL> def main ( ) : <EOL> args = parseArguments ( ) <EOL> config = ConfigParser . RawConfigParser ( ) <EOL> try : <EOL> with open ( args . config , "<STR_LIT:r>" ) as config_file : <EOL> ini_str = '<STR_LIT>' + config_file . read ( ) <EOL> ini_fp = StringIO . StringIO ( ini_str ) <EOL> config . readfp ( ini_fp ) <EOL> except IOError : <EOL> print "<STR_LIT>" + args . file <EOL> return <EOL> try : <EOL> region = config . get ( '<STR_LIT:root>' , '<STR_LIT>' ) <EOL> access_id = config . get ( '<STR_LIT:root>' , '<STR_LIT>' ) <EOL> secret_key = config . get ( '<STR_LIT:root>' , '<STR_LIT>' ) <EOL> except ConfigParser . NoOptionError as e : <EOL> print e <EOL> return <EOL> cloudwatch_conn = boto . ec2 . cloudwatch . connect_to_region ( region , <EOL> aws_access_key_id = access_id , <EOL> aws_secret_access_key = secret_key ) <EOL> metrics = cloudwatch_conn . list_metrics ( namespace = '<STR_LIT>' + args . service ) <EOL> for m in metrics : <EOL> print m . name , m . namespace , m . dimensions <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
