# Path: dcmetrometrics/common/utils.py
# def gen_days(s, e):
#     """Generate days between start_day s and end_day e (exclusive)"""
#     d = s
#     while d < e:
#         yield d
#         d = d + timedelta(days = 1)
# 
# Path: dcmetrometrics/common/dbGlobals.py
# class _DBGlobals(object):
#     def __init__(self):
#     def update(self):
#     def getEscalatorIds(self):
#     def getElevatorIds(self):
#     def getUnitIds(self):
#     def getDB(self):
# def getDB():
# def connect():
# def G():
# _G = None # Global object
#     _G = _DBGlobals()


from mongoengine import *
from operator import attrgetter
from ..common.metroTimes import TimeRange, UTCToLocalTime, toUtc, tzny, utcnow, dateToOpen
from ..common.WebJSONMixin import WebJSONMixin
from ..common.DataWriteable import DataWriteable
from ..common.utils import gen_days
from .defs import symptomToCategory, SYMPTOM_CHOICES
from ..common import dbGlobals
from .misc_utils import *
from .StatusGroup import StatusGroup
from datetime import timedelta, datetime, date
import sys
import logging
      Save the KeyStatuses doc and return it.

      If the key statuses have already been computed,
      use the KeyStatuses.update method to simply update
      the existing KeyStatuses record with the latest escalator
      status.
      """
      statuses = self.get_statuses()
      self.key_statuses = None

      if not statuses:
        return None

      logger.info("Computing key statuses entry for unit: " + self.unit_id)
      self.key_statuses = KeyStatuses.select_key_statuses(statuses)
      if save:
        self.save()
      return self.key_statuses

  def compute_daily_service_reports(self, save = False, statuses = [],
     start_day = date(2013, 6, 1),
     last_day = None):

    if last_day is None:
      last_day = date.today() + timedelta(days=1)

    if not statuses:
      statuses = self.get_statuses()

    docs = []

# Path: dcmetrometrics/common/utils.py
# def gen_days(s, e):
#     """Generate days between start_day s and end_day e (exclusive)"""
#     d = s
#     while d < e:
#         yield d
#         d = d + timedelta(days = 1)
# 
# Path: dcmetrometrics/common/dbGlobals.py
# class _DBGlobals(object):
#     def __init__(self):
#     def update(self):
#     def getEscalatorIds(self):
#     def getElevatorIds(self):
#     def getUnitIds(self):
#     def getDB(self):
# def getDB():
# def connect():
# def G():
# _G = None # Global object
#     _G = _DBGlobals()


# Path: dcmetrometrics/eles/models.py
from mongoengine import *
from operator import attrgetter
from ..common.metroTimes import TimeRange, UTCToLocalTime, toUtc, tzny, utcnow, dateToOpen
from ..common.WebJSONMixin import WebJSONMixin
from ..common.DataWriteable import DataWriteable
from ..common.utils import gen_days
from .defs import symptomToCategory, SYMPTOM_CHOICES
from ..common import dbGlobals
from .misc_utils import *
from .StatusGroup import StatusGroup
from datetime import timedelta, datetime, date
import sys
import logging

      Save the KeyStatuses doc and return it.

      If the key statuses have already been computed,
      use the KeyStatuses.update method to simply update
      the existing KeyStatuses record with the latest escalator
      status.
      """
      statuses = self.get_statuses()
      self.key_statuses = None

      if not statuses:
        return None

      logger.info("Computing key statuses entry for unit: " + self.unit_id)
      self.key_statuses = KeyStatuses.select_key_statuses(statuses)
      if save:
        self.save()
      return self.key_statuses

  def compute_daily_service_reports(self, save = False, statuses = [],
     start_day = date(2013, 6, 1),
     last_day = None):

    if last_day is None:
      last_day = date.today() + timedelta(days=1)

    if not statuses:
      statuses = self.get_statuses()

    docs = []

    for day in gen_days(start_day, last_day):