-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree.py
33 lines (33 loc) · 1.25 KB
/
tree.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import BinaryTree as bt
import subprocess
try:
system = input("Por favor indique su sistema operativo: [win|lin]: ")
while(not (system == "win" or system == "lin")):
system = input("Por favor indique su sistema operativo: [win|lin]: ")
if(system == "lin"):
checker = "./checker"
elif(system == "win"):
checker = "checker.exe"
while (True):
checkerInput = input("Ingrese la cadena: ")
if(checkerInput == "quit"):
break
if(checkerInput == ''):
print('Esa cadena no la reconoce nuestro lenguaje.')
continue
checkerOutput = subprocess.Popen([checker], stdout=subprocess.PIPE, stdin=subprocess.PIPE,
shell=True, universal_newlines=True)
checkerOutput.stdin.write(str(checkerInput))
checkerOutput = checkerOutput.communicate()[0].strip()
if(checkerOutput == 'Nothing'):
print('Esa cadena no la reconoce nuestro lenguaje.')
else:
try:
print(bt.createNode(checkerInput))
print('Result: ' + checkerOutput.split(' ')[1])
except:
print(checkerInput.split()[1])
except KeyboardInterrupt:
print()
pass