当前位置: 首页>>代码示例>>Python>>正文


Python Telnet.read_lazy方法代码示例

本文整理汇总了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):
开发者ID:parcon,项目名称:Adept,代码行数:70,代码来源:simulation.py


注:本文中的telnetlib.Telnet.read_lazy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。