mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
add headless abstraction into command.py
This commit is contained in:
parent
5c399cbc17
commit
22ee8e1f93
3 changed files with 12 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue