ayon-core/openpype/hosts/nuke/api/command.py
2023-06-23 00:10:34 +08:00

31 lines
655 B
Python

import logging
import contextlib
import nuke
from qtpy import QtWidgets
log = logging.getLogger(__name__)
@contextlib.contextmanager
def viewer_update_and_undo_stop():
"""Lock viewer from updating and stop recording undo steps"""
try:
# stop active viewer to update any change
viewer = nuke.activeViewer()
if viewer:
viewer.stop()
else:
log.warning("No available active Viewer")
nuke.Undo.disable()
yield
finally:
nuke.Undo.enable()
def is_headless():
"""
Returns:
bool: headless
"""
return QtWidgets.QApplication.instance() is None