Hi RDKit Community,

I'm trying to run a script in the command line without having any RDKit 
warnings or errors show up in the CL. Instead, I want them written into a 
log.txt



from rdkit import Chem
from contextlib import redirect_stderr

Chem.WrapLogs()

with open('log.txt', 'w') as f:
    with redirect_stderr(f):
        mol = Chem.MolFromSmiles("c1ccccc")



The error does indeed get written to the log.txt file (I'm assuming warnings 
would be too).

What is strange is that the stderr still shows up in the command line, even 
though I'd already redirected it to the log.txt.

Does this mean that there are two stderr streams? How is this possible?


I've been reading several old posts on this topic, but none really fits my 
problem:

https://sourceforge.net/p/rdkit/mailman/rdkit-discuss/thread/CAOC-GK0oTH36vvL7eVyWMJg4zmERpqctonrgNnxG10QmgYXhdg%40mail.gmail.com/#msg36030331

https://sourceforge.net/p/rdkit/mailman/message/33261506/  <- addressed by 
WrapLogs() I believe

<https://sourceforge.net/p/rdkit/mailman/rdkit-discuss/thread/CAOC-GK0oTH36vvL7eVyWMJg4zmERpqctonrgNnxG10QmgYXhdg%40mail.gmail.com/#msg36030331>http://rdkit.blogspot.com/2016/03/capturing-error-information.html

https://github.com/rdkit/rdkit/pull/739

Would appreciate any ideas.

Thanks,
Adelene


<https://github.com/rdkit/rdkit/pull/739>






Doctoral Researcher
Environmental Cheminformatics
UNIVERSITÉ DU LUXEMBOURG

Campus Belval | Luxembourg Centre for Systems Biomedicine
6, avenue du Swing, L-4367 Belvaux
T +356 46 66 44 67 18
https://adelenel.ai









_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to