I'm using the top answer from this question to print my output to colour, but when running on HPC this kind of output isn't supported. The suggested workaround seems to be to use sys.stdout.isatty()
to determine where the output is being directed and remove the unicode colouring.
However when I run my code in parallel (with $ mpirun -n 2 python foo.py > output.txt
) it no longer returns the expected bool (i.e. it returns True when in serial it returned False). Even if I do a mpi rank check before it eg:
if MPI.COMM_WORLD.Get_rank() == 0: print sys.stdout.isatty()
Am I misunderstanding the way this function is supposed to work and/or is there an alternate way to determine the direction of the output when running in parallel?
Thanks for your time.