-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
78 lines (70 loc) · 2.73 KB
/
main.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
73
74
75
76
77
78
import cmdinterface as ci
from colorama import init as coloramainit
from colorama import Fore, Back, Style
coloramainit()
try:
open("start.lh", "r")
except FileNotFoundError:
ci.echo("0>start.lh")
open("start.lh", "w").write("1")
finally:
sett = ci.load("config.toml", 1)
with open("start.lh", "r") as f:
started = int(f.read())
if started == 1:
newJson = []
ci.aprint(sett["app"]["name"])
pcOpi = input("What your device? [PC|PI] > ").lower()
if pcOpi == "pc": newJson.append(0)
elif pcOpi == "pi": newJson.append(1)
else: newJson.append(None)
newJson.append(input("Your telegram bot token > "))
newJson.append(input("Your telegram user id > "))
ci.jsDump(sett["files"]["dataFile"], newJson)
ci.fWrite("start.lh", "0")
else:
newJson = ci.load(sett["files"]["dataFile"], 2)
if newJson[0] == 0:
ci.textAnimation(sett["app"]["name"], 0.1)
while True:
ci.update()
inputs = []
outputs = []
ci.aprint(sett["app"]["name"])
for i in range(sett["limites"]["inputPorts"]):
try:
infilerd = ci.fRead(f"{sett['files']['dataDir']}\\i{i+1}.lh")
except FileNotFoundError:
indenfalas = open(f"{sett['files']['dataDir']}\\i{i+1}.lh", "w")
indenfalas.close()
infilerd = ci.fRead(f"{sett['files']['dataDir']}\\i{i + 1}.lh")
if not infilerd == "":
inputs.append(infilerd)
else: inputs.append("NONE")
amounts = []
for i in range(sett["limites"]["inputPorts"]):
amounts.append(inputs[i])
inputsgui = []
for i in range(sett["limites"]["inputPorts"]):
inputsgui.append(f"Input {i+1}")
textToPrint = [inputsgui,amounts]
print(ci.atabulate(textToPrint))
for i in range(sett["limites"]["outputPorts"]):
try:
infilerd = ci.fRead(f"{sett['files']['dataDir']}\\o{i+1}.lh")
except FileNotFoundError:
indenfalas = open(f"{sett['files']['dataDir']}\\o{i+1}.lh", "w")
indenfalas.close()
infilerd = ci.fRead(f"{sett['files']['dataDir']}\\o{i + 1}.lh")
if not infilerd == "":
outputs.append(infilerd)
else: outputs.append("NONE")
amountsO = []
for i in range(sett["limites"]["outputPorts"]):
amountsO.append(outputs[i])
outputsgui = []
for i in range(sett["limites"]["outputPorts"]):
outputsgui.append(f"Output {i+1}")
textToPrintO = [outputsgui,amountsO]
print(ci.atabulate(textToPrintO))
ci.asleep(sett["settings"]["delayOfInput"])