diff --git a/openpype/hosts/nuke/api/command.py b/openpype/hosts/nuke/api/command.py index 2f772469d8..2e2c5b2b93 100644 --- a/openpype/hosts/nuke/api/command.py +++ b/openpype/hosts/nuke/api/command.py @@ -2,6 +2,8 @@ import logging import contextlib import nuke +from qtpy import QtWidgets + log = logging.getLogger(__name__) @@ -19,3 +21,11 @@ def viewer_update_and_undo_stop(): yield finally: nuke.Undo.enable() + + +def is_headless(): + """ + Returns: + bool: headless + """ + return QtWidgets.QApplication.instance() is None diff --git a/openpype/hosts/nuke/api/lib.py b/openpype/hosts/nuke/api/lib.py index 4a254f7c2f..e3b34222d4 100644 --- a/openpype/hosts/nuke/api/lib.py +++ b/openpype/hosts/nuke/api/lib.py @@ -3155,11 +3155,3 @@ def get_viewer_config_from_string(input_string): ).format(input_string)) return (display, viewer) - - -def is_headless(): - """ - Returns: - bool: headless - """ - return QtWidgets.QApplication.instance() is None diff --git a/openpype/hosts/nuke/api/workio.py b/openpype/hosts/nuke/api/workio.py index 032a9fdda8..b7c9d01097 100644 --- a/openpype/hosts/nuke/api/workio.py +++ b/openpype/hosts/nuke/api/workio.py @@ -1,7 +1,7 @@ """Host API required Work Files tool""" import os import nuke -from qtpy import QtWidgets +from .command import is_headless def file_extensions(): @@ -26,8 +26,7 @@ def open_file(filepath): # To remain in the same window, we have to clear the script and read # in the contents of the workfile. nuke.scriptClear() - headless = QtWidgets.QApplication.instance() is None - if not headless: + if not is_headless(): autosave = nuke.toNode("preferences")["AutoSaveName"].evaluate() autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa if os.path.isfile(autosave) and nuke.ask(autosave_prmpt):