forked from tatanus/apt2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyeventthread.py
More file actions
37 lines (33 loc) · 1.25 KB
/
Copy pathkeyeventthread.py
File metadata and controls
37 lines (33 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from threading import Thread
import sys
import select
# ----------------------------
# KeyEventThread CLASS
# ----------------------------
class KeyEventThread(Thread):
def __init__(self, pDisplay):
Thread.__init__(self)
self.end = False
self.paused = False
self.display = pDisplay
def run(self):
self.display.alert("Use the following controls while scans are running:")
self.display.alert("- p - pause/resume event queueing")
#detect key presses
while not self.end:
#run until end is True
# TODO - This is Linux only, need to find fallback for windows, maybe msvctl.getch
i, o, e = select.select( [sys.stdin], [], [], 1 )
if i:
ch = sys.stdin.read(1)
if ch == 'p':
if self.paused:
self.display.alert("Queue is unpaused, progress will resume")
self.paused = False
else:
self.display.alert("Queue is paused, new events will not be loaded but current threads will continue")
self.paused = True
def stop(self):
self.end = True
def isPaused(self):
return self.paused