|
|
@ -24,6 +24,7 @@ import tempfile
|
|
|
|
from datetime import datetime
|
|
|
|
from datetime import datetime
|
|
|
|
import cv2
|
|
|
|
import cv2
|
|
|
|
import base64
|
|
|
|
import base64
|
|
|
|
|
|
|
|
import platform
|
|
|
|
from interpreter import interpreter # Just for code execution. Maybe we should let people do from interpreter.computer import run?
|
|
|
|
from interpreter import interpreter # Just for code execution. Maybe we should let people do from interpreter.computer import run?
|
|
|
|
# In the future, I guess kernel watching code should be elsewhere? Somewhere server / client agnostic?
|
|
|
|
# In the future, I guess kernel watching code should be elsewhere? Somewhere server / client agnostic?
|
|
|
|
from ..server.utils.kernel import put_kernel_messages_into_queue
|
|
|
|
from ..server.utils.kernel import put_kernel_messages_into_queue
|
|
|
@ -58,6 +59,7 @@ CAMERA_WARMUP_SECONDS = float(os.getenv('CAMERA_WARMUP_SECONDS', 0))
|
|
|
|
|
|
|
|
|
|
|
|
# Specify OS
|
|
|
|
# Specify OS
|
|
|
|
current_platform = get_system_info()
|
|
|
|
current_platform = get_system_info()
|
|
|
|
|
|
|
|
is_win10 = lambda: platform.system() == "Windows" and "10" in platform.version()
|
|
|
|
|
|
|
|
|
|
|
|
# Initialize PyAudio
|
|
|
|
# Initialize PyAudio
|
|
|
|
p = pyaudio.PyAudio()
|
|
|
|
p = pyaudio.PyAudio()
|
|
|
@ -252,9 +254,8 @@ class Device:
|
|
|
|
|
|
|
|
|
|
|
|
async def websocket_communication(self, WS_URL):
|
|
|
|
async def websocket_communication(self, WS_URL):
|
|
|
|
show_connection_log = True
|
|
|
|
show_connection_log = True
|
|
|
|
while True:
|
|
|
|
|
|
|
|
try:
|
|
|
|
async def exec_ws_communication(websocket):
|
|
|
|
async with websockets.connect(WS_URL) as websocket:
|
|
|
|
|
|
|
|
if CAMERA_ENABLED:
|
|
|
|
if CAMERA_ENABLED:
|
|
|
|
print("\nHold the spacebar to start recording. Press 'c' to capture an image from the camera. Press CTRL-C to exit.")
|
|
|
|
print("\nHold the spacebar to start recording. Press 'c' to capture an image from the camera. Press CTRL-C to exit.")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -305,6 +306,21 @@ class Device:
|
|
|
|
code = message["content"]
|
|
|
|
code = message["content"]
|
|
|
|
result = interpreter.computer.run(language, code)
|
|
|
|
result = interpreter.computer.run(language, code)
|
|
|
|
send_queue.put(result)
|
|
|
|
send_queue.put(result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if is_win10():
|
|
|
|
|
|
|
|
logger.info('Windows 10 detected')
|
|
|
|
|
|
|
|
# Workaround for Windows 10 not latching to the websocket server.
|
|
|
|
|
|
|
|
# See https://github.com/OpenInterpreter/01/issues/197
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
ws = websockets.connect(WS_URL)
|
|
|
|
|
|
|
|
await exec_ws_communication(ws)
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
logger.error(f"Error while attempting to connect: {e}")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
async with websockets.connect(WS_URL) as websocket:
|
|
|
|
|
|
|
|
await exec_ws_communication(websocket)
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
logger.debug(traceback.format_exc())
|
|
|
|
logger.debug(traceback.format_exc())
|
|
|
|
if show_connection_log:
|
|
|
|
if show_connection_log:
|
|
|
|