本文整理汇总了Python中pxStats.lib.StatsDateLib.StatsDateLib.getStartEndInIsoFormat方法的典型用法代码示例。如果您正苦于以下问题:Python StatsDateLib.getStartEndInIsoFormat方法的具体用法?Python StatsDateLib.getStartEndInIsoFormat怎么用?Python StatsDateLib.getStartEndInIsoFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pxStats.lib.StatsDateLib.StatsDateLib
的用法示例。
在下文中一共展示了StatsDateLib.getStartEndInIsoFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepareQuery
# 需要导入模块: from pxStats.lib.StatsDateLib import StatsDateLib [as 别名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getStartEndInIsoFormat [as 别名]
def prepareQuery(self):
"""
@summary : Buildup the query to be executed.
@SIDE_EFFECT : modifies self.query value.
"""
global _
if self.queryParameters.combine == 'true':
totals = True
mergerType = "regular"
else:
totals = False
mergerType = ""
fixedCurrent = False
fixedPrevious = False
if _("current") in str(self.queryParameters.fixedSpan).lower() :
fixedCurrent = True
elif _("previous") in str(self.queryParameters.fixedSpan).lower():
fixedPrevious = True
else:
fixedCurrent = False
fixedPrevious = False
hour = self.queryParameters.endTime.split(" ")[1]
splitDate = self.queryParameters.endTime.split(" ")[0].split( '-' )
date = splitDate[2] + '-' + splitDate[1] + '-' + splitDate[0] + " " + hour
if self.queryParameters.span == "":
timespan = 0
else:
timespan = int(self.queryParameters.span )
StatsDateLib.setLanguage( self.querierLanguage )
startTime, endTime = StatsDateLib.getStartEndInIsoFormat(date, timespan, self.queryParameters.specificSpan, fixedCurrent, fixedPrevious )
timespan = int( StatsDateLib.getSecondsSinceEpoch( endTime ) - StatsDateLib.getSecondsSinceEpoch( startTime ) ) / 3600
combinedMachineName = ""
for machine in self.queryParameters.machines:
combinedMachineName = combinedMachineName + machine
machines = [ combinedMachineName ]
self.graphicProducer = RRDGraphicProducer( self.queryParameters.fileTypes[0], self.queryParameters.statsTypes ,\
totals, self.queryParameters.specificSpan,\
self.queryParameters.sourLients, timespan,\
startTime, endTime, machines, False,
mergerType, True, self.querierLanguage, self.querierLanguage )
StatsDateLib.setLanguage( LanguageTools.getMainApplicationLanguage() )
示例2: getGraphicProducerFromParserOptions
# 需要导入模块: from pxStats.lib.StatsDateLib import StatsDateLib [as 别名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getStartEndInIsoFormat [as 别名]
#.........这里部分代码省略.........
try: # Makes sure date is of valid format.
# Makes sure only one space is kept between date and hour.
t = time.strptime( date, '%Y-%m-%d %H:%M:%S' )
split = date.split()
date = "%s %s" %( split[0], split[1] )
except:
print _("Error. The date format must be YYYY-MM-DD HH:MM:SS")
print _("Use -h for help.")
print _("Program terminated.")
sys.exit()
#Set graphic type based on parameters. Only one tpye is allowed at once based on previous validation.
if daily :
graphicType = _("daily")
if fixedPrevious == False and fixedCurrent == False :
timespan = 24
elif weekly:
graphicType = _("weekly")
if fixedPrevious == False and fixedCurrent == False :
timespan = 24 * 7
elif monthly:
graphicType = _("monthly")
if fixedPrevious == False and fixedCurrent == False :
timespan = 24 * 30
elif yearly:
graphicType = _("yearly")
if fixedPrevious == False and fixedCurrent == False :
timespan = 24 * 365
start, end = StatsDateLib.getStartEndInIsoFormat(date, timespan, graphicType, fixedCurrent, fixedPrevious )
timespan = int( StatsDateLib.getSecondsSinceEpoch( end ) - StatsDateLib.getSecondsSinceEpoch( start ) ) / 3600
#print "timespan %s" %timespan
try:
if int( timespan ) < 1 :
raise
except:
print _("Error. The timespan value needs to be an integer one above 0.")
print _("Use -h for help.")
print _("Program terminated.")
sys.exit()
if fileType != "tx" and fileType != "rx":
print _("Error. File type must be either tx or rx.")
print "Specified file type was : ", fileType
print _("Multiple types are not accepted.")
print _("Use -h for additional help.")
print _("Program terminated.")
sys.exit()
if havingRun == True and clientNames[0] != _("ALL"):
print _("Error. Cannot use the havingRun option while specifying client/source names.")
print _("To use havingRun, do not use -c|--client option.")
print _("Use -h for additional help.")
print _("Program terminated.")
sys.exit()