diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-02-16 12:59:45 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-02-16 12:59:45 +0100 |
commit | 1200fd15d5a110b15c16a333936bd3c74f90cbca (patch) | |
tree | bda82a026b57ecca81552787db49ce729f45671c /console/voerbak_connector.py | |
parent | b711f63c4087b3a9f5617af5b55afe93f414ddf5 (diff) |
semi-working voerbak_connector.py
Diffstat (limited to 'console/voerbak_connector.py')
-rw-r--r-- | console/voerbak_connector.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/console/voerbak_connector.py b/console/voerbak_connector.py new file mode 100644 index 0000000..b300af0 --- /dev/null +++ b/console/voerbak_connector.py @@ -0,0 +1,48 @@ +from colorama import Fore +import subprocess +import os + +DISC_SHAPE = "o" +DISC_A = Fore.RED + DISC_SHAPE + Fore.RESET +DISC_B = Fore.BLUE + DISC_SHAPE + Fore.RESET +EMPTY = Fore.LIGHTBLACK_EX + "_" + Fore.RESET + +class bord: + def __init__(self, w, h): + self.width = w + self.height = h + self.process = subprocess.Popen(["./voerbak"], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + msg = bytearray(f"{w} {h}\n", "utf-8") + print({"msg": msg}) + self.process.stdin.write(msg) + self.process.stdin.flush() + + # def print(self): + # for y in range(self.height -1, -1, -1): + # for x in range(self.width): + # print(self.board[x + y * self.width], end=" ") + # print("\n", end="") + + def drop_fisje(self, column): + msg = bytearray(f"{column}\n", "utf-8") + print({"msg": msg}) + self.process.stdin.write(msg) + self.process.stdin.flush() + +def main(): + gert = bord(7, 6) + while True: + # gert.print() + column = int(input("column?: ")) - 1 + if column not in range(gert.width): + continue + # os.system("clear") + gert.drop_fisje(column) + print(gert.process.stdout.readline()) + +if __name__ == "__main__": + main() + |