From 180035731b329fe617460389bebdc995e79260ab Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 19 Aug 2020 21:10:51 +0200 Subject: [PATCH] Hound --- .../websocket_server/hosts/photoshop.py | 5 ++-- .../websocket_server/websocket_server.py | 2 +- pype/plugins/photoshop/load/load_image.py | 2 +- .../photoshop/publish/collect_current_file.py | 3 +- .../photoshop/publish/collect_instances.py | 7 +---- .../photoshop/publish/extract_image.py | 4 +-- .../photoshop/publish/extract_review.py | 28 ++----------------- .../photoshop/publish/extract_save_scene.py | 7 ++--- .../photoshop/publish/increment_workfile.py | 4 +-- .../publish/validate_instance_asset.py | 2 -- .../photoshop/publish/validate_naming.py | 3 +- 11 files changed, 17 insertions(+), 50 deletions(-) diff --git a/pype/modules/websocket_server/hosts/photoshop.py b/pype/modules/websocket_server/hosts/photoshop.py index 9092530e48..c63f66865e 100644 --- a/pype/modules/websocket_server/hosts/photoshop.py +++ b/pype/modules/websocket_server/hosts/photoshop.py @@ -1,5 +1,3 @@ -import asyncio - from pype.api import Logger from wsrpc_aiohttp import WebSocketRoute @@ -30,5 +28,6 @@ class Photoshop(WebSocketRoute): # client functions async def read(self): - log.debug("photoshop.read client calls server server calls Photo client") + log.debug("photoshop.read client calls server server calls " + "Photo client") return await self.socket.call('Photoshop.read') diff --git a/pype/modules/websocket_server/websocket_server.py b/pype/modules/websocket_server/websocket_server.py index 02fde4d56a..6b730d4eb3 100644 --- a/pype/modules/websocket_server/websocket_server.py +++ b/pype/modules/websocket_server/websocket_server.py @@ -105,7 +105,7 @@ class WebSocketServer(): @staticmethod def get_instance(): - if WebSocketServer._instance == None: + if WebSocketServer._instance is None: WebSocketServer() return WebSocketServer._instance diff --git a/pype/plugins/photoshop/load/load_image.py b/pype/plugins/photoshop/load/load_image.py index 0e437b15ba..a24280553c 100644 --- a/pype/plugins/photoshop/load/load_image.py +++ b/pype/plugins/photoshop/load/load_image.py @@ -1,7 +1,7 @@ from avalon import api, photoshop from pype.modules.websocket_server.clients.photoshop_client \ - import PhotoshopClientStub + import PhotoshopClientStub photoshopClient = PhotoshopClientStub() diff --git a/pype/plugins/photoshop/publish/collect_current_file.py b/pype/plugins/photoshop/publish/collect_current_file.py index bb81718bcc..604ce97f89 100644 --- a/pype/plugins/photoshop/publish/collect_current_file.py +++ b/pype/plugins/photoshop/publish/collect_current_file.py @@ -1,10 +1,9 @@ import os import pyblish.api -from avalon import photoshop from pype.modules.websocket_server.clients.photoshop_client import \ - PhotoshopClientStub + PhotoshopClientStub class CollectCurrentFile(pyblish.api.ContextPlugin): diff --git a/pype/plugins/photoshop/publish/collect_instances.py b/pype/plugins/photoshop/publish/collect_instances.py index f2d1c141fd..82a0c35311 100644 --- a/pype/plugins/photoshop/publish/collect_instances.py +++ b/pype/plugins/photoshop/publish/collect_instances.py @@ -1,11 +1,9 @@ import pythoncom -from avalon import photoshop - import pyblish.api from pype.modules.websocket_server.clients.photoshop_client \ - import PhotoshopClientStub + import PhotoshopClientStub class CollectInstances(pyblish.api.ContextPlugin): @@ -30,9 +28,6 @@ class CollectInstances(pyblish.api.ContextPlugin): # can be. pythoncom.CoInitialize() - from datetime import datetime - start = datetime.now() - # for timing photoshop_client = PhotoshopClientStub() layers = photoshop_client.get_layers() diff --git a/pype/plugins/photoshop/publish/extract_image.py b/pype/plugins/photoshop/publish/extract_image.py index 0451308ef1..4cbac38ce7 100644 --- a/pype/plugins/photoshop/publish/extract_image.py +++ b/pype/plugins/photoshop/publish/extract_image.py @@ -4,7 +4,8 @@ import pype.api from avalon import photoshop from pype.modules.websocket_server.clients.photoshop_client import \ - PhotoshopClientStub + PhotoshopClientStub + class ExtractImage(pype.api.Extractor): """Produce a flattened image file from instance @@ -65,7 +66,6 @@ class ExtractImage(pype.api.Extractor): extension, True) - representations = [] for extension, filename in files.items(): representations.append({ diff --git a/pype/plugins/photoshop/publish/extract_review.py b/pype/plugins/photoshop/publish/extract_review.py index 1c3aeaffb5..1e8d726720 100644 --- a/pype/plugins/photoshop/publish/extract_review.py +++ b/pype/plugins/photoshop/publish/extract_review.py @@ -4,9 +4,8 @@ import pype.api import pype.lib from avalon import photoshop -from datetime import datetime from pype.modules.websocket_server.clients.photoshop_client import \ - PhotoshopClientStub + PhotoshopClientStub class ExtractReview(pype.api.Extractor): @@ -17,7 +16,6 @@ class ExtractReview(pype.api.Extractor): families = ["review"] def process(self, instance): - start = datetime.now() staging_dir = self.staging_dir(instance) self.log.info("Outputting image to {}".format(staging_dir)) @@ -34,14 +32,10 @@ class ExtractReview(pype.api.Extractor): os.path.splitext(photoshop_client.get_active_document_name())[0] ) output_image_path = os.path.join(staging_dir, output_image) - self.log.info( - "first part took {}".format(datetime.now() - start)) with photoshop.maintained_visibility(): # Hide all other layers. - start = datetime.now() extract_ids = set([ll.id for ll in photoshop_client. - get_layers_in_layers(layers)]) - self.log.info("extract_ids {}".format(extract_ids)) + get_layers_in_layers(layers)]) for layer in photoshop_client.get_layers(): # limit unnecessary calls to client @@ -51,19 +45,11 @@ class ExtractReview(pype.api.Extractor): if not layer.visible and layer.id in extract_ids: photoshop_client.set_visible(layer.id, True) - self.log.info( - "get_layers_in_layers took {}".format(datetime.now() - start)) - start = datetime.now() - - self.log.info("output_image_path {}".format(output_image_path)) photoshop_client.saveAs(output_image_path, 'jpg', True) - self.log.info( - "saveAs {} took {}".format('JPG', datetime.now() - start)) - start = datetime.now() ffmpeg_path = pype.lib.get_ffmpeg_tool_path("ffmpeg") instance.data["representations"].append({ @@ -84,9 +70,6 @@ class ExtractReview(pype.api.Extractor): thumbnail_path ] output = pype.lib._subprocess(args) - self.log.info( - "thumbnail {} took {}".format('JPG', datetime.now() - start)) - self.log.debug(output) instance.data["representations"].append({ "name": "thumbnail", @@ -95,7 +78,6 @@ class ExtractReview(pype.api.Extractor): "stagingDir": staging_dir, "tags": ["thumbnail"] }) - start = datetime.now() # Generate mov. mov_path = os.path.join(staging_dir, "review.mov") args = [ @@ -106,10 +88,7 @@ class ExtractReview(pype.api.Extractor): mov_path ] output = pype.lib._subprocess(args) - self.log.info( - "review {} took {}".format('JPG', datetime.now() - start)) self.log.debug(output) - start = datetime.now() instance.data["representations"].append({ "name": "mov", "ext": "mov", @@ -126,6 +105,5 @@ class ExtractReview(pype.api.Extractor): instance.data["frameStart"] = 1 instance.data["frameEnd"] = 1 instance.data["fps"] = 25 - self.log.info( - "end {} took {}".format('JPG', datetime.now() - start)) + self.log.info(f"Extracted {instance} to {staging_dir}") diff --git a/pype/plugins/photoshop/publish/extract_save_scene.py b/pype/plugins/photoshop/publish/extract_save_scene.py index ea7bdda9af..3357a05f24 100644 --- a/pype/plugins/photoshop/publish/extract_save_scene.py +++ b/pype/plugins/photoshop/publish/extract_save_scene.py @@ -2,9 +2,9 @@ import pype.api from avalon import photoshop from pype.modules.websocket_server.clients.photoshop_client import \ - PhotoshopClientStub + PhotoshopClientStub + -from datetime import datetime class ExtractSaveScene(pype.api.Extractor): """Save scene before extraction.""" @@ -15,7 +15,4 @@ class ExtractSaveScene(pype.api.Extractor): def process(self, instance): photoshop_client = PhotoshopClientStub() - start = datetime.now() photoshop_client.save() - self.log.info( - "ExtractSaveScene took {}".format(datetime.now() - start)) diff --git a/pype/plugins/photoshop/publish/increment_workfile.py b/pype/plugins/photoshop/publish/increment_workfile.py index 0ae7e9772f..4298eb8e77 100644 --- a/pype/plugins/photoshop/publish/increment_workfile.py +++ b/pype/plugins/photoshop/publish/increment_workfile.py @@ -1,10 +1,10 @@ import pyblish.api from pype.action import get_errored_plugins_from_data from pype.lib import version_up -from avalon import photoshop from pype.modules.websocket_server.clients.photoshop_client import \ - PhotoshopClientStub + PhotoshopClientStub + class IncrementWorkfile(pyblish.api.InstancePlugin): """Increment the current workfile. diff --git a/pype/plugins/photoshop/publish/validate_instance_asset.py b/pype/plugins/photoshop/publish/validate_instance_asset.py index 6a0a408878..4bbea69eb4 100644 --- a/pype/plugins/photoshop/publish/validate_instance_asset.py +++ b/pype/plugins/photoshop/publish/validate_instance_asset.py @@ -27,8 +27,6 @@ class ValidateInstanceAssetRepair(pyblish.api.Action): instances = pyblish.api.instances_by_plugin(failed, plugin) photoshop_client = PhotoshopClientStub() for instance in instances: - self.log.info("validate_instance_asset instance[0] {}".format(instance[0])) - self.log.info("validate_instance_asset instance {}".format(instance)) data = photoshop_client.read(instance[0]) data["asset"] = os.environ["AVALON_ASSET"] diff --git a/pype/plugins/photoshop/publish/validate_naming.py b/pype/plugins/photoshop/publish/validate_naming.py index 7734a0e5a0..ba8a3e997e 100644 --- a/pype/plugins/photoshop/publish/validate_naming.py +++ b/pype/plugins/photoshop/publish/validate_naming.py @@ -3,7 +3,8 @@ import pype.api from avalon import photoshop from pype.modules.websocket_server.clients.photoshop_client import \ - PhotoshopClientStub + PhotoshopClientStub + class ValidateNamingRepair(pyblish.api.Action): """Repair the instance asset."""