Bug fixes, CTRL-C fix, relative script fixes, less print statements
This commit is contained in:
		
							parent
							
								
									f2e51dd14f
								
							
						
					
					
						commit
						3571382a9f
					
				|  | @ -129,7 +129,7 @@ class Device: | ||||||
|                     self.audiosegments.remove(audio) |                     self.audiosegments.remove(audio) | ||||||
|                 await asyncio.sleep(0.1) |                 await asyncio.sleep(0.1) | ||||||
|             except: |             except: | ||||||
|                 traceback.print_exc() |                 logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     def record_audio(self): |     def record_audio(self): | ||||||
|  | @ -207,13 +207,10 @@ class Device: | ||||||
|             RECORDING = False |             RECORDING = False | ||||||
| 
 | 
 | ||||||
|     def on_press(self, key): |     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 |         self.pressed_keys.add(key)  # Add the pressed key to the set | ||||||
| 
 | 
 | ||||||
|         if keyboard.Key.esc in self.pressed_keys: |         if keyboard.Key.space in self.pressed_keys: | ||||||
|             logger.info("Exiting...") |  | ||||||
|             os._exit(0) |  | ||||||
|         elif keyboard.Key.space in self.pressed_keys: |  | ||||||
|             self.toggle_recording(True) |             self.toggle_recording(True) | ||||||
|         elif {keyboard.Key.ctrl, keyboard.KeyCode.from_char('c')} <= self.pressed_keys: |         elif {keyboard.Key.ctrl, keyboard.KeyCode.from_char('c')} <= self.pressed_keys: | ||||||
|             logger.info("Ctrl+C pressed. Exiting...") |             logger.info("Ctrl+C pressed. Exiting...") | ||||||
|  | @ -244,9 +241,9 @@ class Device: | ||||||
|             try: |             try: | ||||||
|                 async with websockets.connect(WS_URL) as websocket: |                 async with websockets.connect(WS_URL) as websocket: | ||||||
|                     if CAMERA_ENABLED: |                     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: |                     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)) |                     asyncio.create_task(self.message_sender(websocket)) | ||||||
| 
 | 
 | ||||||
|  | @ -285,7 +282,7 @@ class Device: | ||||||
|      |      | ||||||
| 
 | 
 | ||||||
|             except: |             except: | ||||||
|                 traceback.print_exc() |                 logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) | ||||||
|                 logger.info(f"Connecting to `{WS_URL}`...") |                 logger.info(f"Connecting to `{WS_URL}`...") | ||||||
|                 await asyncio.sleep(2) |                 await asyncio.sleep(2) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,8 +1,6 @@ | ||||||
| DEVICE=$(uname -n) | DEVICE=$(uname -n) | ||||||
| if [[ "$DEVICE" == "rpi" ]]; then | if [[ "$DEVICE" == "rpi" ]]; then | ||||||
|     cd 01OS |  | ||||||
|     python -m 01OS.clients.rpi.device |     python -m 01OS.clients.rpi.device | ||||||
| else | else | ||||||
|     cd 01OS |  | ||||||
|     python -m 01OS.clients.macos.device |     python -m 01OS.clients.macos.device | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  | @ -102,7 +102,7 @@ async def websocket_endpoint(websocket: WebSocket): | ||||||
|     try: |     try: | ||||||
|         await asyncio.gather(receive_task, send_task) |         await asyncio.gather(receive_task, send_task) | ||||||
|     except Exception as e: |     except Exception as e: | ||||||
|         traceback.print_exc() |         logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) | ||||||
|         logger.info(f"Connection lost. Error: {e}") |         logger.info(f"Connection lost. Error: {e}") | ||||||
| 
 | 
 | ||||||
| async def receive_messages(websocket: WebSocket): | async def receive_messages(websocket: WebSocket): | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ class Accumulator: | ||||||
|         self.message = self.template |         self.message = self.template | ||||||
| 
 | 
 | ||||||
|     def accumulate(self, chunk): |     def accumulate(self, chunk): | ||||||
|         print(str(chunk)[:100]) |         #print(str(chunk)[:100]) | ||||||
|         if type(chunk) == dict: |         if type(chunk) == dict: | ||||||
| 
 | 
 | ||||||
|             if "format" in chunk and chunk["format"] == "active_line": |             if "format" in chunk and chunk["format"] == "active_line": | ||||||
|  |  | ||||||
|  | @ -122,7 +122,7 @@ def on_press(key): | ||||||
|         toggle_recording(True) |         toggle_recording(True) | ||||||
| 
 | 
 | ||||||
| def on_release(key): | def on_release(key): | ||||||
|     """Detect spacebar release and ESC key press.""" |     """Detect spacebar release and CTRL-C key press.""" | ||||||
|     if key == keyboard.Key.space: |     if key == keyboard.Key.space: | ||||||
|         toggle_recording(False) |         toggle_recording(False) | ||||||
|     elif key == keyboard.Key.esc: |     elif key == keyboard.Key.esc: | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ packages = [ | ||||||
|     {include = "01OS"}, |     {include = "01OS"}, | ||||||
| ] | ] | ||||||
| include = [".env.example", "start.py", "start.sh"] | include = [".env.example", "start.py", "start.sh"] | ||||||
| version = "0.0.2" | version = "0.0.3" | ||||||
| description = "The open-source language model computer" | description = "The open-source language model computer" | ||||||
| authors = ["Killian <killian@openinterpreter.com>"] | authors = ["Killian <killian@openinterpreter.com>"] | ||||||
| license = "AGPL" | license = "AGPL" | ||||||
|  |  | ||||||
|  | @ -19,5 +19,8 @@ def main(): | ||||||
|     command = [os.path.join(dir_path, 'start.sh')] + args |     command = [os.path.join(dir_path, 'start.sh')] + args | ||||||
| 
 | 
 | ||||||
|     # Start start.sh with the command line arguments |     # Start start.sh with the command line arguments | ||||||
|     subprocess.run(command, check=True) |     try: | ||||||
|  |         subprocess.run(command, check=True) | ||||||
|  |     except KeyboardInterrupt: | ||||||
|  |         print("Exiting...") | ||||||
|      |      | ||||||
|  | @ -124,7 +124,7 @@ fi | ||||||
| 
 | 
 | ||||||
| start_client() { | start_client() { | ||||||
|     echo "Starting client..." |     echo "Starting client..." | ||||||
|     bash 01OS/clients/start.sh & |     bash $SCRIPT_DIR/01OS/clients/start.sh & | ||||||
|     CLIENT_PID=$! |     CLIENT_PID=$! | ||||||
|     echo "client started as process $CLIENT_PID" |     echo "client started as process $CLIENT_PID" | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 killian
						killian