Skip to content

Commit

Permalink
split proc to replay_proc and record_proc
Browse files Browse the repository at this point in the history
  • Loading branch information
jesicasusanto committed Jun 27, 2023
1 parent 6096a8f commit ecf0e65
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions openadapt/widget/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ def __init__(self, **kwargs):
self.window.size = (50, 50)
self.window.clearcolor = (255, 255, 255)
self.window.always_on_top = True
self.PROC = None
self.record_proc = None
self.replay_proc = None
self.button = Button(background_normal="assets/logo.png")
self.button.bind(on_press=self.callback)
self.current_state = "default"
self.add_widget(self.button)
# Check for active window changes every 0.5 seconds
self.prev_active_window_position = None
self._active_window_checker = Clock.schedule_interval(
Clock.schedule_interval(
self.position_above_active_window, 0.5
)

Expand Down Expand Up @@ -67,32 +68,26 @@ def callback(self, instance):
self.resume_replay()

def start_recording(self):
self.PROC = Popen(
self.record_proc = Popen(
"python -m openadapt.record " + "test",
shell=True,
)

def stop_recording(self):
try:
self.PROC.send_signal(signal.CTRL_C_EVENT)
# Wait for process to terminate
self.PROC.wait()
except KeyboardInterrupt:
# Catch the KeyboardInterrupt exception to prevent termination
pass
self.PROC = None
self.record_proc.send_signal(signal.CTRL_C_EVENT)
self.record_proc.wait()

def replay_recording(self):
self.PROC = Popen(
self.replay_proc = Popen(
"python -m openadapt.replay " + "NaiveReplayStrategy",
shell=True,
)

def pause_replay(self):
self.PROC.send_signal(signal.SIGSTOP)
self.replay_proc.send_signal(signal.SIGSTOP)

def resume_replay(self):
self.PROC.send_signal(signal.SIGCONT)
self.replay_proc.send_signal(signal.SIGCONT)


class OpenAdapt(App):
Expand Down

0 comments on commit ecf0e65

Please sign in to comment.