本文整理汇总了Python中datalogger.DataLogger.monthwalker方法的典型用法代码示例。如果您正苦于以下问题:Python DataLogger.monthwalker方法的具体用法?Python DataLogger.monthwalker怎么用?Python DataLogger.monthwalker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datalogger.DataLogger
的用法示例。
在下文中一共展示了DataLogger.monthwalker方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_statics
# 需要导入模块: from datalogger import DataLogger [as 别名]
# 或者: from datalogger.DataLogger import monthwalker [as 别名]
def test_statics(self):
self.assertTrue(isinstance(DataLogger.get_user(self.basedir), basestring))
self.assertTrue(isinstance(DataLogger.get_group(self.basedir), basestring))
self.assertTrue(isinstance(DataLogger.get_yesterday_datestring(), basestring))
lbd = DataLogger.get_last_business_day_datestring()
self.assertTrue(isinstance(DataLogger.get_last_business_day_datestring(), basestring))
self.assertTrue(isinstance(DataLogger.datestring_to_date(lbd), datetime.date))
for datestring in DataLogger.datewalker("2016-01-01", "2016-02-29"):
self.assertTrue(isinstance(datestring, basestring))
for datestring in DataLogger.monthwalker("2016-02"):
self.assertTrue(isinstance(datestring, basestring))
self.assertEqual(list(DataLogger.monthwalker("2016-02"))[-1], "2016-02-29")
self.assertTrue(isinstance(DataLogger.get_ts_for_datestring("2016-01-01"), tuple))
self.assertTrue(isinstance(DataLogger.get_ts_for_datestring("2016-01-01")[0], float))
self.assertTrue(isinstance(DataLogger.get_ts_for_datestring("2016-01-01")[1], float))
示例2: get_monthly_ts
# 需要导入模块: from datalogger import DataLogger [as 别名]
# 或者: from datalogger.DataLogger import monthwalker [as 别名]
def get_monthly_ts(self, project, tablename, monthstring, args):
"""
get monthly statistical values
TODO: should be combined with get_lt_ts
"""
index_key_enc = None
value_keyname = None
stat_func_name = "avg"
if len(args) == 2:
index_key_enc, value_keyname = args
else:
index_key_enc, value_keyname, stat_func_name = args
if len(monthstring) != 7:
web.internalerror()
return "monthstring, has to be in YYYY-MM format"
# key_str should be a tuple string, convert to unicode tuple
index_key = tuple([unicode(key_value) for key_value in eval(base64.b64decode(index_key_enc))])
logging.info("index_key : %s", index_key)
logging.info("value_keyname : %s", value_keyname)
logging.info("stat_func_name: %s", stat_func_name)
datalogger = DataLogger(basedir, project, tablename)
filterkeys = dict(zip(datalogger.index_keynames, index_key))
ret_data = []
for datestring in datalogger.monthwalker(monthstring):
logging.debug("getting tsatstats for %s", monthstring)
try:
tsastats = datalogger.load_tsastats(datestring, filterkeys=filterkeys)
ret_data.append([datestring, tsastats[index_key][value_keyname][stat_func_name]])
except DataLoggerRawFileMissing as exc:
logging.error("No Input File for datestring %s found, skipping this date", datestring)
except DataLoggerLiveDataError as exc:
logging.error("Reading from live data is not allowed, skipping this data, and ending loop")
break
return json.dumps(ret_data)