-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] #11 a very similar issue can be reproduced
- Loading branch information
Showing
4 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
|