diff --git a/01OS/01OS/clients/base_device.py b/01OS/01OS/clients/base_device.py index 60f3cf3..26ff235 100644 --- a/01OS/01OS/clients/base_device.py +++ b/01OS/01OS/clients/base_device.py @@ -129,7 +129,7 @@ class Device: self.audiosegments.remove(audio) await asyncio.sleep(0.1) except: - traceback.print_exc() + logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) def record_audio(self): @@ -207,13 +207,10 @@ class Device: RECORDING = False def on_press(self, key): - """Detect spacebar press, ESC key press, and Ctrl+C combination.""" + """Detect spacebar press and Ctrl+C combination.""" self.pressed_keys.add(key) # Add the pressed key to the set - if keyboard.Key.esc in self.pressed_keys: - logger.info("Exiting...") - os._exit(0) - elif keyboard.Key.space in self.pressed_keys: + if keyboard.Key.space in self.pressed_keys: self.toggle_recording(True) elif {keyboard.Key.ctrl, keyboard.KeyCode.from_char('c')} <= self.pressed_keys: logger.info("Ctrl+C pressed. Exiting...") @@ -244,9 +241,9 @@ class Device: try: async with websockets.connect(WS_URL) as websocket: if CAMERA_ENABLED: - logger.info("Press the spacebar to start/stop recording. Press 'c' to capture an image from the camera. Press ESC to exit.") + logger.info("Press the spacebar to start/stop recording. Press 'c' to capture an image from the camera. Press CTRL-C to exit.") else: - logger.info("Press the spacebar to start/stop recording. Press ESC to exit.") + logger.info("Press the spacebar to start/stop recording. Press CTRL-C to exit.") asyncio.create_task(self.message_sender(websocket)) @@ -285,7 +282,7 @@ class Device: except: - traceback.print_exc() + logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) logger.info(f"Connecting to `{WS_URL}`...") await asyncio.sleep(2) diff --git a/01OS/01OS/clients/start.sh b/01OS/01OS/clients/start.sh index 844e6a0..d602a78 100644 --- a/01OS/01OS/clients/start.sh +++ b/01OS/01OS/clients/start.sh @@ -1,8 +1,6 @@ DEVICE=$(uname -n) if [[ "$DEVICE" == "rpi" ]]; then - cd 01OS python -m 01OS.clients.rpi.device else - cd 01OS python -m 01OS.clients.macos.device fi diff --git a/01OS/01OS/server/server.py b/01OS/01OS/server/server.py index 9710fd5..3ac559b 100644 --- a/01OS/01OS/server/server.py +++ b/01OS/01OS/server/server.py @@ -102,7 +102,7 @@ async def websocket_endpoint(websocket: WebSocket): try: await asyncio.gather(receive_task, send_task) except Exception as e: - traceback.print_exc() + logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) logger.info(f"Connection lost. Error: {e}") async def receive_messages(websocket: WebSocket): diff --git a/01OS/01OS/utils/accumulator.py b/01OS/01OS/utils/accumulator.py index 93f9c2f..5b039e2 100644 --- a/01OS/01OS/utils/accumulator.py +++ b/01OS/01OS/utils/accumulator.py @@ -4,7 +4,7 @@ class Accumulator: self.message = self.template def accumulate(self, chunk): - print(str(chunk)[:100]) + #print(str(chunk)[:100]) if type(chunk) == dict: if "format" in chunk and chunk["format"] == "active_line": diff --git a/01OS/_archive/device.py b/01OS/_archive/device.py index 3e71554..ee6eb55 100644 --- a/01OS/_archive/device.py +++ b/01OS/_archive/device.py @@ -122,7 +122,7 @@ def on_press(key): toggle_recording(True) def on_release(key): - """Detect spacebar release and ESC key press.""" + """Detect spacebar release and CTRL-C key press.""" if key == keyboard.Key.space: toggle_recording(False) elif key == keyboard.Key.esc: diff --git a/01OS/pyproject.toml b/01OS/pyproject.toml index 42f5992..5f4d26c 100644 --- a/01OS/pyproject.toml +++ b/01OS/pyproject.toml @@ -4,7 +4,7 @@ packages = [ {include = "01OS"}, ] include = [".env.example", "start.py", "start.sh"] -version = "0.0.2" +version = "0.0.3" description = "The open-source language model computer" authors = ["Killian "] license = "AGPL" diff --git a/01OS/start.py b/01OS/start.py index ea734fa..886d332 100644 --- a/01OS/start.py +++ b/01OS/start.py @@ -19,5 +19,8 @@ def main(): command = [os.path.join(dir_path, 'start.sh')] + args # Start start.sh with the command line arguments - subprocess.run(command, check=True) + try: + subprocess.run(command, check=True) + except KeyboardInterrupt: + print("Exiting...") \ No newline at end of file diff --git a/01OS/start.sh b/01OS/start.sh index 36b7ec6..2db9140 100755 --- a/01OS/start.sh +++ b/01OS/start.sh @@ -124,7 +124,7 @@ fi start_client() { echo "Starting client..." - bash 01OS/clients/start.sh & + bash $SCRIPT_DIR/01OS/clients/start.sh & CLIENT_PID=$! echo "client started as process $CLIENT_PID" }