From bcd81fa934bcf13ca5861f212cb6871fa439e78a Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Tue, 23 Jun 2020 12:52:35 +0100 Subject: [PATCH 01/16] Implemented 'camera' asset for Blender --- pype/plugins/blender/create/create_camera.py | 32 +++ pype/plugins/blender/load/load_camera.py | 241 ++++++++++++++++++ pype/plugins/blender/publish/extract_blend.py | 2 +- 3 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 pype/plugins/blender/create/create_camera.py create mode 100644 pype/plugins/blender/load/load_camera.py diff --git a/pype/plugins/blender/create/create_camera.py b/pype/plugins/blender/create/create_camera.py new file mode 100644 index 0000000000..5817985053 --- /dev/null +++ b/pype/plugins/blender/create/create_camera.py @@ -0,0 +1,32 @@ +"""Create a camera asset.""" + +import bpy + +from avalon import api +from avalon.blender import Creator, lib +import pype.hosts.blender.plugin + + +class CreateCamera(Creator): + """Polygonal static geometry""" + + name = "cameraMain" + label = "Camera" + family = "camera" + icon = "video-camera" + + def process(self): + + asset = self.data["asset"] + subset = self.data["subset"] + name = pype.hosts.blender.plugin.asset_name(asset, subset) + collection = bpy.data.collections.new(name=name) + bpy.context.scene.collection.children.link(collection) + self.data['task'] = api.Session.get('AVALON_TASK') + lib.imprint(collection, self.data) + + if (self.options or {}).get("useSelection"): + for obj in lib.get_selection(): + collection.objects.link(obj) + + return collection diff --git a/pype/plugins/blender/load/load_camera.py b/pype/plugins/blender/load/load_camera.py new file mode 100644 index 0000000000..a69c01e806 --- /dev/null +++ b/pype/plugins/blender/load/load_camera.py @@ -0,0 +1,241 @@ +"""Load a camera asset in Blender.""" + +import logging +from pathlib import Path +from pprint import pformat +from typing import Dict, List, Optional + +from avalon import api, blender +import bpy +import pype.hosts.blender.plugin + +logger = logging.getLogger("pype").getChild("blender").getChild("load_camera") + + +class BlendCameraLoader(pype.hosts.blender.plugin.AssetLoader): + """Load a camera from a .blend file. + + Warning: + Loading the same asset more then once is not properly supported at the + moment. + """ + + families = ["camera"] + representations = ["blend"] + + label = "Link Camera" + icon = "code-fork" + color = "orange" + + def _remove(self, objects, lib_container): + + for obj in objects: + bpy.data.cameras.remove(obj.data) + + bpy.data.collections.remove(bpy.data.collections[lib_container]) + + def _process(self, libpath, lib_container, container_name, actions): + + relative = bpy.context.preferences.filepaths.use_relative_paths + with bpy.data.libraries.load( + libpath, link=True, relative=relative + ) as (_, data_to): + data_to.collections = [lib_container] + + scene = bpy.context.scene + + scene.collection.children.link(bpy.data.collections[lib_container]) + + camera_container = scene.collection.children[lib_container].make_local() + + objects_list = [] + + for obj in camera_container.objects: + obj = obj.make_local() + obj.data.make_local() + + if not obj.get(blender.pipeline.AVALON_PROPERTY): + obj[blender.pipeline.AVALON_PROPERTY] = dict() + + avalon_info = obj[blender.pipeline.AVALON_PROPERTY] + avalon_info.update({"container_name": container_name}) + + + + if actions[0] is not None: + if obj.animation_data is None: + obj.animation_data_create() + obj.animation_data.action = actions[0] + + if actions[1] is not None: + if obj.data.animation_data is None: + obj.data.animation_data_create() + obj.data.animation_data.action = actions[1] + + objects_list.append(obj) + + camera_container.pop(blender.pipeline.AVALON_PROPERTY) + + bpy.ops.object.select_all(action='DESELECT') + + return objects_list + + def process_asset( + self, context: dict, name: str, namespace: Optional[str] = None, + options: Optional[Dict] = None + ) -> Optional[List]: + """ + Arguments: + name: Use pre-defined name + namespace: Use pre-defined namespace + context: Full parenthood of representation to load + options: Additional settings dictionary + """ + + libpath = self.fname + asset = context["asset"]["name"] + subset = context["subset"]["name"] + lib_container = pype.hosts.blender.plugin.asset_name(asset, subset) + container_name = pype.hosts.blender.plugin.asset_name( + asset, subset, namespace + ) + + container = bpy.data.collections.new(lib_container) + container.name = container_name + blender.pipeline.containerise_existing( + container, + name, + namespace, + context, + self.__class__.__name__, + ) + + container_metadata = container.get( + blender.pipeline.AVALON_PROPERTY) + + container_metadata["libpath"] = libpath + container_metadata["lib_container"] = lib_container + + objects_list = self._process( + libpath, lib_container, container_name, (None, None)) + + # Save the list of objects in the metadata container + container_metadata["objects"] = objects_list + + nodes = list(container.objects) + nodes.append(container) + self[:] = nodes + return nodes + + def update(self, container: Dict, representation: Dict): + """Update the loaded asset. + + This will remove all objects of the current collection, load the new + ones and add them to the collection. + If the objects of the collection are used in another collection they + will not be removed, only unlinked. Normally this should not be the + case though. + + Warning: + No nested collections are supported at the moment! + """ + + collection = bpy.data.collections.get( + container["objectName"] + ) + + libpath = Path(api.get_representation_path(representation)) + extension = libpath.suffix.lower() + + logger.info( + "Container: %s\nRepresentation: %s", + pformat(container, indent=2), + pformat(representation, indent=2), + ) + + assert collection, ( + f"The asset is not loaded: {container['objectName']}" + ) + assert not (collection.children), ( + "Nested collections are not supported." + ) + assert libpath, ( + "No existing library file found for {container['objectName']}" + ) + assert libpath.is_file(), ( + f"The file doesn't exist: {libpath}" + ) + assert extension in pype.hosts.blender.plugin.VALID_EXTENSIONS, ( + f"Unsupported file: {libpath}" + ) + + collection_metadata = collection.get( + blender.pipeline.AVALON_PROPERTY) + collection_libpath = collection_metadata["libpath"] + objects = collection_metadata["objects"] + lib_container = collection_metadata["lib_container"] + + normalized_collection_libpath = ( + str(Path(bpy.path.abspath(collection_libpath)).resolve()) + ) + normalized_libpath = ( + str(Path(bpy.path.abspath(str(libpath))).resolve()) + ) + logger.debug( + "normalized_collection_libpath:\n %s\nnormalized_libpath:\n %s", + normalized_collection_libpath, + normalized_libpath, + ) + if normalized_collection_libpath == normalized_libpath: + logger.info("Library already loaded, not updating...") + return + + camera = objects[0] + + actions = ( camera.animation_data.action, camera.data.animation_data.action ) + + self._remove(objects, lib_container) + + objects_list = self._process( + str(libpath), lib_container, collection.name, actions) + + # Save the list of objects in the metadata container + collection_metadata["objects"] = objects_list + collection_metadata["libpath"] = str(libpath) + collection_metadata["representation"] = str(representation["_id"]) + + bpy.ops.object.select_all(action='DESELECT') + + def remove(self, container: Dict) -> bool: + """Remove an existing container from a Blender scene. + + Arguments: + container (avalon-core:container-1.0): Container to remove, + from `host.ls()`. + + Returns: + bool: Whether the container was deleted. + + Warning: + No nested collections are supported at the moment! + """ + + collection = bpy.data.collections.get( + container["objectName"] + ) + if not collection: + return False + assert not (collection.children), ( + "Nested collections are not supported." + ) + + collection_metadata = collection.get( + blender.pipeline.AVALON_PROPERTY) + objects = collection_metadata["objects"] + lib_container = collection_metadata["lib_container"] + + self._remove(objects, lib_container) + + bpy.data.collections.remove(collection) + + return True diff --git a/pype/plugins/blender/publish/extract_blend.py b/pype/plugins/blender/publish/extract_blend.py index 0924763f12..a5e76dcf4e 100644 --- a/pype/plugins/blender/publish/extract_blend.py +++ b/pype/plugins/blender/publish/extract_blend.py @@ -9,7 +9,7 @@ class ExtractBlend(pype.api.Extractor): label = "Extract Blend" hosts = ["blender"] - families = ["animation", "model", "rig", "action", "layout"] + families = ["model", "camera", "rig", "action", "layout", "animation"] optional = True def process(self, instance): From 85cf9b728e5e5cae6218a12ad2840527a303aaa6 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Tue, 23 Jun 2020 12:56:05 +0100 Subject: [PATCH 02/16] Pep8 compliance --- pype/plugins/blender/load/load_camera.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pype/plugins/blender/load/load_camera.py b/pype/plugins/blender/load/load_camera.py index a69c01e806..7fd8f94b4e 100644 --- a/pype/plugins/blender/load/load_camera.py +++ b/pype/plugins/blender/load/load_camera.py @@ -60,8 +60,6 @@ class BlendCameraLoader(pype.hosts.blender.plugin.AssetLoader): avalon_info = obj[blender.pipeline.AVALON_PROPERTY] avalon_info.update({"container_name": container_name}) - - if actions[0] is not None: if obj.animation_data is None: obj.animation_data_create() @@ -192,7 +190,7 @@ class BlendCameraLoader(pype.hosts.blender.plugin.AssetLoader): camera = objects[0] - actions = ( camera.animation_data.action, camera.data.animation_data.action ) + actions = (camera.animation_data.action, camera.data.animation_data.action) self._remove(objects, lib_container) From 08c7d1e5014a521dd2b3795c26aa07d260981c14 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Tue, 23 Jun 2020 16:32:39 +0100 Subject: [PATCH 03/16] Fix event server mongo uri - collection name in uri creates a bad database name error - uri was not composed correctly --- pype/modules/ftrack/ftrack_server/lib.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pype/modules/ftrack/ftrack_server/lib.py b/pype/modules/ftrack/ftrack_server/lib.py index 327fab817d..32d31a8bff 100644 --- a/pype/modules/ftrack/ftrack_server/lib.py +++ b/pype/modules/ftrack/ftrack_server/lib.py @@ -51,9 +51,8 @@ def get_ftrack_event_mongo_info(): if not _used_ftrack_url or components["database"] is None: components["database"] = database_name - components["collection"] = collection_name - uri = compose_url(components) + uri = compose_url(**components) return uri, components["port"], database_name, collection_name From fc1f8896088bce56df6c806fe0c6a30a5dd5e77e Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Tue, 23 Jun 2020 17:14:28 +0100 Subject: [PATCH 04/16] Ensure collection is not in uri. --- pype/modules/ftrack/ftrack_server/lib.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pype/modules/ftrack/ftrack_server/lib.py b/pype/modules/ftrack/ftrack_server/lib.py index 32d31a8bff..9d0f55ada0 100644 --- a/pype/modules/ftrack/ftrack_server/lib.py +++ b/pype/modules/ftrack/ftrack_server/lib.py @@ -52,6 +52,8 @@ def get_ftrack_event_mongo_info(): if not _used_ftrack_url or components["database"] is None: components["database"] = database_name + components.pop("collection") + uri = compose_url(**components) return uri, components["port"], database_name, collection_name From b470642bec3ad6c531764443fd5c9a2f2d9cdb46 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 10:10:27 +0200 Subject: [PATCH 05/16] icons in tray at the end of initialization --- pype/tools/tray/pype_tray.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pype/tools/tray/pype_tray.py b/pype/tools/tray/pype_tray.py index eec8f61cc4..9b5914ee5e 100644 --- a/pype/tools/tray/pype_tray.py +++ b/pype/tools/tray/pype_tray.py @@ -29,11 +29,11 @@ class TrayManager: self.main_window = main_window self.log = Logger().get_logger(self.__class__.__name__) - self.icon_run = QtGui.QIcon(get_resource('circle_green.png')) - self.icon_stay = QtGui.QIcon(get_resource('circle_orange.png')) - self.icon_failed = QtGui.QIcon(get_resource('circle_red.png')) self.services_thread = None + self.icon_run = QtGui.QIcon(get_resource("circle_green.png")) + self.icon_stay = QtGui.QIcon(get_resource("circle_orange.png")) + self.icon_failed = QtGui.QIcon(get_resource("circle_red.png")) def process_presets(self): """Add modules to tray by presets. From 6e9b8d130b20b0a5315de1e883ce96868e74831e Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 10:11:08 +0200 Subject: [PATCH 06/16] few class attributes moved to object initialization --- pype/tools/tray/pype_tray.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pype/tools/tray/pype_tray.py b/pype/tools/tray/pype_tray.py index 9b5914ee5e..55b47f0bad 100644 --- a/pype/tools/tray/pype_tray.py +++ b/pype/tools/tray/pype_tray.py @@ -12,11 +12,6 @@ class TrayManager: Load submenus, actions, separators and modules into tray's context. """ - modules = {} - services = {} - services_submenu = None - - errors = [] items = ( config.get_presets(first_run=True) .get('tray', {}) @@ -27,8 +22,14 @@ class TrayManager: def __init__(self, tray_widget, main_window): self.tray_widget = tray_widget self.main_window = main_window + self.log = Logger().get_logger(self.__class__.__name__) + self.modules = {} + self.services = {} + self.services_submenu = None + + self.errors = [] self.services_thread = None self.icon_run = QtGui.QIcon(get_resource("circle_green.png")) From 42615368a3ce3fbaddbd96ba2d79b6874fbe0fb5 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 10:12:13 +0200 Subject: [PATCH 07/16] module imports specifications moved to pype --- pype/tools/tray/modules_imports.json | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 pype/tools/tray/modules_imports.json diff --git a/pype/tools/tray/modules_imports.json b/pype/tools/tray/modules_imports.json new file mode 100644 index 0000000000..e9526dcddb --- /dev/null +++ b/pype/tools/tray/modules_imports.json @@ -0,0 +1,58 @@ +[ + { + "title": "User settings", + "type": "module", + "import_path": "pype.modules.user", + "fromlist": ["pype", "modules"] + }, { + "title": "Ftrack", + "type": "module", + "import_path": "pype.modules.ftrack.tray", + "fromlist": ["pype", "modules", "ftrack"] + }, { + "title": "Muster", + "type": "module", + "import_path": "pype.modules.muster", + "fromlist": ["pype", "modules"] + }, { + "title": "Avalon", + "type": "module", + "import_path": "pype.modules.avalon_apps", + "fromlist": ["pype", "modules"] + }, { + "title": "Clockify", + "type": "module", + "import_path": "pype.modules.clockify", + "fromlist": ["pype", "modules"] + }, { + "title": "Standalone Publish", + "type": "module", + "import_path": "pype.modules.standalonepublish", + "fromlist": ["pype", "modules"] + }, { + "title": "Logging", + "type": "module", + "import_path": "pype.modules.logging.tray", + "fromlist": ["pype", "modules", "logging"] + }, { + "title": "Idle Manager", + "type": "module", + "import_path": "pype.modules.idle_manager", + "fromlist": ["pype","modules"] + }, { + "title": "Timers Manager", + "type": "module", + "import_path": "pype.modules.timers_manager", + "fromlist": ["pype","modules"] + }, { + "title": "Rest Api", + "type": "module", + "import_path": "pype.modules.rest_api", + "fromlist": ["pype","modules"] + }, { + "title": "Adobe Communicator", + "type": "module", + "import_path": "pype.modules.adobe_communicator", + "fromlist": ["pype", "modules"] + } +] From d81b0221470d2052cb60202b458ada5f0c89939e Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 10:16:13 +0200 Subject: [PATCH 08/16] module specifications are loaded from json in pype --- pype/tools/tray/pype_tray.py | 46 ++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/pype/tools/tray/pype_tray.py b/pype/tools/tray/pype_tray.py index 55b47f0bad..b6dcf98edf 100644 --- a/pype/tools/tray/pype_tray.py +++ b/pype/tools/tray/pype_tray.py @@ -31,7 +31,17 @@ class TrayManager: self.errors = [] - self.services_thread = None + CURRENT_DIR = os.path.dirname(__file__) + self.modules_imports = config.load_json( + os.path.join(CURRENT_DIR, "modules_imports.json") + ) + presets = config.get_presets(first_run=True) + try: + self.modules_usage = presets["tray"]["menu_items"]["item_usage"] + except Exception: + self.modules_usage = {} + self.log.critical("Couldn't find modules usage data.") + self.icon_run = QtGui.QIcon(get_resource("circle_green.png")) self.icon_stay = QtGui.QIcon(get_resource("circle_orange.png")) self.icon_failed = QtGui.QIcon(get_resource("circle_red.png")) @@ -62,27 +72,23 @@ class TrayManager: } In this case `Statics Server` won't be used. """ - # Backwards compatible presets loading - if isinstance(self.items, list): - items = self.items - else: - items = [] - # Get booleans is module should be used - usages = self.items.get("item_usage") or {} - for item in self.items.get("item_import", []): - import_path = item.get("import_path") - title = item.get("title") - item_usage = usages.get(title) - if item_usage is None: - item_usage = usages.get(import_path, True) + items = [] + # Get booleans is module should be used + for item in self.modules_imports: + import_path = item.get("import_path") + title = item.get("title") - if item_usage: - items.append(item) - else: - if not title: - title = import_path - self.log.debug("{} - Module ignored".format(title)) + item_usage = self.modules_usage.get(title) + if item_usage is None: + item_usage = self.modules_usage.get(import_path, True) + + if item_usage: + items.append(item) + else: + if not title: + title = import_path + self.log.info("{} - Module ignored".format(title)) if items: self.process_items(items, self.tray_widget.menu) From 166df5c58e8c0098d8e30da64df181b233d56fd1 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 10:16:22 +0200 Subject: [PATCH 09/16] cleaned docstring --- pype/tools/tray/pype_tray.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pype/tools/tray/pype_tray.py b/pype/tools/tray/pype_tray.py index b6dcf98edf..18cf1e0982 100644 --- a/pype/tools/tray/pype_tray.py +++ b/pype/tools/tray/pype_tray.py @@ -57,18 +57,6 @@ class TrayManager: "item_usage": { "Statics Server": false } - }, { - "item_import": [{ - "title": "Ftrack", - "type": "module", - "import_path": "pype.ftrack.tray", - "fromlist": ["pype", "ftrack"] - }, { - "title": "Statics Server", - "type": "module", - "import_path": "pype.services.statics_server", - "fromlist": ["pype","services"] - }] } In this case `Statics Server` won't be used. """ From bf868eb97e9e6399fc4f69cc77cadf2d3272e8c8 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 10:16:57 +0200 Subject: [PATCH 10/16] removed items attribute from class definition --- pype/tools/tray/pype_tray.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pype/tools/tray/pype_tray.py b/pype/tools/tray/pype_tray.py index 18cf1e0982..436734e712 100644 --- a/pype/tools/tray/pype_tray.py +++ b/pype/tools/tray/pype_tray.py @@ -12,12 +12,7 @@ class TrayManager: Load submenus, actions, separators and modules into tray's context. """ - items = ( - config.get_presets(first_run=True) - .get('tray', {}) - .get('menu_items', []) - ) - available_sourcetypes = ['python', 'file'] + available_sourcetypes = ["python", "file"] def __init__(self, tray_widget, main_window): self.tray_widget = tray_widget From 1616d598542e651b86d7f6b5132397d36f7aa0c2 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 24 Jun 2020 10:32:57 +0100 Subject: [PATCH 11/16] Fix collection popping. --- pype/modules/ftrack/ftrack_server/lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/modules/ftrack/ftrack_server/lib.py b/pype/modules/ftrack/ftrack_server/lib.py index 9d0f55ada0..8377187ebe 100644 --- a/pype/modules/ftrack/ftrack_server/lib.py +++ b/pype/modules/ftrack/ftrack_server/lib.py @@ -52,7 +52,7 @@ def get_ftrack_event_mongo_info(): if not _used_ftrack_url or components["database"] is None: components["database"] = database_name - components.pop("collection") + components.pop("collection", None) uri = compose_url(**components) From 03daa23fd932437d0752b199ab665aa96ae00bf1 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 15:13:38 +0200 Subject: [PATCH 12/16] movedmoved app icons to ~/pype/resources --- {res => pype/resources}/app_icons/Aport.png | Bin {res => pype/resources}/app_icons/blender.png | Bin .../resources}/app_icons/celaction_local.png | Bin .../resources}/app_icons/celaction_remotel.png | Bin .../resources}/app_icons/clockify-white.png | Bin {res => pype/resources}/app_icons/clockify.png | Bin {res => pype/resources}/app_icons/djvView.png | Bin {res => pype/resources}/app_icons/harmony.png | Bin {res => pype/resources}/app_icons/houdini.png | Bin {res => pype/resources}/app_icons/maya.png | Bin {res => pype/resources}/app_icons/nuke.png | Bin {res => pype/resources}/app_icons/nukex.png | Bin {res => pype/resources}/app_icons/photoshop.png | Bin {res => pype/resources}/app_icons/premiere.png | Bin {res => pype/resources}/app_icons/python.png | Bin {res => pype/resources}/app_icons/resolve.png | Bin {res => pype/resources}/app_icons/storyboardpro.png | Bin {res => pype/resources}/app_icons/ue4.png | Bin 18 files changed, 0 insertions(+), 0 deletions(-) rename {res => pype/resources}/app_icons/Aport.png (100%) rename {res => pype/resources}/app_icons/blender.png (100%) rename {res => pype/resources}/app_icons/celaction_local.png (100%) rename {res => pype/resources}/app_icons/celaction_remotel.png (100%) rename {res => pype/resources}/app_icons/clockify-white.png (100%) rename {res => pype/resources}/app_icons/clockify.png (100%) rename {res => pype/resources}/app_icons/djvView.png (100%) rename {res => pype/resources}/app_icons/harmony.png (100%) rename {res => pype/resources}/app_icons/houdini.png (100%) rename {res => pype/resources}/app_icons/maya.png (100%) rename {res => pype/resources}/app_icons/nuke.png (100%) rename {res => pype/resources}/app_icons/nukex.png (100%) rename {res => pype/resources}/app_icons/photoshop.png (100%) rename {res => pype/resources}/app_icons/premiere.png (100%) rename {res => pype/resources}/app_icons/python.png (100%) rename {res => pype/resources}/app_icons/resolve.png (100%) rename {res => pype/resources}/app_icons/storyboardpro.png (100%) rename {res => pype/resources}/app_icons/ue4.png (100%) diff --git a/res/app_icons/Aport.png b/pype/resources/app_icons/Aport.png similarity index 100% rename from res/app_icons/Aport.png rename to pype/resources/app_icons/Aport.png diff --git a/res/app_icons/blender.png b/pype/resources/app_icons/blender.png similarity index 100% rename from res/app_icons/blender.png rename to pype/resources/app_icons/blender.png diff --git a/res/app_icons/celaction_local.png b/pype/resources/app_icons/celaction_local.png similarity index 100% rename from res/app_icons/celaction_local.png rename to pype/resources/app_icons/celaction_local.png diff --git a/res/app_icons/celaction_remotel.png b/pype/resources/app_icons/celaction_remotel.png similarity index 100% rename from res/app_icons/celaction_remotel.png rename to pype/resources/app_icons/celaction_remotel.png diff --git a/res/app_icons/clockify-white.png b/pype/resources/app_icons/clockify-white.png similarity index 100% rename from res/app_icons/clockify-white.png rename to pype/resources/app_icons/clockify-white.png diff --git a/res/app_icons/clockify.png b/pype/resources/app_icons/clockify.png similarity index 100% rename from res/app_icons/clockify.png rename to pype/resources/app_icons/clockify.png diff --git a/res/app_icons/djvView.png b/pype/resources/app_icons/djvView.png similarity index 100% rename from res/app_icons/djvView.png rename to pype/resources/app_icons/djvView.png diff --git a/res/app_icons/harmony.png b/pype/resources/app_icons/harmony.png similarity index 100% rename from res/app_icons/harmony.png rename to pype/resources/app_icons/harmony.png diff --git a/res/app_icons/houdini.png b/pype/resources/app_icons/houdini.png similarity index 100% rename from res/app_icons/houdini.png rename to pype/resources/app_icons/houdini.png diff --git a/res/app_icons/maya.png b/pype/resources/app_icons/maya.png similarity index 100% rename from res/app_icons/maya.png rename to pype/resources/app_icons/maya.png diff --git a/res/app_icons/nuke.png b/pype/resources/app_icons/nuke.png similarity index 100% rename from res/app_icons/nuke.png rename to pype/resources/app_icons/nuke.png diff --git a/res/app_icons/nukex.png b/pype/resources/app_icons/nukex.png similarity index 100% rename from res/app_icons/nukex.png rename to pype/resources/app_icons/nukex.png diff --git a/res/app_icons/photoshop.png b/pype/resources/app_icons/photoshop.png similarity index 100% rename from res/app_icons/photoshop.png rename to pype/resources/app_icons/photoshop.png diff --git a/res/app_icons/premiere.png b/pype/resources/app_icons/premiere.png similarity index 100% rename from res/app_icons/premiere.png rename to pype/resources/app_icons/premiere.png diff --git a/res/app_icons/python.png b/pype/resources/app_icons/python.png similarity index 100% rename from res/app_icons/python.png rename to pype/resources/app_icons/python.png diff --git a/res/app_icons/resolve.png b/pype/resources/app_icons/resolve.png similarity index 100% rename from res/app_icons/resolve.png rename to pype/resources/app_icons/resolve.png diff --git a/res/app_icons/storyboardpro.png b/pype/resources/app_icons/storyboardpro.png similarity index 100% rename from res/app_icons/storyboardpro.png rename to pype/resources/app_icons/storyboardpro.png diff --git a/res/app_icons/ue4.png b/pype/resources/app_icons/ue4.png similarity index 100% rename from res/app_icons/ue4.png rename to pype/resources/app_icons/ue4.png From 7eb36b417359682d7310ea57808461e7cdee895d Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 15:14:10 +0200 Subject: [PATCH 13/16] moved ftrack resource files to ~/pype/resources --- .../ftrack/action_icons/ActionAskWhereIRun.svg | 0 .../ftrack/action_icons/AssetsRemover.svg | 0 .../ftrack/action_icons/ComponentOpen.svg | 0 .../ftrack/action_icons/CreateFolders.svg | 0 .../ftrack/action_icons/CreateProjectFolders.svg | 0 .../resources}/ftrack/action_icons/DeleteAsset.svg | 0 .../resources}/ftrack/action_icons/Delivery.svg | 0 .../ftrack/action_icons/MultipleNotes.svg | 0 .../ftrack/action_icons/PrepareProject.svg | 0 .../resources}/ftrack/action_icons/PypeAdmin.svg | 0 .../resources}/ftrack/action_icons/PypeDoctor.svg | 0 .../resources}/ftrack/action_icons/PypeUpdate.svg | 0 {res => pype/resources}/ftrack/action_icons/RV.png | Bin .../resources}/ftrack/action_icons/SeedProject.svg | 0 .../ftrack/action_icons/SyncHierarchicalAttrs.svg | 0 .../resources}/ftrack/action_icons/SyncToAvalon.svg | 0 .../resources}/ftrack/action_icons/TestAction.svg | 0 .../resources}/ftrack/action_icons/Thumbnail.svg | 0 {res => pype/resources}/ftrack/sign_in_message.html | 0 19 files changed, 0 insertions(+), 0 deletions(-) rename {res => pype/resources}/ftrack/action_icons/ActionAskWhereIRun.svg (100%) rename {res => pype/resources}/ftrack/action_icons/AssetsRemover.svg (100%) rename {res => pype/resources}/ftrack/action_icons/ComponentOpen.svg (100%) rename {res => pype/resources}/ftrack/action_icons/CreateFolders.svg (100%) rename {res => pype/resources}/ftrack/action_icons/CreateProjectFolders.svg (100%) rename {res => pype/resources}/ftrack/action_icons/DeleteAsset.svg (100%) rename {res => pype/resources}/ftrack/action_icons/Delivery.svg (100%) rename {res => pype/resources}/ftrack/action_icons/MultipleNotes.svg (100%) rename {res => pype/resources}/ftrack/action_icons/PrepareProject.svg (100%) rename {res => pype/resources}/ftrack/action_icons/PypeAdmin.svg (100%) rename {res => pype/resources}/ftrack/action_icons/PypeDoctor.svg (100%) rename {res => pype/resources}/ftrack/action_icons/PypeUpdate.svg (100%) rename {res => pype/resources}/ftrack/action_icons/RV.png (100%) rename {res => pype/resources}/ftrack/action_icons/SeedProject.svg (100%) rename {res => pype/resources}/ftrack/action_icons/SyncHierarchicalAttrs.svg (100%) rename {res => pype/resources}/ftrack/action_icons/SyncToAvalon.svg (100%) rename {res => pype/resources}/ftrack/action_icons/TestAction.svg (100%) rename {res => pype/resources}/ftrack/action_icons/Thumbnail.svg (100%) rename {res => pype/resources}/ftrack/sign_in_message.html (100%) diff --git a/res/ftrack/action_icons/ActionAskWhereIRun.svg b/pype/resources/ftrack/action_icons/ActionAskWhereIRun.svg similarity index 100% rename from res/ftrack/action_icons/ActionAskWhereIRun.svg rename to pype/resources/ftrack/action_icons/ActionAskWhereIRun.svg diff --git a/res/ftrack/action_icons/AssetsRemover.svg b/pype/resources/ftrack/action_icons/AssetsRemover.svg similarity index 100% rename from res/ftrack/action_icons/AssetsRemover.svg rename to pype/resources/ftrack/action_icons/AssetsRemover.svg diff --git a/res/ftrack/action_icons/ComponentOpen.svg b/pype/resources/ftrack/action_icons/ComponentOpen.svg similarity index 100% rename from res/ftrack/action_icons/ComponentOpen.svg rename to pype/resources/ftrack/action_icons/ComponentOpen.svg diff --git a/res/ftrack/action_icons/CreateFolders.svg b/pype/resources/ftrack/action_icons/CreateFolders.svg similarity index 100% rename from res/ftrack/action_icons/CreateFolders.svg rename to pype/resources/ftrack/action_icons/CreateFolders.svg diff --git a/res/ftrack/action_icons/CreateProjectFolders.svg b/pype/resources/ftrack/action_icons/CreateProjectFolders.svg similarity index 100% rename from res/ftrack/action_icons/CreateProjectFolders.svg rename to pype/resources/ftrack/action_icons/CreateProjectFolders.svg diff --git a/res/ftrack/action_icons/DeleteAsset.svg b/pype/resources/ftrack/action_icons/DeleteAsset.svg similarity index 100% rename from res/ftrack/action_icons/DeleteAsset.svg rename to pype/resources/ftrack/action_icons/DeleteAsset.svg diff --git a/res/ftrack/action_icons/Delivery.svg b/pype/resources/ftrack/action_icons/Delivery.svg similarity index 100% rename from res/ftrack/action_icons/Delivery.svg rename to pype/resources/ftrack/action_icons/Delivery.svg diff --git a/res/ftrack/action_icons/MultipleNotes.svg b/pype/resources/ftrack/action_icons/MultipleNotes.svg similarity index 100% rename from res/ftrack/action_icons/MultipleNotes.svg rename to pype/resources/ftrack/action_icons/MultipleNotes.svg diff --git a/res/ftrack/action_icons/PrepareProject.svg b/pype/resources/ftrack/action_icons/PrepareProject.svg similarity index 100% rename from res/ftrack/action_icons/PrepareProject.svg rename to pype/resources/ftrack/action_icons/PrepareProject.svg diff --git a/res/ftrack/action_icons/PypeAdmin.svg b/pype/resources/ftrack/action_icons/PypeAdmin.svg similarity index 100% rename from res/ftrack/action_icons/PypeAdmin.svg rename to pype/resources/ftrack/action_icons/PypeAdmin.svg diff --git a/res/ftrack/action_icons/PypeDoctor.svg b/pype/resources/ftrack/action_icons/PypeDoctor.svg similarity index 100% rename from res/ftrack/action_icons/PypeDoctor.svg rename to pype/resources/ftrack/action_icons/PypeDoctor.svg diff --git a/res/ftrack/action_icons/PypeUpdate.svg b/pype/resources/ftrack/action_icons/PypeUpdate.svg similarity index 100% rename from res/ftrack/action_icons/PypeUpdate.svg rename to pype/resources/ftrack/action_icons/PypeUpdate.svg diff --git a/res/ftrack/action_icons/RV.png b/pype/resources/ftrack/action_icons/RV.png similarity index 100% rename from res/ftrack/action_icons/RV.png rename to pype/resources/ftrack/action_icons/RV.png diff --git a/res/ftrack/action_icons/SeedProject.svg b/pype/resources/ftrack/action_icons/SeedProject.svg similarity index 100% rename from res/ftrack/action_icons/SeedProject.svg rename to pype/resources/ftrack/action_icons/SeedProject.svg diff --git a/res/ftrack/action_icons/SyncHierarchicalAttrs.svg b/pype/resources/ftrack/action_icons/SyncHierarchicalAttrs.svg similarity index 100% rename from res/ftrack/action_icons/SyncHierarchicalAttrs.svg rename to pype/resources/ftrack/action_icons/SyncHierarchicalAttrs.svg diff --git a/res/ftrack/action_icons/SyncToAvalon.svg b/pype/resources/ftrack/action_icons/SyncToAvalon.svg similarity index 100% rename from res/ftrack/action_icons/SyncToAvalon.svg rename to pype/resources/ftrack/action_icons/SyncToAvalon.svg diff --git a/res/ftrack/action_icons/TestAction.svg b/pype/resources/ftrack/action_icons/TestAction.svg similarity index 100% rename from res/ftrack/action_icons/TestAction.svg rename to pype/resources/ftrack/action_icons/TestAction.svg diff --git a/res/ftrack/action_icons/Thumbnail.svg b/pype/resources/ftrack/action_icons/Thumbnail.svg similarity index 100% rename from res/ftrack/action_icons/Thumbnail.svg rename to pype/resources/ftrack/action_icons/Thumbnail.svg diff --git a/res/ftrack/sign_in_message.html b/pype/resources/ftrack/sign_in_message.html similarity index 100% rename from res/ftrack/sign_in_message.html rename to pype/resources/ftrack/sign_in_message.html From 5a2ae24d9e9458d2b50fbb504e83b865b4a3c7ef Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 15:14:48 +0200 Subject: [PATCH 14/16] rest api statics path changed to ~/pype/resources --- pype/modules/rest_api/rest_api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pype/modules/rest_api/rest_api.py b/pype/modules/rest_api/rest_api.py index 5f0969a5a2..1c4db9f706 100644 --- a/pype/modules/rest_api/rest_api.py +++ b/pype/modules/rest_api/rest_api.py @@ -102,7 +102,11 @@ class RestApiServer: port = self.find_port() self.rest_api_thread = RestApiThread(self, port) - statics_dir = os.path.sep.join([os.environ["PYPE_MODULE_ROOT"], "res"]) + statics_dir = os.path.join( + os.environ["PYPE_MODULE_ROOT"], + "pype", + "resources" + ) self.register_statics("/res", statics_dir) os.environ["PYPE_STATICS_SERVER"] = "{}/res".format( os.environ["PYPE_REST_API_URL"] From 880c91b06ecd003174c56c5c8d5efe3928b6e9ec Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 15:15:20 +0200 Subject: [PATCH 15/16] modified ftrack message file getting --- pype/modules/ftrack/tray/login_tools.py | 33 +++++++++++-------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/pype/modules/ftrack/tray/login_tools.py b/pype/modules/ftrack/tray/login_tools.py index b259f2d2ed..02982294f2 100644 --- a/pype/modules/ftrack/tray/login_tools.py +++ b/pype/modules/ftrack/tray/login_tools.py @@ -1,16 +1,16 @@ from http.server import BaseHTTPRequestHandler, HTTPServer from urllib import parse -import os import webbrowser import functools -import pype -import inspect from Qt import QtCore +from pype.api import resources class LoginServerHandler(BaseHTTPRequestHandler): '''Login server handler.''' + message_filepath = resources.get_resource("ftrack", "sign_in_message.html") + def __init__(self, login_callback, *args, **kw): '''Initialise handler.''' self.login_callback = login_callback @@ -28,23 +28,21 @@ class LoginServerHandler(BaseHTTPRequestHandler): login_credentials = parse.parse_qs(query) api_user = login_credentials['api_user'][0] api_key = login_credentials['api_key'][0] - # get path to resources - path_items = os.path.dirname( - inspect.getfile(pype) - ).split(os.path.sep) - del path_items[-1] - path_items.extend(['res', 'ftrack', 'sign_in_message.html']) - message_filepath = os.path.sep.join(path_items) - message_file = open(message_filepath, 'r') - sign_in_message = message_file.read() - message_file.close() + + with open(self.message_filepath, "r") as message_file: + sign_in_message = message_file.read() + # formatting html code for python - replacement = [('{', '{{'), ('}', '}}'), ('{{}}', '{}')] - for r in (replacement): - sign_in_message = sign_in_message.replace(*r) + replacements = ( + ("{", "{{"), + ("}", "}}"), + ("{{}}", "{}") + ) + for replacement in (replacements): + sign_in_message = sign_in_message.replace(*replacement) message = sign_in_message.format(api_user) else: - message = '

Failed to sign in

' + message = "

Failed to sign in

" self.send_response(200) self.end_headers() @@ -74,7 +72,6 @@ class LoginServerThread(QtCore.QThread): def run(self): '''Listen for events.''' - # self._server = BaseHTTPServer.HTTPServer( self._server = HTTPServer( ('localhost', 0), functools.partial( From a72c9a0e6fd400882a31fba85a7e217abfc7b0e9 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 24 Jun 2020 15:16:52 +0200 Subject: [PATCH 16/16] added resources to pype.api --- pype/api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pype/api.py b/pype/api.py index 5775bb3ce4..44a31f2626 100644 --- a/pype/api.py +++ b/pype/api.py @@ -12,6 +12,8 @@ from pypeapp.lib.mongo import ( get_default_components ) +from . import resources + from .plugin import ( Extractor, @@ -54,6 +56,8 @@ __all__ = [ "compose_url", "get_default_components", + # Resources + "resources", # plugin classes "Extractor", # ordering