本文整理汇总了Python中pxStats.lib.StatsDateLib.StatsDateLib.getStartEndFromCurrentDay方法的典型用法代码示例。如果您正苦于以下问题:Python StatsDateLib.getStartEndFromCurrentDay方法的具体用法?Python StatsDateLib.getStartEndFromCurrentDay怎么用?Python StatsDateLib.getStartEndFromCurrentDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pxStats.lib.StatsDateLib.StatsDateLib
的用法示例。
在下文中一共展示了StatsDateLib.getStartEndFromCurrentDay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getOptionsFromParser
# 需要导入模块: from pxStats.lib.StatsDateLib import StatsDateLib [as 别名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getStartEndFromCurrentDay [as 别名]
def getOptionsFromParser( parser ):
"""
@summary: Parses and validates the options found in the parser.
@return: If information was found to be valid, return options
"""
infos = None
date = []
( options, args )= parser.parse_args()
machines = options.machines.replace( ' ','').split(',')
date = options.date.replace('"','').replace("'",'')
fileType = options.fileType.replace("'",'')
daily = options.daily
weekly = options.weekly
monthly = options.monthly
yearly = options.yearly
fixedCurrent = options.fixedCurrent
fixedPrevious = options.fixedPrevious
turnOffLogging = options.turnOffLogging
includeGroups = options.includeGroups
machinesAreClusters = options.machinesAreClusters
outputLanguage = options.outputLanguage
if fixedPrevious and fixedCurrent:
print _("Error. Please use only one of the fixed options,either fixedPrevious or fixedCurrent. " )
print _("Use -h for help.")
print _("Program terminated.")
sys.exit()
counter = 0
specialParameters = [daily, monthly, weekly, yearly]
for specialParameter in specialParameters:
if specialParameter:
counter = counter + 1
if counter > 1 :
print _( "Error. Only one of the daily, weekly and yearly options can be use at a time " )
print _( "Use -h for help." )
print _( "Program terminated." )
sys.exit()
elif counter == 0:
print _( "Error. Please use either the -d -m -w or -y options. " )
print _( "Use -h for help." )
print _( "Program terminated." )
sys.exit()
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()
#TODO :fixStartEnd method???
if fixedPrevious :
if daily :
span = "daily"
graphicType = "daily"
start, end = StatsDateLib.getStartEndFromPreviousDay( date )
elif weekly:
span = "weekly"
graphicType = "weekly"
start, end = StatsDateLib.getStartEndFromPreviousWeek( date )
elif monthly:
span = "monthly"
graphicType = "monthly"
start, end = StatsDateLib.getStartEndFromPreviousMonth( date )
elif yearly:
span = "yearly"
graphicType = "yearly"
start, end = StatsDateLib.getStartEndFromPreviousYear( date )
timeSpan = int( StatsDateLib.getSecondsSinceEpoch( end ) - StatsDateLib.getSecondsSinceEpoch( start ) ) / 3600
elif fixedCurrent:
if daily :
span = "daily"
graphicType = "daily"
start, end = StatsDateLib.getStartEndFromCurrentDay( date )
elif weekly:
span = "weekly"
graphicType = "weekly"
start, end = StatsDateLib.getStartEndFromCurrentWeek( date )
elif monthly:
span = "monthly"
graphicType = "monthly"
#.........这里部分代码省略.........
示例2: getParametersFromForm
# 需要导入模块: from pxStats.lib.StatsDateLib import StatsDateLib [as 别名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getStartEndFromCurrentDay [as 别名]
def getParametersFromForm( self, form ):
"""
@summary: Initialises the queryParameters
based on the form received as
parameter.
@note : Absent parameters will be set to default values( [] or '' )
and will NOT raise exceptions. Use the searchForParameterErrors
function to search for errors
"""
global _
#print form
image = None #No image was produced yet
#Every param is received in an array, use [0] to get first item, nothing for array.
try:
querier = form["querier"].replace("'", "").replace('"','')
except:
querier = ''
try:
plotter = form["plotter"].replace("'", "").replace('"','')
except:
plotter = ''
try:
fileTypes = form["fileType"].replace("'", "").replace('"','')
except:
fileTypes = ''
try:
sourLients = form["sourLients"].split(',')
except:
sourLients = []
try:
groupName = form["groupName"].replace("'", "").replace('"','')
except:
groupName = ''
try:
machines = form["machines"].split(',')
except:
machines = []
if groupName != '' and ( sourLients == [] or sourLients == [''] ) :
configParameters = StatsConfigParameters( )
configParameters.getAllParameters()
if groupName in configParameters.groupParameters.groups:
if configParameters.groupParameters.groupFileTypes[groupName] == fileTypes and configParameters.groupParameters.groupsMachines[groupName] == machines:
sourLients = configParameters.groupParameters.groupsMembers[groupName]
try:
combine = form["combineSourlients"].replace(",", "").replace('"','')
if combine == 'false' or combine == 'False':
combine = False
elif combine == 'true' or combine == 'True':
combine = True
else:
raise
except:
combine = False
try:
endTime = form["endTime"].replace("'", "").replace('"','')
hour = endTime.split(" ")[1]
splitDate = endTime.split(" ")[0].split( '-' )
endTime = "%s" %( splitDate[2] + '-' + splitDate[1] + '-' + splitDate[0] + " " + hour )
if _("current") in str(form["fixedSpan"]).lower():
start, endTime = StatsDateLib.getStartEndFromCurrentDay(endTime)
elif _("previous") in str(form["fixedSpan"]).lower():
start, endTime = StatsDateLib.getStartEndFromPreviousDay( endTime )
except:
endTime = ''
try:
products = form["products"].split(',')
if products == [""]:
raise
except:
products = ["*"]
try:
statsTypes = form["statsTypes"].split(',')
except:
#.........这里部分代码省略.........