That code creates a new message handler. You want to get the existing
message handler and change the settings. It's at openbabel.obErrorLog.

On Thu, 26 Aug 2021, 14:07 , <theoki...@fz-juelich.de> wrote:

>
> Hi,
>
> I want to use openbabel conversion in python like shown below.
> But I do not want to get an error message thrown like this,
> instead I can use the value of the success varible.
>
> > ./mwe.py
> ==============================
> *** Open Babel Error  in ParseSimple
>   SMILES string contains a character 'X' which is invalid
>
>
> I already tried to set the OutputLevel, but this is not working.
> Whant can I do?
>
> TIA.
>
> ----------------------------------------------------------------
> #!/usr/bin/env python3
> from openbabel import openbabel
>
> ob_log_handler = openbabel.OBMessageHandler()
> ob_log_handler.SetOutputLevel(0)
> openbabel.cvar.obErrorLog.SetOutputLevel(0)  # also tested this
>
> mol = openbabel.OBMol()
> obConversion = openbabel.OBConversion()
> obConversion.SetInAndOutFormats('smi', 'can')
> success = obConversion.ReadString(mol, 'X')
>
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to