With this reference https://github.com/8go/matrix-commander Create one script using or…
- User
With this reference https://github.com/8go/matrix-commander Create one script using or calling matrix-commander.py to start a second Python3 script when I receive the message “GO” and stop the second with the reception of the message “STOP”
- Assistant
Here's an example script that uses matrix-commander.py to start and stop a second Python 3 script based on incoming messages:
#!/usr/bin/env python3 from matrix_lite import led from matrix_io.proto.malos.v1 import io_pb2 from matrix_io.proto.malos.v1 import driver_pb2 from matrix_io.proto.malos.v1 import common_pb2 from google.protobuf.json_format import MessageToJson import time import os # Initialize Matrix Commander mc = io_pb2.MalosDriverConfig() mc.endpoint.host = '127.0.0.1' mc.endpoint.port = 20042 mc.service = io_pb2.DRIVER mc.delay_between_updates = 0.1 # Connect to Matrix Commander try: driver = io_pb2.DriverChannelStub( common_pb2.ChannelCredentials(port=mc.endpoint.port)) driver.Init(mc) except Exception as e: print('Error connecting to Matrix Commander:', e) exit() # Start loop to check for incoming messages while True: try: # Check for incoming messages data = driver.Receive(common_pb2.Void(), 1) # If message is "GO", start the second script if data.content == b"GO": print("Starting second script...") os.system("python3 second_script.py &") # If message is "STOP", stop the second script elif data.content == b"STOP": print("Stopping second script...") os.system("pkill -f second_script.py") # If message is something else, ignore it else: continue # Handle any errors that occur except KeyboardInterrupt: break except Exception as e: print('Error:', e) continue # Disconnect from Matrix Commander driver.Stop(common_pb2.Void())
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.