Hi Antonio, You can suppress this message with:
cmd.feedback("disable", "scene", "actions") Cheers, Thomas > On Nov 20, 2020, at 10:23 PM, Antonio Serrano <aserra...@ucam.edu> wrote: > > ############## CONTEXT ############## > Running PyMol 2.4 on Ubuntu 20.04.1 LTS. > > I'm launching the PyMol's GUI from a Python script executed from the shell > like this: > > python my_script.py > > A virtual environment is activated. This venv takes PyMol's Python > interpreter from ~/pymol/bin/. I import the pymol module inside the script > following these instructions > (https://pymolwiki.org/index.php/Launching_From_a_Script): > > import pymol > pymol.finish_launching(['pymol']) > > ############## THE ISSUE ############## > My program continuously writes PNG images within a loop with the following > command: > > cmd.png("./my_image", width=84, height=84, dpi=-1.0, ray=0, quiet=1) > > When turning the parameter quiet=1 it's supposed to work quietly. But it > keeps printing the following message in the stdout over and over again each > time it writes an image on disk inside the loop: > > ScenePNG: wrote 84x84 pixel image to file "./my_image.png". > > My program is also printing some debugging information, so this unnecessary > message is quite annoying and spoils my output. > > I also tried to disable it with the following command line option when > importing the pymol library in the script (seen in > https://pymolwiki.org/index.php/Command_Line_Options): > > import pymol > pymol.finish_launching(['pymol', '-Q']) > > But it doesn't work either. If I was running the program without GUI, I could > try to redirect the stdout to “nothing” with some of these clever tricks > (https://stackoverflow.com/questions/6735917/redirecting-stdout-to-nothing-in-python). > For example, using the following function: > > @contextmanager > def stdout_redirected(to=os.devnull): > fd = sys.stdout.fileno() > > def _redirect_stdout(to): > sys.stdout.close() > os.dup2(to.fileno(), fd) > sys.stdout = os.fdopen(fd, 'w') > > with os.fdopen(os.dup(fd), 'w') as old_stdout: > with open(to, 'w') as file: > _redirect_stdout(to=file) > try: > yield > finally: > _redirect_stdout(to=old_stdout) > > And then do this: > with stdout_redirected(): > cmd.png("./my_image", width=84, height=84, dpi=-1.0, ray=0, > quiet=1) > > This trick worked for me in the past. But since I need the GUI now, I get the > following error: > Traceback (most recent call last): > File "mvdqn_train.py", line 525, in <module> > main() > File "mvdqn_train.py", line 386, in main > env = gym.make("docking-v0", kwargs=env_args) > File > "/home/aserrano/pymol/lib/python3.7/site-packages/gym/envs/registration.py", > line 145, in make > return registry.make(id, **kwargs) > File > "/home/aserrano/pymol/lib/python3.7/site-packages/gym/envs/registration.py", > line 90, in make > env = spec.make(**kwargs) > File > "/home/aserrano/pymol/lib/python3.7/site-packages/gym/envs/registration.py", > line 60, in make > env = cls(**_kwargs) > File > "/home/aserrano/projects/mvdqn/gym-docking-vis/gym_docking_vis/envs/docking_env.py", > line 128, in __init__ > self.initial_state = generate_images(None, self.views, self.num_views, > self.input_height, self.input_width, self.n_channels) > File > "/home/aserrano/projects/mvdqn/gym-docking-vis/gym_docking_vis/envs/utils_env.py", > line 636, in generate_images > with stdout_redirected(): > File "/home/aserrano/pymol/lib/python3.7/contextlib.py", line 112, in > __enter__ > return next(self.gen) > File > "/home/aserrano/projects/mvdqn/gym-docking-vis/gym_docking_vis/envs/utils_env.py", > line 682, in stdout_redirected > fd = sys.stdout.fileno() > AttributeError: module 'pcatch' has no attribute 'fileno' > > Any clue to solve this issue? Thx. > > Cheers, > Antonio > > > "Este mensaje es privado y confidencial y se dirige exclusivamente a su > destinatario. Si usted recibe este mensaje por error, no debe revelar, > distribuir o copiar este e-mail. Por favor, comuníquelo al remitente y borre > el mensaje y los archivos adjuntos de su sistema. No hay renuncia a la > confidencialidad ni a ningún privilegio a causa de una transmisión errónea o > por mal funcionamiento". > > "This message is private and confidential and it is intended exclusively for > the addressee. If your receive this message by mistake, you should not > disseminate, distribute or copy this e-mail. Please inform the sender and > delete the message and attachments from your system. No confidentiality or > any privilege regarding the information is waived or lost by any > mistransmission or malfunction". > > No me imprimas si no es necesario. > Don't print me unless it's necessary. > > _______________________________________________ > PyMOL-users mailing list > Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net > Unsubscribe: > https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe -- Thomas Holder PyMOL Principal Developer Schrödinger, Inc. _______________________________________________ PyMOL-users mailing list Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net Unsubscribe: https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe