[FIX] #9 fixed by removing repeted read in readConsole

This commit is contained in:
Benedek Racz 2019-10-01 16:06:26 +02:00
parent 366c89aa59
commit 0e359036ab

View File

@ -129,9 +129,9 @@ logger = logging.getLogger('wexpect')
if 'dev' in __version__ : if 'dev' in __version__ :
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)
else: else:
logger.setLevel(logging.INFO) logger.setLevel(logging.WARNING)
fh = logging.FileHandler('wexpect.log') fh = logging.FileHandler('wexpect.log')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') formatter = logging.Formatter('%(asctime)s - %(filename)s::%(funcName)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter) fh.setFormatter(formatter)
logger.addHandler(fh) logger.addHandler(fh)
@ -2165,19 +2165,23 @@ class Wtty:
startY = startCo.Y startY = startCo.Y
endX = endCo.X endX = endCo.X
endY = endCo.Y endY = endCo.Y
logger.debug("startX: %d startY %d -- endX: %d endY: %d", startX, startY, endX, endY)
while True: while True:
startOff = self.getOffset(startX, startY) startOff = self.getOffset(startX, startY)
endOff = self.getOffset(endX, endY) endOff = self.getOffset(endX, endY)
readlen = endOff - startOff readlen = endOff - startOff
logger.debug("startOff: %d endOff %d readlen: %d", startOff, endOff, readlen)
if readlen > 4000: if readlen > 4000:
readlen = 4000 readlen = 4000
endPoint = self.getPoint(startOff + 4000) endPoint = self.getPoint(startOff + 4000)
else: else:
endPoint = self.getPoint(endOff) endPoint = self.getPoint(endOff)
logger.debug("endPoint: (%d, %d)", endPoint[0], endPoint[1])
s = self.__consout.ReadConsoleOutputCharacter(readlen, startCo) s = self.__consout.ReadConsoleOutputCharacter(readlen, startCo)
logger.debug("ReadConsoleOutputCharacter: %s", repr(s))
ln = len(s) ln = len(s)
self.lastRead += ln self.lastRead += ln
self.totalRead += ln self.totalRead += ln
@ -2227,10 +2231,8 @@ class Wtty:
#log('isSamePos: %r' % isSamePos) #log('isSamePos: %r' % isSamePos)
if isSameY or not self.lastReadData.endswith('\r\n'): if isSameY or not self.lastReadData.endswith('\r\n'):
# Read the current slice again # This part causes the #09 issue. Test remove.
self.totalRead -= self.lastRead logger.debug('Read the current slice again')
self.__currentReadCo.X = 0
self.__currentReadCo.Y = self.__bufferY
#log('cursor: %r, current: %r' % (cursorPos, self.__currentReadCo)) #log('cursor: %r, current: %r' % (cursorPos, self.__currentReadCo))
@ -2881,7 +2883,3 @@ def split_command_line(command_line, escape_char = '^'):
if arg != '': if arg != '':
arg_list.append(arg) arg_list.append(arg)
return arg_list return arg_list