mirror of
https://github.com/clearml/wexpect-venv
synced 2025-05-04 04:11:22 +00:00
[FIX] #11 a very similar issue can be reproduced
This commit is contained in:
parent
016a674bf7
commit
0781222bdc
44
issues/i11_greek_parent.py
Normal file
44
issues/i11_greek_parent.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
|
||||||
|
import wexpect
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
here = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
sys.path.insert(0, here)
|
||||||
|
|
||||||
|
import i11_greek_printer
|
||||||
|
|
||||||
|
print(wexpect.__version__)
|
||||||
|
|
||||||
|
# With quotes (C:\Program Files\Python37\python.exe needs quotes)
|
||||||
|
python_executable = '"' + sys.executable + '" '
|
||||||
|
child_script = here + '\\i11_greek_printer.py'
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
unicodePrinter = python_executable + ' ' + child_script
|
||||||
|
prompt = 'give the name of a greek letter> '
|
||||||
|
|
||||||
|
# Start the child process
|
||||||
|
print('starting child: ' + unicodePrinter)
|
||||||
|
p = wexpect.spawn(unicodePrinter)
|
||||||
|
print('waiting for prompt')
|
||||||
|
|
||||||
|
# Wait for prompt
|
||||||
|
p.expect(prompt)
|
||||||
|
print('Child prompt arrived, lets start commands!')
|
||||||
|
|
||||||
|
# Send commands
|
||||||
|
for letterName in i11_greek_printer.greekLetters.keys():
|
||||||
|
p.sendline(letterName)
|
||||||
|
p.expect(prompt)
|
||||||
|
print(p.before.splitlines()[1])
|
||||||
|
if i11_greek_printer.greekLetters[letterName] != p.before.splitlines()[1]:
|
||||||
|
p.interact()
|
||||||
|
time.sleep(5)
|
||||||
|
raise Exception()
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
45
issues/i11_greek_printer.py
Normal file
45
issues/i11_greek_printer.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
greekLetters = {
|
||||||
|
'ALPHA': '\u03B1',
|
||||||
|
'BETA': '\u03B2',
|
||||||
|
'GAMMA': '\u03B3',
|
||||||
|
'DELTA': '\u03B4',
|
||||||
|
'EPSILON': '\u03B5',
|
||||||
|
'ZETA': '\u03B6',
|
||||||
|
'ETA': '\u03B7',
|
||||||
|
'THETA': '\u03B8',
|
||||||
|
'IOTA': '\u03B9',
|
||||||
|
'KAPPA': '\u03BA',
|
||||||
|
'LAMDA': '\u03BB',
|
||||||
|
'MU': '\u03BC',
|
||||||
|
'NU': '\u03BD',
|
||||||
|
'XI': '\u03BE',
|
||||||
|
'OMICRON': '\u03BF',
|
||||||
|
'PI': '\u03C0',
|
||||||
|
'RHO': '\u03C1',
|
||||||
|
'FINAL SIGMA': '\u03C2',
|
||||||
|
'SIGMA': '\u03C3',
|
||||||
|
'TAU': '\u03C4',
|
||||||
|
'UPSILON': '\u03C5',
|
||||||
|
'PHI': '\u03C6',
|
||||||
|
'CHI': '\u03C7',
|
||||||
|
'PSI': '\u03C8',
|
||||||
|
'OMEGA': '\u03C9'
|
||||||
|
}
|
||||||
|
|
||||||
|
def main():
|
||||||
|
while True:
|
||||||
|
letter = input('give the name of a greek letter> ')
|
||||||
|
if letter.lower() == 'exit':
|
||||||
|
print('Bye')
|
||||||
|
break
|
||||||
|
if letter.lower() == 'all':
|
||||||
|
print(greekLetters)
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
print(greekLetters[letter.upper()])
|
||||||
|
except:
|
||||||
|
print('ERROR!!! Uunknkown letter')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
48
issues/i11_unicode_parent.py
Normal file
48
issues/i11_unicode_parent.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
import wexpect
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
here = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
sys.path.insert(0, here)
|
||||||
|
|
||||||
|
import i11_unicode_printer
|
||||||
|
|
||||||
|
print(wexpect.__version__)
|
||||||
|
|
||||||
|
encodings = ['cp1250', 'utf-8']
|
||||||
|
|
||||||
|
|
||||||
|
# With quotes (C:\Program Files\Python37\python.exe needs quotes)
|
||||||
|
python_executable = '"' + sys.executable + '" '
|
||||||
|
child_script = here + '\\i11_unicode_printer.py'
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
unicodePrinter = python_executable + ' ' + child_script
|
||||||
|
prompt = '> '
|
||||||
|
|
||||||
|
for ec in encodings:
|
||||||
|
# Start the child process
|
||||||
|
p = wexpect.spawn(unicodePrinter)
|
||||||
|
|
||||||
|
# Wait for prompt
|
||||||
|
p.expect(prompt)
|
||||||
|
print('Child prompt arrived, lets set encoding!')
|
||||||
|
p.sendline(ec)
|
||||||
|
p.expect(prompt)
|
||||||
|
|
||||||
|
# Send commands
|
||||||
|
for cc in range(34, 500):
|
||||||
|
p.sendline(str(cc))
|
||||||
|
p.expect(prompt)
|
||||||
|
print(p.before.splitlines()[1])
|
||||||
|
if chr(int(cc)).encode("utf-8").decode(ec) != p.before.splitlines()[1]:
|
||||||
|
p.interact()
|
||||||
|
time.sleep(5)
|
||||||
|
raise Exception()
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
21
issues/i11_unicode_printer.py
Normal file
21
issues/i11_unicode_printer.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
encoding = "utf-8"
|
||||||
|
encoding = input('give the encoding> ')
|
||||||
|
while True:
|
||||||
|
code = input('give a number> ')
|
||||||
|
if code.lower() == 'exit':
|
||||||
|
print('Bye')
|
||||||
|
break
|
||||||
|
try:
|
||||||
|
print(chr(int(code)).encode("utf-8").decode(encoding) )
|
||||||
|
# code_int = int(code)
|
||||||
|
# print(greekLetters[letter.upper()])
|
||||||
|
except:
|
||||||
|
print('ERROR!!!')
|
||||||
|
raise
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user