コード例 #1
0
ファイル: serialport.py プロジェクト: rstager/odb2
 def write(self, str):
     """Pretend to write the given string to the port, raising an
     exception if that's not what was written in the recorded session.
     """
     timestamp, log_str = self.next_log("write")
     log_str = eval(log_str)
     if str != log_str:
         error("%d: write(%r) != log(%r)" % (self.line_number, str, log_str))
         raise ValueError
     self.timestamp = timestamp
     return
コード例 #2
0
 def write(self, str):
     """Pretend to write the given string to the port, raising an
     exception if that's not what was written in the recorded session.
     """
     timestamp, log_str = self.next_log("write")
     log_str = eval(log_str)
     if str != log_str:
         error("%d: write(%r) != log(%r)" %
               (self.line_number, str, log_str))
         raise ValueError
     self.timestamp = timestamp
     return
コード例 #3
0
ファイル: serialport.py プロジェクト: rstager/odb2
 def next_log(self, expected_action):
     """Return the next line from the log file and raise an exception
     if there's a major discrepancy.
     """
     line = self.logfile.readline()
     if not line: raise EOFError()
     self.line_number += 1
     line = line.rstrip('\r\n')
     timestamp, log_action, parameters = line.split(" ", 2)
     timestamp = float(timestamp)
     if not self.timestamp: self.timestamp = timestamp
     if expected_action != log_action:
         error("%d: %s != %s" % (self.line_number, expected_action, log_action))
         raise ValueError
     return timestamp, parameters
コード例 #4
0
 def next_log(self, expected_action):
     """Return the next line from the log file and raise an exception
     if there's a major discrepancy.
     """
     line = self.logfile.readline()
     if not line: raise EOFError()
     self.line_number += 1
     line = line.rstrip('\r\n')
     timestamp, log_action, parameters = line.split(" ", 2)
     timestamp = float(timestamp)
     if not self.timestamp: self.timestamp = timestamp
     if expected_action != log_action:
         error("%d: %s != %s" %
               (self.line_number, expected_action, log_action))
         raise ValueError
     return timestamp, parameters