本文整理汇总了Python中Library.timeSinceEpoch方法的典型用法代码示例。如果您正苦于以下问题:Python Library.timeSinceEpoch方法的具体用法?Python Library.timeSinceEpoch怎么用?Python Library.timeSinceEpoch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library
的用法示例。
在下文中一共展示了Library.timeSinceEpoch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createDistributionRuns
# 需要导入模块: import Library [as 别名]
# 或者: from Library import timeSinceEpoch [as 别名]
def createDistributionRuns(newEmulation):
daemon=Library.getDaemon()
daemon.setEmuObject(newEmulation)
for distro in newEmulation.distroList:
if distro.getDistributionID() != "none":
#do nothing continue to next element, because this distribution was already scheduled.
print "Already scheduled"
else:
try:
conn = Library.dbconn()
c = conn.cursor()
# 1. We populate "distribution" table
c.execute('INSERT INTO distribution (distributionGranularity, distributionType,emulator,distributionName,startTime,duration,emulationID) VALUES (?, ?, ?, ?,?, ?,?)', [distro.granularity, distro.type, distro.emulatorName,distro.name,distro.startTime,distro.duration,newEmulation.emulationID])
distro.setDistributionID(c.lastrowid)
daemon.setEmuObject(newEmulation)
'''
{'startLoad': u'10', 'stopLoad': u'90'}
'''
#print "distributionArg:", distributionArg
#print "emulatorArg:",emulatorArg
#2. populate DistributionParameters, of table determined by distributionType name in our test it is "linearDistributionParameters"
for d in distro.distroArgs :
c.execute('INSERT INTO DistributionParameters (paramName,value,distributionID) VALUES (?, ?, ?)',[d,distro.distroArgs[d],distro.ID])
distributionParametersID=c.lastrowid
c.execute('UPDATE distribution SET distributionParametersID=? WHERE distributionID =?',(distributionParametersID,distro.ID))
for emu in distro.emulatorArg :
c.execute('INSERT INTO EmulatorParameters (paramName,value,resourceType,distributionID) VALUES (?, ?, ?,?)',[emu,distro.emulatorArg[emu],distro.resourceType,distro.ID])
distributionParametersID=c.lastrowid
conn.commit()
c.close()
except sqlite.Error, e:
print "Error %s:" % e.args[0]
print e
sys.exit(1)
startTime= Library.timeConv(newEmulation.startTimeEmu)
startTimesec=time.mktime(startTime.timetuple()) + float(distro.startTime)
#making sure that the run after event has valid date for scheduling
nowTime = Library.timeSinceEpoch(5)
if startTimesec < nowTime:
startTimesec = nowTime + float(distro.startTime)
'''
1. Load the module according to Distribution Type to create runs
'''
#1. Get required module loaded
modhandleMy=Library.loadDistribution(distro.type)
#Check if error returned
if (type(modhandleMy) is str):
raise Exception (modhandleMy)
#2. Use this module for calculation and run creation
stressValues,runStartTime,runDurations,triggerType=modhandleMy(newEmulation.emulationID,newEmulation.emulationName,newEmulation.getEmulationLifetimeID(),startTimesec,distro.duration, int(distro.granularity),distro.distroArgs,distro.resourceType,HOMEPATH)
if (distro.type != "event"): #event distributions don't require a minjobtime
try:
if (distro.distroArgs.has_key("minjobtime")):
minJobTime = distro.distroArgs["minjobtime"]
else:
minJobTime = 2
(stressValues, runStartTime, runDurations) = Library.checkMinJobTime(distro.name, stressValues, runStartTime, runDurations, distro.distroArgs["minjobtime"])
except Exception, e:
print "Could not enforce minimum job time. " + str(e)
runStartTime = Library.staggerStartTimes(runStartTime)
(stressValues, runStartTime, runDurations) = Library.removeZeroJobs(stressValues, runStartTime, runDurations) #Remove jobs with a stressValue of 0
#event and time type disro's separation
try :
n=0
for vals in stressValues:
#print "stressValues: ",vals
try:
#print "Things that are sent to daemon:\n",emulationID,emulationName,distributionName,emulationLifetimeID,runDurations[n],emulator,emulatorArg,resourceTypeDist,vals,runStartTime[n],str(n)
daemon.hello()
#Sending emulation name already including ID stamp
emulationNameID =str(newEmulation.emulationID)+"-"+str(newEmulation.emulationName)
schedulerReply = str(daemon.createJob(newEmulation.emulationID,emulationNameID,distro.ID,distro.name,newEmulation.getEmulationLifetimeID(),runDurations[n],distro.emulatorName,distro.emulatorArg,distro.resourceType,vals,runStartTime[n],str(n),runDurations[n]))
distLoggerDM=singleLogger("Distribution Manager",None,str(newEmulation.emulationID)+"-"+str(newEmulation.emulationName)+"-syslog"+"_"+str(newEmulation.startTimeEmu)+".csv")
distLoggerDM.info("Job Created: "+schedulerReply)
#adding values to the table for recovery
try:
conn = Library.dbconn()
c = conn.cursor()
#.........这里部分代码省略.........