From e3f4893b74b97e1de5e126761d9ec6a0f6585888 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Mon, 12 Jul 2021 04:19:46 +0100 Subject: Add recording event placeholder --- events.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'events.py') diff --git a/events.py b/events.py index 1ed185c..cbd17ea 100644 --- a/events.py +++ b/events.py @@ -2,6 +2,7 @@ import subprocess from datetime import datetime from config import config import requests +from multiprocessing import Process class Event(): def __init__(self, dial_manager, phone_held, phone_hung_up): @@ -89,3 +90,32 @@ class TimerEvent(Event): end = datetime.now() print(end - start) return "time" + +class RecordThread(Process): + def __init__(self): + super().__init__() + self.daemon = True + + def run(self): + subprocess.run(["time", "cat"]) + + +class RecordEvent(Event): + def get_name(self): + return "recorder" + + def get_text(self): + start = datetime.now() + print("timer start", start) + + record_thread = RecordThread() + record_thread.start() + + self.phone_hung_up.wait() + print("terminating") + record_thread.terminate() + + end = datetime.now() + print(end - start) + + return str(end-start) -- cgit v1.2.3