add headless abstraction into command.py

This commit is contained in:
Kayla Man 2023-06-23 00:10:34 +08:00
parent 5c399cbc17
commit 22ee8e1f93
3 changed files with 12 additions and 11 deletions

View file

@ -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):