From 00da1af9213f1f880aca532d80217e9f19e8708e Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sun, 5 Oct 2025 23:08:43 -0700 Subject: [PATCH] Factor out Recording.stop() --- srec.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/srec.py b/srec.py index 35efcaf..50f311c 100644 --- a/srec.py +++ b/srec.py @@ -22,6 +22,13 @@ from gi.repository import GLib # nopep8 pylint: disable=wrong-import-position class Recording: process: subprocess.Popen[bytes] + def stop(self) -> None: + stdin = self.process.stdin + assert stdin is not None + stdin.write(b'q') + stdin.flush() + self.process.wait() + recording: Recording | None = None @@ -83,11 +90,7 @@ def on_start_recording(_: Gtk.Button, stack: Gtk.Stack) -> None: def on_stop_recording(_: Gtk.Button, stack: Gtk.Stack) -> None: global recording # pylint: disable=global-statement assert recording is not None - stdin = recording.process.stdin - assert stdin is not None - stdin.write(b'q') - stdin.flush() - recording.process.wait() + recording.stop() recording = None stack.set_visible_child_name("not_recording") -- 2.50.1