[FIX] getPoint; [ADD] more detailed reproduce script

This commit is contained in:
Benedek Racz 2019-10-03 21:59:04 +02:00
parent 7f0ade128f
commit d85f9b3d49
3 changed files with 63 additions and 54 deletions

View File

@ -6,7 +6,7 @@ import os
here = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, here)
import i11_unicode_printer
from long_printer import puskas_wiki
print(wexpect.__version__)
@ -22,33 +22,32 @@ def main():
# Start the child process
p = wexpect.spawn(longPrinter)
print('After Spawn')
# Wait for prompt
p.expect(prompt)
print('After prompt')
p.sendline('0')
p.expect(prompt)
print(p.before)
p.sendline('all')
print('After all')
p.expect(prompt)
print('After prompt')
print(p.before)
p.sendline('0')
p.expect(prompt)
print(p.before)
p.sendline('1')
p.expect(prompt)
print(p.before)
p.sendline('2')
p.expect(prompt)
print(p.before)
p.sendline('all')
p.expect(prompt)
print(p.before)
for i in range(10):
p.sendline('0')
p.expect(prompt)
if p.before.splitlines()[1] != puskas_wiki[0]:
print(p.before.splitlines()[1])
raise Exception()
p.sendline('all')
p.expect(prompt)
for a,b in zip(p.before.splitlines()[1:-1], puskas_wiki):
if a!=b:
print(p.before.splitlines()[1:-1])
raise Exception()
for j, paragraph in enumerate(puskas_wiki):
p.sendline(str(j))
p.expect(prompt)
if p.before.splitlines()[1] != paragraph:
print(p.before.splitlines()[1])
print(i)
print(j)
print(paragraph)
raise Exception()
main()

View File

@ -47,24 +47,26 @@ Budapest Honvéd, Puskás helped the club win five Hungarian League titles. He a
goal scorer in the league in 194748, 194950, 1950 and 1953, scoring 50, 31, 25 and 27 goals, \
respectively. In 1948, he was the top goal scorer in Europe.[17]''' ]
def main():
print('Welcome!')
print('Welcome!')
while True:
print('> ', end='')
num = input()
if num == 'exit':
break
if num == 'all':
print('\r\n'.join(puskas_wiki))
continue
try:
if int(num) in range(len(puskas_wiki)):
print(puskas_wiki[int(num)])
while True:
print('> ', end='')
num = input()
if num == 'exit':
break
if num == 'all':
print('\r\n'.join(puskas_wiki))
continue
except:
pass
print('unknown command')
try:
if int(num) in range(len(puskas_wiki)):
print(puskas_wiki[int(num)])
continue
except:
pass
print('unknown command')
if __name__ == '__main__':
main()

View File

@ -2146,7 +2146,7 @@ class Wtty:
"""Converts an offset to a point represented as a tuple."""
x = offset % self.__consSize[0]
y = offset / self.__consSize[0]
y = offset // self.__consSize[0]
return (x, y)
def getOffset(self, x, y):
@ -2157,7 +2157,7 @@ class Wtty:
def readConsole(self, startCo, endCo):
"""Reads the console area from startCo to endCo and returns it
as a string."""
buff = []
self.lastRead = 0
@ -2168,25 +2168,32 @@ class Wtty:
while True:
startOff = self.getOffset(startX, startY)
logger.info("startOff %s" % startOff)
endOff = self.getOffset(endX, endY)
logger.info("endOff %s" % endOff)
readlen = endOff - startOff
logger.info("readlen %s" % readlen)
if readlen > 4000:
readlen = 4000
endPoint = self.getPoint(startOff + 4000)
logger.info("endPoint {}".format(endPoint))
else:
endPoint = self.getPoint(endOff)
logger.info("endPoint {}".format(endPoint))
s = self.__consout.ReadConsoleOutputCharacter(readlen, startCo)
ln = len(s)
self.lastRead += ln
self.totalRead += ln
buff.append(s)
startX, startY = endPoint[0], endPoint[1]
logger.info("startX %s startY %s" % (startX, startY))
logger.info("endX %s endY %s" % (endX, endY))
if readlen <= 0 or (startX >= endX and startY >= endY):
break
return ''.join(buff)
def parseData(self, s):
@ -2211,6 +2218,7 @@ class Wtty:
position and inserts the string into self.__buffer."""
if not self.__consout:
logger.info('self.__consout is False')
return ""
consinfo = self.__consout.GetConsoleScreenBufferInfo()
@ -2322,10 +2330,10 @@ class Wtty:
timeout -= end - start
except Exception as e:
log(e)
log('End Of File (EOF) in Wtty.read_nonblocking().')
# This exception seems faulty EOF exception.
logger.info('Unknown Exception!!!')
self.switchBack()
raise EOF('End Of File (EOF) in Wtty.read_nonblocking().')
raise e
self.switchBack()
return s