本文整理汇总了Python中pxStats.lib.StatsDateLib.StatsDateLib.getStartEndFromPreviousMonth方法的典型用法代码示例。如果您正苦于以下问题:Python StatsDateLib.getStartEndFromPreviousMonth方法的具体用法?Python StatsDateLib.getStartEndFromPreviousMonth怎么用?Python StatsDateLib.getStartEndFromPreviousMonth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pxStats.lib.StatsDateLib.StatsDateLib
的用法示例。
在下文中一共展示了StatsDateLib.getStartEndFromPreviousMonth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getOptionsFromParser
# 需要导入模块: from pxStats.lib.StatsDateLib import StatsDateLib [as 别名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getStartEndFromPreviousMonth [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"
#.........这里部分代码省略.........