From 3e02ea62632627e1ced226e0ffbceba7f19aafc6 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 7 Jun 2023 15:30:59 +0800 Subject: [PATCH 01/13] autosave nk script will be loaded if the script is found in the work directory --- openpype/hosts/nuke/api/workio.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/nuke/api/workio.py b/openpype/hosts/nuke/api/workio.py index 5692f8e63c..50e22391b2 100644 --- a/openpype/hosts/nuke/api/workio.py +++ b/openpype/hosts/nuke/api/workio.py @@ -25,7 +25,13 @@ 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() - nuke.scriptReadFile(filepath) + autosave = f"{filepath}.autosave" + autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa + if os.path.isfile(autosave) and nuke.ask(autosave_prmpt): + filepath = autosave + nuke.scriptReadFile(filepath) + else: + nuke.scriptReadFile(filepath) nuke.Root()["name"].setValue(filepath) nuke.Root()["project_directory"].setValue(os.path.dirname(filepath)) nuke.Root().setModified(False) From 8c5b9321e4c29b7d11245eea0315447279ac83ab Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 7 Jun 2023 18:24:05 +0800 Subject: [PATCH 02/13] Jakub's comment --- openpype/hosts/nuke/api/workio.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/nuke/api/workio.py b/openpype/hosts/nuke/api/workio.py index 50e22391b2..99e95dbd77 100644 --- a/openpype/hosts/nuke/api/workio.py +++ b/openpype/hosts/nuke/api/workio.py @@ -25,13 +25,12 @@ 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() - autosave = f"{filepath}.autosave" + autosave = "{}.autosave".format(filepath) autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa if os.path.isfile(autosave) and nuke.ask(autosave_prmpt): filepath = autosave - nuke.scriptReadFile(filepath) - else: - nuke.scriptReadFile(filepath) + + nuke.scriptReadFile(filepath) nuke.Root()["name"].setValue(filepath) nuke.Root()["project_directory"].setValue(os.path.dirname(filepath)) nuke.Root().setModified(False) From 47b2a38cd4d97ae1d0eaf5dfcc9399952a8bafff Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 8 Jun 2023 17:06:37 +0800 Subject: [PATCH 03/13] add allow_autosave argument as kwargs in open_file function in nuke --- openpype/hosts/nuke/api/workio.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/nuke/api/workio.py b/openpype/hosts/nuke/api/workio.py index 99e95dbd77..d674e3ba4d 100644 --- a/openpype/hosts/nuke/api/workio.py +++ b/openpype/hosts/nuke/api/workio.py @@ -19,16 +19,17 @@ def save_file(filepath): nuke.Root().setModified(False) -def open_file(filepath): +def open_file(filepath, allow_autosave=True): filepath = filepath.replace("\\", "/") # To remain in the same window, we have to clear the script and read # in the contents of the workfile. nuke.scriptClear() - autosave = "{}.autosave".format(filepath) - autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa - if os.path.isfile(autosave) and nuke.ask(autosave_prmpt): - filepath = autosave + if allow_autosave: + autosave = "{}.autosave".format(filepath) + autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa + if os.path.isfile(autosave) and nuke.ask(autosave_prmpt): + filepath = autosave nuke.scriptReadFile(filepath) nuke.Root()["name"].setValue(filepath) From 82d18355c8342ea923db368129fbdae0e7a90136 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 8 Jun 2023 21:15:30 +0800 Subject: [PATCH 04/13] Jakub's comment --- openpype/hosts/nuke/api/workio.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/nuke/api/workio.py b/openpype/hosts/nuke/api/workio.py index d674e3ba4d..88d555cbb8 100644 --- a/openpype/hosts/nuke/api/workio.py +++ b/openpype/hosts/nuke/api/workio.py @@ -1,6 +1,7 @@ """Host API required Work Files tool""" import os import nuke +from qtpy import QtWidgets def file_extensions(): @@ -19,13 +20,14 @@ def save_file(filepath): nuke.Root().setModified(False) -def open_file(filepath, allow_autosave=True): +def open_file(filepath): filepath = filepath.replace("\\", "/") # To remain in the same window, we have to clear the script and read # in the contents of the workfile. nuke.scriptClear() - if allow_autosave: + headless = QtWidgets.QApplication.instance() is None + if not headless: autosave = "{}.autosave".format(filepath) autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa if os.path.isfile(autosave) and nuke.ask(autosave_prmpt): From b150e0b6a166c495eb21503ddddb82900df94478 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 13 Jun 2023 21:31:45 +0800 Subject: [PATCH 05/13] jiri's comment --- openpype/hosts/nuke/api/workio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/nuke/api/workio.py b/openpype/hosts/nuke/api/workio.py index 88d555cbb8..032a9fdda8 100644 --- a/openpype/hosts/nuke/api/workio.py +++ b/openpype/hosts/nuke/api/workio.py @@ -28,7 +28,7 @@ def open_file(filepath): nuke.scriptClear() headless = QtWidgets.QApplication.instance() is None if not headless: - autosave = "{}.autosave".format(filepath) + 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): filepath = autosave From 56a90a47f544e5c71e5edefd83d4d224773f08a7 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 22 Jun 2023 19:02:18 +0800 Subject: [PATCH 06/13] abstract the headless command as function in lib.py --- openpype/hosts/nuke/api/lib.py | 9 +++++++++ openpype/hosts/nuke/api/workio.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/nuke/api/lib.py b/openpype/hosts/nuke/api/lib.py index 4a57bc3165..c469612954 100644 --- a/openpype/hosts/nuke/api/lib.py +++ b/openpype/hosts/nuke/api/lib.py @@ -3116,3 +3116,12 @@ def get_viewer_config_from_string(input_string): ).format(input_string)) return (display, viewer) + + +def is_headless(): + """ + Returns: + bool: headless + """ + headless = QtWidgets.QApplication.instance() is None + return headless diff --git a/openpype/hosts/nuke/api/workio.py b/openpype/hosts/nuke/api/workio.py index 032a9fdda8..8b5bae3b2c 100644 --- a/openpype/hosts/nuke/api/workio.py +++ b/openpype/hosts/nuke/api/workio.py @@ -2,6 +2,7 @@ import os import nuke from qtpy import QtWidgets +from openpype.hosts.nuke.api.lib import is_headless def file_extensions(): @@ -26,7 +27,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 + headless = is_headless() if not headless: autosave = nuke.toNode("preferences")["AutoSaveName"].evaluate() autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa From d9af1d91670bfdd2747a81feeb251bf0566b7762 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 22 Jun 2023 19:03:29 +0800 Subject: [PATCH 07/13] remove unused library --- openpype/hosts/nuke/api/workio.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openpype/hosts/nuke/api/workio.py b/openpype/hosts/nuke/api/workio.py index 8b5bae3b2c..12f069a386 100644 --- a/openpype/hosts/nuke/api/workio.py +++ b/openpype/hosts/nuke/api/workio.py @@ -1,7 +1,6 @@ """Host API required Work Files tool""" import os import nuke -from qtpy import QtWidgets from openpype.hosts.nuke.api.lib import is_headless From 31f76563b8cdc3c49344d702e3c4ea2bfd64aa83 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 22 Jun 2023 21:51:58 +0800 Subject: [PATCH 08/13] jakub's comment --- openpype/hosts/nuke/api/lib.py | 3 +-- openpype/hosts/nuke/api/workio.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/nuke/api/lib.py b/openpype/hosts/nuke/api/lib.py index 1251e1a718..4a254f7c2f 100644 --- a/openpype/hosts/nuke/api/lib.py +++ b/openpype/hosts/nuke/api/lib.py @@ -3162,5 +3162,4 @@ def is_headless(): Returns: bool: headless """ - headless = QtWidgets.QApplication.instance() is None - return headless + return QtWidgets.QApplication.instance() is None diff --git a/openpype/hosts/nuke/api/workio.py b/openpype/hosts/nuke/api/workio.py index 12f069a386..4ec0766599 100644 --- a/openpype/hosts/nuke/api/workio.py +++ b/openpype/hosts/nuke/api/workio.py @@ -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 = is_headless() - 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): From 5c399cbc1781428f099e43ee648fedbc81b2773e Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 22 Jun 2023 23:13:24 +0800 Subject: [PATCH 09/13] revert the headless function --- openpype/hosts/nuke/api/workio.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/nuke/api/workio.py b/openpype/hosts/nuke/api/workio.py index 4ec0766599..032a9fdda8 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 openpype.hosts.nuke.api.lib import is_headless +from qtpy import QtWidgets def file_extensions(): @@ -26,7 +26,8 @@ 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() - if not is_headless(): + headless = QtWidgets.QApplication.instance() is None + if not 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): From 22ee8e1f9337b71b6939b6f490ba9cf13cf92701 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 23 Jun 2023 00:10:34 +0800 Subject: [PATCH 10/13] add headless abstraction into command.py --- openpype/hosts/nuke/api/command.py | 10 ++++++++++ openpype/hosts/nuke/api/lib.py | 8 -------- openpype/hosts/nuke/api/workio.py | 5 ++--- 3 files changed, 12 insertions(+), 11 deletions(-) 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): From c414c8c6e933e82e6e7703b8e509b711e36f9d2e Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 23 Jun 2023 16:45:41 +0800 Subject: [PATCH 11/13] add scripts to utils --- openpype/hosts/nuke/api/command.py | 9 --------- openpype/hosts/nuke/api/utils.py | 11 ++++++++++- openpype/hosts/nuke/api/workio.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openpype/hosts/nuke/api/command.py b/openpype/hosts/nuke/api/command.py index 2e2c5b2b93..486f637a55 100644 --- a/openpype/hosts/nuke/api/command.py +++ b/openpype/hosts/nuke/api/command.py @@ -2,7 +2,6 @@ import logging import contextlib import nuke -from qtpy import QtWidgets log = logging.getLogger(__name__) @@ -21,11 +20,3 @@ 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/utils.py b/openpype/hosts/nuke/api/utils.py index 2b3c35c23a..7b02585892 100644 --- a/openpype/hosts/nuke/api/utils.py +++ b/openpype/hosts/nuke/api/utils.py @@ -2,7 +2,7 @@ import os import nuke from openpype import resources -from .lib import maintained_selection +from qtpy import QtWidgets def set_context_favorites(favorites=None): @@ -55,6 +55,7 @@ def bake_gizmos_recursively(in_group=None): Arguments: is_group (nuke.Node)[optonal]: group node or all nodes """ + from .lib import maintained_selection if in_group is None: in_group = nuke.Root() # preserve selection after all is done @@ -129,3 +130,11 @@ def get_colorspace_list(colorspace_knob): reduced_clrs.append(clrs) return reduced_clrs + + +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 b7c9d01097..8d29e0441f 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 .command import is_headless +from .utils import is_headless def file_extensions(): From cbf21cf95d0876508f2ea77992b66f405b9fbf19 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 23 Jun 2023 18:00:15 +0800 Subject: [PATCH 12/13] update --- openpype/hosts/nuke/api/command.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openpype/hosts/nuke/api/command.py b/openpype/hosts/nuke/api/command.py index 486f637a55..2f772469d8 100644 --- a/openpype/hosts/nuke/api/command.py +++ b/openpype/hosts/nuke/api/command.py @@ -2,7 +2,6 @@ import logging import contextlib import nuke - log = logging.getLogger(__name__) From 6f7f633e868b33d01c7aff84f61653d09f74195c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 24 Jun 2023 03:31:59 +0000 Subject: [PATCH 13/13] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 203ac1df23..2f185a3f87 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to OpenPype Tray options: + - 3.15.11-nightly.5 - 3.15.11-nightly.4 - 3.15.11-nightly.3 - 3.15.11-nightly.2 @@ -134,7 +135,6 @@ body: - 3.14.4-nightly.1 - 3.14.3 - 3.14.3-nightly.7 - - 3.14.3-nightly.6 validations: required: true - type: dropdown