Пример #1
0
def getStats(startDate,endDate,**kwargs):
    nullwrite = NullWriter()
    oldstdout = sys.stdout
    sys.stdout = nullwrite
    kwargs["startDate"] = dt.datetime.strptime(startDate, '%Y-%m-%d')
    kwargs["endDate"] = dt.datetime.strptime(endDate, '%Y-%m-%d')
    statsDict = {}
    for statistic in sf.Statistic.__subclasses__():
        statsDict[statistic.__name__] = \
            sf.statFactory(statistic.__name__, **kwargs).getResult()    
    statsDict = flatten(statsDict)
    statsDict["Start Date"] = startDate
    statsDict["End Date"] = endDate
    sys.stdout = oldstdout
    return statsDict
Пример #2
0
def getRequestedStats(**kwargs):
    intervals = getMonthIntervals(kwargs["startDate"], kwargs["endDate"])
    monthCollection = []
    for interval in intervals:
        kwargs["startDate"] = interval["startDate"]
        kwargs["endDate"] = interval["endDate"]
        statsDict = {}
        for statistic in kwargs["stats"]:
            statsDict[statistic] = sf.statFactory(statistic, **kwargs) \
                                   .getResult()
        statsDict["Start Date"] = kwargs["startDate"].strftime('%d-%m-%Y')
        statsDict["End Date"] = kwargs["endDate"].strftime('%d-%m-%Y')
        statsDict["Node Type"] = kwargs["node"]
        statsDict = flatten(statsDict)
        monthCollection.append(statsDict)
    printStats(monthCollection)