old_contents: # -*- coding: utf-8-*-
  import Queue
  from modules import Gmail
  from apscheduler.scheduler import Scheduler
  import logging
  logging.basicConfig()
  
  
  class Notifier(object):
  
      class NotificationClient(object):
  
          def __init__(self, gather, timestamp):
              self.gather = gather
              self.timestamp = timestamp
  
          def run(self):
              self.timestamp = self.gather(self.timestamp)
  
      def __init__(self, profile):
          self.q = Queue.Queue()
          self.profile = profile
          self.notifiers = []
  
          if 'gmail_address' in profile and 'gmail_password' in profile:
              self.notifiers.append(self.NotificationClient(self.handleEmailNotifications, None))
  
          sched = Scheduler()
          sched.start()
          sched.add_interval_job(self.gather, seconds=30)
  
      def gather(self):
          [client.run() for client in self.notifiers]
  
      def handleEmailNotifications(self, lastDate):
          """Places new Gmail notifications in the Notifier's queue."""
          emails = Gmail.fetchUnreadEmails(self.profile, since=lastDate)
          if emails:
              lastDate = Gmail.getMostRecentDate(emails)
  
          def styleEmail(e):
              return "New email from %s." % Gmail.getSender(e)
  
          for e in emails:
              self.q.put(styleEmail(e))
  
          return lastDate
  
      def getNotification(self):
          """Returns a notification. Note that this function is consuming."""
          try:
              notif = self.q.get(block=False)
              return notif
          except Queue.Empty:
              return None
  
      def getAllNotifications(self):
          """
              Return a list of notifications in chronological order.
              Note that this function is consuming, so consecutive calls
              will yield different results.
          """
          notifs = []
  
          notif = self.getNotification()
          while notif:
              notifs.append(notif)
              notif = self.getNotification()
  
          return notifs
  
new_contents: # -*- coding: utf-8-*-
  import Queue
  from modules import Gmail
  from apscheduler.scheduler import Scheduler
  import logging
  logging.basicConfig()
  
  
  class Notifier(object):
  
      class NotificationClient(object):
  
          def __init__(self, gather, timestamp):
              self.gather = gather
              self.timestamp = timestamp
  
          def run(self):
              self.timestamp = self.gather(self.timestamp)
  
      def __init__(self, profile):
          self._logger = logging.getLogger(__name__)
          self.q = Queue.Queue()
          self.profile = profile
          self.notifiers = []
  
          if 'gmail_address' in profile and 'gmail_password' in profile:
              self.notifiers.append(self.NotificationClient(self.handleEmailNotifications, None))
          else:
              self._logger.warning('gmail_address or gmail_password not set in profile, Gmail notifier will not be used')
  
          sched = Scheduler()
          sched.start()
          sched.add_interval_job(self.gather, seconds=30)
  
      def gather(self):
          [client.run() for client in self.notifiers]
  
      def handleEmailNotifications(self, lastDate):
          """Places new Gmail notifications in the Notifier's queue."""
          emails = Gmail.fetchUnreadEmails(self.profile, since=lastDate)
          if emails:
              lastDate = Gmail.getMostRecentDate(emails)
  
          def styleEmail(e):
              return "New email from %s." % Gmail.getSender(e)
  
          for e in emails:
              self.q.put(styleEmail(e))
  
          return lastDate
  
      def getNotification(self):
          """Returns a notification. Note that this function is consuming."""
          try:
              notif = self.q.get(block=False)
              return notif
          except Queue.Empty:
              return None
  
      def getAllNotifications(self):
          """
              Return a list of notifications in chronological order.
              Note that this function is consuming, so consecutive calls
              will yield different results.
          """
          notifs = []
  
          notif = self.getNotification()
          while notif:
              notifs.append(notif)
              notif = self.getNotification()
  
          return notifs
  
subject: Add some logging in notifier module