It looks like you're new here. If you want to get involved, click one of these buttons!
Hi Matthias,
My script converts a GDS file into a proprietary format. The output file must go to stdout. However, layout.read() sometimes writes warnings to stdout (e.g. "Warning: Record length larger than 0x8000 encountered"), thus breaking the output file format. I need to redirect these warnings to stderr, but all my attempts with context_manager.redirect_stdout() failed. The only way to redirect seems to do this from the command-line (with > operator), but in this case, the output file is also redirected away from stdout, which is not what I want.
Can you think of a way to force klayout module functions to use stderr instead of stdout?
Thank you,
Mikhail
Comments
HI Mikhail,
the code to send warnings to stdout is in tlLog.cc, line 334++ (WarningChannel uses stdout).
Without recompiling you can't change this behaviour.
But beware: even if you manage to change this, Qt might still spit out warnings itself. These you can't redirect. I made this experience myself.
But how come you can only send your output to stdout? I think you can always substitute such a pipeline front end with the Linux sh equivalent of:
Matthias
Hi Matthias,
Thank you for, as usual, a prompt and helpful reply!
You are quite right, the stdout requirement is a bit weird, but it is not mine.
I have found a cunning way of "deep" stdout redirection using ctypes and context manager which did the trick for me:
https://www.programcreek.com/python/example/1108/ctypes.CDLL
Cheers,
Mikhail