On Wed, Mar 25, 2015 at 5:20 PM, Modeller Caretaker modeller-care@salilab.org wrote: > On 3/25/15 8:14 AM, David Menéndez Hurtado wrote: >> I have also tried to redirect stdout to /dev/null from Python while >> Modeller runs, without effect, so I guess this must be coming from a >> compiled printf. > > > I have no idea what a "compiled printf" is, but all Modeller output is > routed to Python's sys.stdout, so you can definitely redirect that in Python > (or even do something fancy, like reassign it to some other filelike object, > like a StringIO) or from the command line (e.g. with the > operator). So I'm > not sure what you're doing here.
Indeed, you are right. I was redirecting the output using:
_stdout = sys.stdout sys.stdout = open(os.devnull, 'w') [run modeller] sys.stdout.close() sys.stdout = _stdout
But somewhere along the road I made a mistake, and it was still showing up; so I assumed the output came from a compiled extension, that cannot be redirected. Sorry about that.
In case this is helpful for anyone else, here is my final solution. ContactModel inherits from and replaces automodel because I am adding some restraints. Now make() is completely silent.
class ShutUp(object): def __enter__(self): self._stdout = sys.stdout sys.stdout = open(os.devnull, 'w')
def __exit__(self, *args): sys.stdout.close() sys.stdout = self._stdout
class ContactModel(modeller.automodel.automodel): [...] def make(self): with ShutUp(): super(ContactModel, self).make()
/David.