python test to check if the Editor is running in Commandlet mode (UE4Editor-Cmd.exe)

I set up an init_unreal.py to change my font size. It works fine, except sometimes I run .bat files, and they hang on the init_unreal.py, because there are no widgets to scale, I think. How can I add an if test to check if I"m running with a UI or without? I think it needs to happen in the python, because I put a test in the C++ and I don’t think it gets reached before the li’l crash that happens.

I put the command in ini_unreal.py in a try/except block. Done.

try/except block did not work.