From 352fb3d75770c3148842eaebab784fb0916cecc0 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 2 Jan 2023 18:36:33 +0100 Subject: [PATCH] Change Python event types to uppercase --- apis/python/node/src/lib.rs | 10 +++++----- examples/python-dataflow/no_webcam.py | 4 ++-- examples/python-dataflow/object_detection.py | 4 ++-- examples/python-dataflow/plot.py | 4 ++-- examples/python-dataflow/webcam.py | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/apis/python/node/src/lib.rs b/apis/python/node/src/lib.rs index 6d45bbf5..8e2be28c 100644 --- a/apis/python/node/src/lib.rs +++ b/apis/python/node/src/lib.rs @@ -24,7 +24,7 @@ impl IntoPy for PyInput<'_> { let dict = PyDict::new(py); let ty = match self.0 { - Event::Stop => "stop", + Event::Stop => "STOP", Event::Input { id, metadata, data } => { dict.set_item("id", id.to_string()) .wrap_err("failed to add input ID") @@ -38,21 +38,21 @@ impl IntoPy for PyInput<'_> { dict.set_item("metadata", metadata_to_pydict(&metadata, py)) .wrap_err("failed to add input metadata") .unwrap(); - "input" + "INPUT" } Event::InputClosed { id } => { dict.set_item("id", id.to_string()) .wrap_err("failed to add closed-input ID") .unwrap(); - "input-closed" + "INPUT_CLOSED" } Event::Error(err) => { dict.set_item("error", err) .wrap_err("failed to add error") .unwrap(); - "error" + "ERROR" } - _other => "unknown", + _other => "UNKNOWN", }; dict.set_item("type", ty) diff --git a/examples/python-dataflow/no_webcam.py b/examples/python-dataflow/no_webcam.py index 40acf8bb..01a99cb2 100755 --- a/examples/python-dataflow/no_webcam.py +++ b/examples/python-dataflow/no_webcam.py @@ -19,10 +19,10 @@ while time.time() - start < 20: # Wait next dora_input event = node.next() match event["type"]: - case "input": + case "INPUT": print("received input", event["id"]) node.send_output("image", arr.tobytes()) - case "stop": + case "STOP": print("received stop") case other: print("received unexpected event:", other) diff --git a/examples/python-dataflow/object_detection.py b/examples/python-dataflow/object_detection.py index b788cf75..3f07a18c 100755 --- a/examples/python-dataflow/object_detection.py +++ b/examples/python-dataflow/object_detection.py @@ -15,7 +15,7 @@ node = Node() for event in node: match event["type"]: - case "input": + case "INPUT": match event["id"]: case "image": print("received image input") @@ -28,7 +28,7 @@ for event in node: node.send_output("bbox", arrays, event["metadata"]) case other: print("ignoring unexpected input:", other) - case "stop": + case "STOP": print("received stop") case other: print("received unexpected event:", other) diff --git a/examples/python-dataflow/plot.py b/examples/python-dataflow/plot.py index 67a9b3db..e3723d94 100755 --- a/examples/python-dataflow/plot.py +++ b/examples/python-dataflow/plot.py @@ -92,7 +92,7 @@ node = Node() for event in node: match event["type"]: - case "input": + case "INPUT": status = plotter.on_input(event) match status: case Status.CONTINUE: @@ -100,7 +100,7 @@ for event in node: case Status.STOP: print("plotter returned stop status") break - case "stop": + case "STOP": print("received stop") case other: print("received unexpected event:", other) diff --git a/examples/python-dataflow/webcam.py b/examples/python-dataflow/webcam.py index 435fb5ec..cbcaedfc 100755 --- a/examples/python-dataflow/webcam.py +++ b/examples/python-dataflow/webcam.py @@ -17,11 +17,11 @@ while time.time() - start < 10: # Wait next dora_input event = node.next() match event["type"]: - case "input": + case "INPUT": ret, frame = video_capture.read() if ret: node.send_output("image", cv2.imencode(".jpg", frame)[1].tobytes()) - case "stop": + case "STOP": print("received stop") break case other: