本文整理汇总了Python中telnetlib.Telnet.read_lazy方法的典型用法代码示例。如果您正苦于以下问题:Python Telnet.read_lazy方法的具体用法?Python Telnet.read_lazy怎么用?Python Telnet.read_lazy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类telnetlib.Telnet
的用法示例。
在下文中一共展示了Telnet.read_lazy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from telnetlib import Telnet [as 别名]
# 或者: from telnetlib.Telnet import read_lazy [as 别名]
#.........这里部分代码省略.........
#job = "00:00:00 %s" % (job)
(timestamp, type, pick, drop, pickpri, droppri, echo_string) = job.split(" ", 6)
#interval = self.getInterval(self.lastTime, timestamp)
#print "Interval is %s %s %s" %( timestamp, self.lastTime, interval)
self.lastTime = timestamp
newJob = ReplayEntry()
self.numReplayJobs += 1
newJob.id = self.numReplayJobs
newJob.type = type
currentTime = time.strptime(timestamp, FMT)
if ( self.numReplayJobs == 1 ):
newJob.interval = 0
else:
newJob.interval = time.mktime(currentTime) - time.mktime(lastJobTimeStamp)
if ( newJob.interval < 0 ):
newJob.interval += 24*60*60
#newJob.interval = .5
lastJobTimeStamp = currentTime
newJob.pickupGoal = pick
newJob.dropoffGoal = drop
newJob.pickPri = pickpri
newJob.dropPri = droppri
newJob.echoStr = echo_string
if ( pick == lastDrop ):
self.numSwaps += 1
lastDrop = drop
self.rawReplayJobList.append(newJob)
log("Added job: %s %s %s %s %s" % (self.numReplayJobs, type, pick, drop, newJob.interval))
log("Total jobs: %s Swaps: %s" % (self.numReplayJobs, self.numSwaps))
# routine to clear old jobs. This should be used at startup
def clearQueue(self):
# flush incoming buffer
self.sock.read_lazy()
log("Clearing EM queue")
self.sock.write("queueshow\n")
jobList = []
queueIsClear = 0
while ( queueIsClear == 0 ):
buf = self.sock.read_until("\n", .1)
buf = buf.rstrip()
#log (buf)
if ( buf == "EndQueueShow" ):
queueIsClear = 1
return
( first, rest ) = buf.split(" ", 1)
if ( first == "QueueShow:" ):
( id, jobid, priority, status, rest ) = rest.split(" ", 4)
if ( status == "Pending" or status == "InProgress" ):
#self.sock.write("queuecancel jobid %s\n" % (jobid))
self.sock.write("queuecancel id %s\n" % (id))
log("Clearing job %s" % (id))
time.sleep(.1)
elif ( first == "QueueRobot:" ):
( robot, rest) = rest.split(" ", 1)
log("Cancelling robot %s" % (robot))
self.sock.write("queuecancel robotname %s\n" % (robot))
# Routine to establish the
def initializeConnection(self):