Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, writer, path, metadata, append=False):
async_worker.__init__(self)
self.writer = writer
self.path = path
self.metadata = metadata
self.append = append
def write_stdout(self, ts, data):
self.enqueue([ts, 'o', data])
def run(self):
with self.writer(self.path, metadata=self.metadata, append=self.append) as w:
for event in iter(self.queue.get, None):
ts, etype, data = event
if etype == 'o':
w.write_stdout(ts, data)
elif etype == 'i':
w.write_stdin(ts, data)
class async_notifier(async_worker):
def __init__(self):
async_worker.__init__(self)
self.notifier = notifier.get_notifier()
def notify(self, text):
self.enqueue(text)
def perform(self, text):
try:
self.notifier.notify(text)
except:
# we catch *ALL* exceptions here because we don't want failed
# notification to crash the recording session
pass
def __init__(self):
async_worker.__init__(self)
self.notifier = notifier.get_notifier()
if append and os.stat(path).st_size > 0:
time_offset = v2.get_duration(path)
with async_writer(writer, path, full_metadata, append) as w:
with async_notifier() as n:
record(
['sh', '-c', command],
w,
command_env,
rec_stdin,
time_offset,
n
)
class async_writer(async_worker):
def __init__(self, writer, path, metadata, append=False):
async_worker.__init__(self)
self.writer = writer
self.path = path
self.metadata = metadata
self.append = append
def write_stdin(self, ts, data):
self.enqueue([ts, 'i', data])
def write_stdout(self, ts, data):
self.enqueue([ts, 'o', data])
def run(self):
with self.writer(self.path, metadata=self.metadata, append=self.append) as w:
for event in iter(self.queue.get, None):