diff options
Diffstat (limited to 'events.py')
-rw-r--r-- | events.py | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -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) |