-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshell.py
72 lines (55 loc) · 1.86 KB
/
shell.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import signal
import sys
import os
import ctypes
import datetime
import pkg_resources
try:
# name of console
ctypes.windll.kernel32.SetConsoleTitleW("Consola CheLang")
except:
pass
from fulvo.basic import run
# ctrl + c function
def signal_handler(sig, frame):
print('Se metio el enano de ANVISA. Se suspende el partido')
sys.exit(0)
# set ctrl + c function
signal.signal(signal.SIGINT, signal_handler)
try:
dist = pkg_resources.get_distribution('playsound')
print("La cancha esta lista para jugar".format(dist.key, dist.version))
except pkg_resources.DistributionNotFound:
print('Las condiciones no permiten jugar el partido. Instala {}'.format('playsound'))
sys.exit(0)
def export():
for arg in sys.argv:
if arg[0] == "-":
sys.argv.remove(arg)
# if 1 argument open console
if len(sys.argv) == 1:
while True:
folder = os.path.basename(os.getcwd())
inputText = input("/"+ folder + " < Fulvo > ")
inputText = inputText.replace("\\","\\\\")
if inputText.strip() == "": continue
result, error = run(__file__,inputText)
if error: print(error.as_string())
elif result:
for programReturn in result.elements:
print(repr(programReturn))
# if 2 argument open file
else:
uri = sys.argv[1]
uri = uri.replace("\\","\\\\")
result, error = run(__file__, f'Correme("{uri}")')
if error: print(error.as_string())
elif result:
if len(result.elements) == 1:
print(repr(result.elements[0]))
elif len(result.elements) > 1:
print(repr(result))
folder = os.path.basename(os.getcwd())
input("/"+ folder + " Fulvo > Apreta enter y terminalo juez")
sys.exit(0)
export()