new_contents: import sys
  import os
  
  import pyinotify
  
  root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  sys.path.append(root)
  
  from geotweet.load import S3Loader
  from geotweet.log import logger
  
  
  BUCKET = os.getenv("AWS_BUCKET", None)
  LOG_DIR = os.getenv("GEOTWEET_STREAM_DIR", "/tmp/geotweet")
  if not BUCKET:
      logger.info("Environment Variable AWS_BUCKET not set")
      sys.exit(1)
  
  
  class LogEventS3Handler(pyinotify.ProcessEvent):
      
      def my_init(self, s3=S3Loader()):
          """
          This is automatically called from ProcessEvent.__init__()
          """
          try:
              s3.valid()
              self.s3 = s3
          except EnvironmentError as e:
              print e
  
      def process_IN_MOVED_TO(self, event):
          """
          Log file was rotated. Send to s3
          """
          logger.debug("MOVED LOG {0} {1}".format(event.maskname, event.pathname))
          if self.s3:
              logger.info("Loading to S3 bucket {0}: {1}".format(BUCKET, event.pathname))
              self.s3.store(BUCKET, event.pathname)
              logger.info("Finished loading: {0}".format(event.pathname))
  
  
  class LogListener(object):
      
      def __init__(self, log_dir=LOG_DIR):
          """
          Listen for changes to files in log_dir
  
          When TwitterStream rotates a log the event handler will be called
          The LogEventS3Handler will load the log file into a s3 bucket on AWS
          """
          wm = pyinotify.WatchManager()
          self.notifier = pyinotify.Notifier(wm, LogEventS3Handler())
          self.log_dir = log_dir
          wm.add_watch(self.log_dir, pyinotify.ALL_EVENTS)
  
      def start(self):
          msg = "Start listening for events in directory: {0}"
          logger.info(msg.format(self.log_dir))
          self.notifier.loop()
      
  
  if __name__ == "__main__":
      LogListener().start()
  
subject: add script to listen for log files and load into s3