#!/usr/bin/python3
import sys, time
from pathlib import Path
log=Path('/tmp/factory-issue-45720-evidence-1/pinentry.log')
with log.open('a') as f: f.write(time.strftime('%H:%M:%S')+' PINENTRY START\n')
print('OK',flush=True)
for line in sys.stdin:
 if line.startswith('SETDESC'):
  with log.open('a') as f: f.write(line)
 if line.startswith('GETPIN'): print('ERR 83886179 Operation cancelled',flush=True)
 elif line.startswith('BYE'): print('OK',flush=True); break
 else: print('OK',flush=True)
