-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.py
More file actions
executable file
·44 lines (39 loc) · 1.54 KB
/
console.py
File metadata and controls
executable file
·44 lines (39 loc) · 1.54 KB
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
#! /usr/bin/python3
import Desyntaxer
import ServiceHandler
import requests
import ServiceHandler
desyntaxer = Desyntaxer.Desyntaxer()
deviceHandler = ServiceHandler.DeviceHandler()
if __name__ == '__main__':
print("q - quit")
print("desyn [text] - desyntax entered text")
print("device print|init - Discovers devices on the network, or init a client side configuration of the devices")
print("match [text] - desyn's a sentence and tries to match to a initialized config found")
while(True):
command = input()
commands = command.split()
if(commands[0] == "q"):
break
elif(commands[0] == "desyn"):
commands.pop(0)
syn = desyntaxer.GetSyntax(' '.join(word for word in commands))
syn.PrintSyntax()
elif(commands[0] == "device"):
if(len(commands) > 1):
if(len(commands) >= 2):
if(commands[1] == "print"):
for device in deviceHandler.devices:
print("init: ", end="")
print(device.address,device.HasBeenInit)
elif(commands[0] == "match"):
commands.pop(0)
syn = desyntaxer.GetSyntax(' '.join(word for word in commands))
deviceUrl = deviceHandler.MatchSyntax(syn)
if(deviceUrl != None):
response = requests.get(deviceUrl)
print(response)
else:
print("no match found")
else:
print("not a valid command")