<commit_before>from feedback import Feedback
import boto
import os, time, pickle, sys

CACHE_FILE_EXT = "ec2_instances.cache"
MAX_CACHE_AGE = 10    #10s

#Alter the next 2 functions to change what fields are searched and appear in alfred
def parse_title(instance):
  return [
    instance.tags.get('Name', ''),
    instance.tags.get('aws:autoscaling:groupName', ''),
  ]

def parse_subtitle(instance):
  return [
    instance.id,
    str(instance.instance_type),
    getattr(instance, 'private_ip_address', '') or getattr(instance, 'public_ip_address', ''),
    str(instance.state),
  ]

# Alter the next function to change the return value
def pick_result_field(instance, fieldname):
  return {
    'priv': getattr(instance, 'private_ip_address', ''),
    'pub' : getattr(instance, 'public_ip_address', ''),
    'ami' : getattr(instance, 'image_id', ''),
    'id'  : getattr(instance, 'id', ''),
    ''    : getattr(instance, 'private_ip_address', '')
  }[fieldname]

#-----------------------


def get_instances(profile):
  if not profile: profile = 'default'
  cache_file = profile + '-' + CACHE_FILE_EXT
  if not os.path.isfile(cache_file) or time.time() - os.stat(cache_file).st_mtime > MAX_CACHE_AGE:
    ec2 = boto.connect_ec2(profile_name=profile)
    instances = ec2.get_only_instances()
    pickle.dump(instances, open(cache_file, 'w'), pickle.HIGHEST_PROTOCOL)
  
  return pickle.load(open(cache_file))

def main():
  profile, remaining = sys.argv[1].split('<', 1) if '<' in sys.argv[1] else (None, sys.argv[1])
  query, output_field = remaining.rsplit('>', 1) if '>' in remaining else (remaining, '')
  if profile == '':
    profile = None
  query = query.split()

  instances = get_instances(profile)

  for instance in instances:
    match = 0  <commit_msg>Fix public IP addresses not outputing<commit_after>from feedback import Feedback
import boto
import os, time, pickle, sys

CACHE_FILE_EXT = "ec2_instances.cache"
MAX_CACHE_AGE = 10    #10s

#Alter the next 2 functions to change what fields are searched and appear in alfred
def parse_title(instance):
  return [
    instance.tags.get('Name', ''),
    instance.tags.get('aws:autoscaling:groupName', ''),
  ]

def parse_subtitle(instance):
  return [
    instance.id,
    str(instance.instance_type),
    getattr(instance, 'private_ip_address', '') or getattr(instance, 'public_ip_address', ''),
    str(instance.state),
  ]

# Alter the next function to change the return value
def pick_result_field(instance, fieldname):
  return {
    'priv': getattr(instance, 'private_ip_address', ''),
    'pub' : getattr(instance, 'ip_address', ''),
    'ami' : getattr(instance, 'image_id', ''),
    'id'  : getattr(instance, 'id', ''),
    ''    : getattr(instance, 'private_ip_address', '')
  }[fieldname]

#-----------------------


def get_instances(profile):
  if not profile: profile = 'default'
  cache_file = profile + '-' + CACHE_FILE_EXT
  if not os.path.isfile(cache_file) or time.time() - os.stat(cache_file).st_mtime > MAX_CACHE_AGE:
    ec2 = boto.connect_ec2(profile_name=profile)
    instances = ec2.get_only_instances()
    pickle.dump(instances, open(cache_file, 'w'), pickle.HIGHEST_PROTOCOL)
  
  return pickle.load(open(cache_file))

def main():
  profile, remaining = sys.argv[1].split('<', 1) if '<' in sys.argv[1] else (None, sys.argv[1])
  query, output_field = remaining.rsplit('>', 1) if '>' in remaining else (remaining, '')
  if profile == '':
    profile = None
  query = query.split()

  instances = get_instances(profile)

  for instance in instances:
    match = 0  
{'fraction_non_alphanumeric': 0.15453779151447036, 'fraction_numerical': 0.008429334082607475, 'mean_word_length': 4.100286532951289, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6895809', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1202, 'n_words': 279}