From 07536fe1c3451b2687fbbd8bfec1f195f69fd5cb Mon Sep 17 00:00:00 2001 From: Johannes Wendel Date: Thu, 28 Nov 2019 23:03:28 +0100 Subject: [PATCH] Did some sensefull changes in main.py --- cli/FlippR_Networking.py | 2 +- cli/main.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cli/FlippR_Networking.py b/cli/FlippR_Networking.py index f40d4b7..f9c836b 100644 --- a/cli/FlippR_Networking.py +++ b/cli/FlippR_Networking.py @@ -48,7 +48,7 @@ class Networking: def getInputEvent(self): header = '' while chr(2) not in header: - header += self.input_socket.recv(1) + header += str(self.input_socket.recv(1)) length = int(header[:-1]) diff --git a/cli/main.py b/cli/main.py index d1fec49..23b940d 100644 --- a/cli/main.py +++ b/cli/main.py @@ -3,7 +3,7 @@ from cursesmenu.items import * import curses import argparse as ap from FlippR_Networking import Networking -import keyboard +import signal import os networking = "notset" @@ -37,10 +37,17 @@ def create_menu(): #win = curses.newwin(20,20,20,20) menu.show() + +#quit = False +#def sigint_handler(quit): + # quit = True def print_input(): - while(not keyboard.is_pressed('q')): + # end_loop_handler = signal.signal(signal.SIGINT, sigint_handler) + while(True): print(networking.getInputEvent()) + # signal.signal(signal.SIGINT, end_loop_handler) + quit = False def create_lamps_submenu(lamps): menu = CursesMenu("Output", "Lamps") @@ -91,10 +98,10 @@ def create_submenu(title, items, fun): def main(): argparser = ap.ArgumentParser() global networking - if os.getenv("XDG_RUNTIME_DIR"): - path = os.getenv("XDG_RUNTIME_DIR") + if os.environ["XDG_RUNTIME_DIR"]: + path = os.environ["XDG_RUNTIME_DIR"] else: - path = "/tmp/" + path = "/tmp" in_path = path + "/S.flippR_driver.in" out_path = path + "/S.flippR_driver.out" print("Input path: " + in_path + " output path " + out_path )