From 6cd34139f3219a10b0db6c7e67dd0af6be6bf388 Mon Sep 17 00:00:00 2001 From: Sharkitty Date: Fri, 8 Mar 2024 17:06:13 -0500 Subject: [PATCH 1/6] Bugfix: Newly downloaded workfile --- .../hooks/pre_set_workfile_publish_time.py | 20 +++++++++++++++++++ .../set_workfile_publish_time.py | 13 ++++++++++++ .../pre_copy_last_published_workfile.py | 3 +++ 3 files changed, 36 insertions(+) create mode 100644 openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py create mode 100644 openpype/hosts/blender/utility_scripts/set_workfile_publish_time.py diff --git a/openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py b/openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py new file mode 100644 index 00000000000..dee80cce7e8 --- /dev/null +++ b/openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py @@ -0,0 +1,20 @@ +from pathlib import Path + +from openpype.lib import PreLaunchHook +from openpype.hosts.blender import utility_scripts + + +class PreSetWorkfilePublishTime(PreLaunchHook): + + def execute(self): + if self.data.get("set_workfile_publish_time"): + # Add `set_workfile_publish_time` script to launch arguments + self.launch_context.launch_args.insert( + self.launch_context.launch_args.index("-P"), + [ + "-P", + Path(utility_scripts.__file__).parent.joinpath( + "set_workfile_publish_time.py" + ).as_posix(), + ], + ) diff --git a/openpype/hosts/blender/utility_scripts/set_workfile_publish_time.py b/openpype/hosts/blender/utility_scripts/set_workfile_publish_time.py new file mode 100644 index 00000000000..f7d173c1d06 --- /dev/null +++ b/openpype/hosts/blender/utility_scripts/set_workfile_publish_time.py @@ -0,0 +1,13 @@ +import bpy + +from openpype.lib.log import Logger +from openpype.lib.dateutils import get_timestamp + +if __name__ == "__main__": + log = Logger().get_logger() + log.debug("Setting workfile last publish time") + + # Set last publish time to current time + # This script assumes it is only executed in a known up to date workfile + # TODO Use UTC time instead of local time + bpy.context.scene["op_published_time"] = get_timestamp() diff --git a/openpype/modules/sync_server/launch_hooks/pre_copy_last_published_workfile.py b/openpype/modules/sync_server/launch_hooks/pre_copy_last_published_workfile.py index 4242fc98888..8af9bc6f8fd 100644 --- a/openpype/modules/sync_server/launch_hooks/pre_copy_last_published_workfile.py +++ b/openpype/modules/sync_server/launch_hooks/pre_copy_last_published_workfile.py @@ -184,3 +184,6 @@ def execute(self): self.data["last_workfile_path"] = local_workfile_path # Keep source filepath for further path conformation self.data["source_filepath"] = last_published_workfile_path + + if host_name == "blender": + self.data["set_workfile_publish_time"] = True From d513633b5483da65682aba5a283ae29652d26c64 Mon Sep 17 00:00:00 2001 From: Sharkitty <81646000+Sharkitty@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:59:41 +0000 Subject: [PATCH 2/6] Update openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add app group to set workfile publish time prelaunch hook Co-authored-by: Félix David --- openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py b/openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py index dee80cce7e8..b9a686f72c9 100644 --- a/openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py +++ b/openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py @@ -5,7 +5,9 @@ class PreSetWorkfilePublishTime(PreLaunchHook): - + app_groups = [ + "blender", + ] def execute(self): if self.data.get("set_workfile_publish_time"): # Add `set_workfile_publish_time` script to launch arguments From 4d5822ed81d88b40f468a82e3a2ef0eb2f53481b Mon Sep 17 00:00:00 2001 From: Sharkitty Date: Tue, 12 Mar 2024 09:14:27 -0400 Subject: [PATCH 3/6] renamed hook and util script, improved logging, use source_filepath --- ...blish_time.py => pre_set_current_time_to_workfile.py} | 9 +++++---- ...e_publish_time.py => set_current_time_to_workfile.py} | 6 ++++-- .../launch_hooks/pre_copy_last_published_workfile.py | 3 --- 3 files changed, 9 insertions(+), 9 deletions(-) rename openpype/hosts/blender/hooks/{pre_set_workfile_publish_time.py => pre_set_current_time_to_workfile.py} (84%) rename openpype/hosts/blender/utility_scripts/{set_workfile_publish_time.py => set_current_time_to_workfile.py} (66%) diff --git a/openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py b/openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py similarity index 84% rename from openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py rename to openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py index b9a686f72c9..04a0929ad71 100644 --- a/openpype/hosts/blender/hooks/pre_set_workfile_publish_time.py +++ b/openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py @@ -5,11 +5,12 @@ class PreSetWorkfilePublishTime(PreLaunchHook): - app_groups = [ - "blender", - ] + app_groups = [ + "blender", + ] + def execute(self): - if self.data.get("set_workfile_publish_time"): + if self.data.get("source_filepath"): # Add `set_workfile_publish_time` script to launch arguments self.launch_context.launch_args.insert( self.launch_context.launch_args.index("-P"), diff --git a/openpype/hosts/blender/utility_scripts/set_workfile_publish_time.py b/openpype/hosts/blender/utility_scripts/set_current_time_to_workfile.py similarity index 66% rename from openpype/hosts/blender/utility_scripts/set_workfile_publish_time.py rename to openpype/hosts/blender/utility_scripts/set_current_time_to_workfile.py index f7d173c1d06..b805294c2b8 100644 --- a/openpype/hosts/blender/utility_scripts/set_workfile_publish_time.py +++ b/openpype/hosts/blender/utility_scripts/set_current_time_to_workfile.py @@ -4,10 +4,12 @@ from openpype.lib.dateutils import get_timestamp if __name__ == "__main__": + current_time = get_timestamp() + log = Logger().get_logger() - log.debug("Setting workfile last publish time") + log.debug(f"Setting workfile last publish time to {current_time}") # Set last publish time to current time # This script assumes it is only executed in a known up to date workfile # TODO Use UTC time instead of local time - bpy.context.scene["op_published_time"] = get_timestamp() + bpy.context.scene["op_published_time"] = current_time diff --git a/openpype/modules/sync_server/launch_hooks/pre_copy_last_published_workfile.py b/openpype/modules/sync_server/launch_hooks/pre_copy_last_published_workfile.py index 8af9bc6f8fd..4242fc98888 100644 --- a/openpype/modules/sync_server/launch_hooks/pre_copy_last_published_workfile.py +++ b/openpype/modules/sync_server/launch_hooks/pre_copy_last_published_workfile.py @@ -184,6 +184,3 @@ def execute(self): self.data["last_workfile_path"] = local_workfile_path # Keep source filepath for further path conformation self.data["source_filepath"] = last_published_workfile_path - - if host_name == "blender": - self.data["set_workfile_publish_time"] = True From 16317b9a51e872e6569e59e9406e0512c1a412e7 Mon Sep 17 00:00:00 2001 From: Sharkitty Date: Tue, 12 Mar 2024 12:23:03 -0400 Subject: [PATCH 4/6] fix wrong script name --- .../hosts/blender/hooks/pre_set_current_time_to_workfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py b/openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py index 04a0929ad71..ea65e743c07 100644 --- a/openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py +++ b/openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py @@ -17,7 +17,7 @@ def execute(self): [ "-P", Path(utility_scripts.__file__).parent.joinpath( - "set_workfile_publish_time.py" + "set_current_time_to_workfile.py" ).as_posix(), ], ) From fda37e48f1693364ac15e74bdbde2ed82e929939 Mon Sep 17 00:00:00 2001 From: Sharkitty Date: Tue, 12 Mar 2024 12:29:10 -0400 Subject: [PATCH 5/6] remove TODO --- .../blender/utility_scripts/set_current_time_to_workfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openpype/hosts/blender/utility_scripts/set_current_time_to_workfile.py b/openpype/hosts/blender/utility_scripts/set_current_time_to_workfile.py index b805294c2b8..2293558234e 100644 --- a/openpype/hosts/blender/utility_scripts/set_current_time_to_workfile.py +++ b/openpype/hosts/blender/utility_scripts/set_current_time_to_workfile.py @@ -11,5 +11,4 @@ # Set last publish time to current time # This script assumes it is only executed in a known up to date workfile - # TODO Use UTC time instead of local time bpy.context.scene["op_published_time"] = current_time From 1a5617f3aa6675f53e88fd39ecefa9cbdbe1221e Mon Sep 17 00:00:00 2001 From: Sharkitty <81646000+Sharkitty@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:37:40 +0000 Subject: [PATCH 6/6] Update openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Félix David --- .../hosts/blender/hooks/pre_set_current_time_to_workfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py b/openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py index ea65e743c07..311623a3459 100644 --- a/openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py +++ b/openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py @@ -11,7 +11,7 @@ class PreSetWorkfilePublishTime(PreLaunchHook): def execute(self): if self.data.get("source_filepath"): - # Add `set_workfile_publish_time` script to launch arguments + # Add `set_current_time_to_workfile` script to launch arguments self.launch_context.launch_args.insert( self.launch_context.launch_args.index("-P"), [