25 lines
612 B
Python
25 lines
612 B
Python
from telnetlib import Telnet
|
|||
|
|
|
||
|
|
|
||
|
|
class Controller(object):
|
||
|
|
timeout = 30
|
||
|
|
|
||
|
|
def connect(self, host: str = "0.0.0.0", port: int = 5800):
|
||
|
|
self.connection = Telnet(host=host, port=port, timeout=Controller.timeout)
|
||
|
|
|
||
|
|
def execute(self, command: str):
|
||
|
|
self.connection.write(command.encode("ascii") + b"\r\n")
|
||
|
|
output = self.connection.read_until(b"END OF IT", timeout=2)
|
||
|
|
|
||
|
|
return output.decode("ascii")
|
||
|
|
|
||
|
|
def get_soundfonts(self):
|
||
|
|
self.execute("fonts")
|
||
|
|
|
||
|
|
return {}
|
||
|
|
|
||
|
|
def get_instruments(self, font: int):
|
||
|
|
self.execute(f"inst {font}")
|
||
|
|
|
||
|
|
return {}
|