def decrypt_to_fifo(_input, _output, _mode, _force, text=None):
def write_to_fifo(notifier):
st = os.stat(_output)
if not stat.S_ISFIFO(st.st_mode):
raise click.ClickException('%s is not a FIFO!' % _output)
if (st.st_mode & 0o777 != _mode):
raise click.ClickException('mode has changed on %s!' % _output)
if _input != '-':
f_in = open(_input, 'rb')
text = f_in.read()
f_in.close()
try:
f = open(_output, 'w')
text = decrypt_string(text)
f.write(text)
f.close()
except IOError:
pass
finally:
text = str(0x00) * len(text)
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm, pyinotify.ProcessEvent)
wm.add_watch(_output, pyinotify.IN_CLOSE_NOWRITE)
notifier.loop(callback=write_to_fifo)
评论列表
文章目录