+ # Pipe messsages through fribidi
+ if params.get('bidi_workaround', False):
+ # fribidi does not support ungetting, so force newlines
+ params['progress_with_newline'] = True
+
+ for fid in ['_screen_file', '_err_file']:
+ class FribidiOut(object):
+ def __init__(self, outfile, errfile):
+ self.outfile = outfile
+ self.process = subprocess.Popen(
+ ['fribidi'],
+ stdin=subprocess.PIPE,
+ stdout=outfile,
+ stderr=errfile)
+
+ def write(self, s):
+ res = self.process.stdin.write(s)
+ self.flush()
+ return res
+
+ def flush(self):
+ return self.process.stdin.flush()
+
+ def isatty(self):
+ return self.outfile.isatty()
+
+ try:
+ vout = FribidiOut(getattr(self, fid), self._err_file)
+ setattr(self, fid, vout)
+ except OSError as ose:
+ if ose.errno == 2:
+ self.report_warning(u'Could not find fribidi executable, ignoring --bidi-workaround . Make sure that fribidi is an executable file in one of the directories in your $PATH.')
+ break
+ else:
+ raise
+