Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Add validator to check correct version of extension for PS and AE #397

Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified avalon/aftereffects/extension.zxp
Binary file not shown.
2 changes: 1 addition & 1 deletion avalon/aftereffects/extension/CSXS/manifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ExtensionManifest Version="8.0" ExtensionBundleId="com.openpype.AE.panel" ExtensionBundleVersion="1.0.18"
<ExtensionManifest Version="8.0" ExtensionBundleId="com.openpype.AE.panel" ExtensionBundleVersion="1.0.20"
ExtensionBundleName="openpype" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ExtensionList>
<Extension Id="com.openpype.AE.panel" Version="1.0" />
Expand Down
37 changes: 37 additions & 0 deletions avalon/aftereffects/extension/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@ async function startUp(url){
main(res);
}

function get_extension_version(){
/** Returns version number from extension manifest.xml **/
log.debug("get_extension_version")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

var path = csInterface.getSystemPath(SystemPath.EXTENSION);
log.debug("extension path " + path);

var result = window.cep.fs.readFile(path + "/CSXS/manifest.xml");
var version = undefined;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary to initialize 'version' to 'undefined'.

if(result.err === 0){
if (window.DOMParser) {
const parser = new DOMParser();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const xmlDoc = parser.parseFromString(result.data.toString(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

'text/xml');
const children = xmlDoc.children;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).


for (let i = 0; i <= children.length; i++) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

if (children[i] &&
children[i].getAttribute('ExtensionBundleVersion')) {
version =
children[i].getAttribute('ExtensionBundleVersion');
}
}
}
}
return version
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

}

function main(websocket_url){
// creates connection to 'websocket_url', registers routes
var default_url = 'ws://localhost:8099/ws/';
Expand Down Expand Up @@ -268,6 +295,16 @@ function main(websocket_url){
return result;
});
});

RPC.addRoute('AfterEffects.get_extension_version', function (data) {
log.warn('Server called client route "get_extension_version":', data);
return get_extension_version();
});

RPC.addRoute('AfterEffects.close', function (data) {
log.warn('Server called client route "close":', data);
return runEvalScript("close()");
});
}

/** main entry point **/
Expand Down
6 changes: 6 additions & 0 deletions avalon/aftereffects/extension/jsx/hostscript.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,12 @@ function render(target_folder){
}
app.project.renderQueue.render();
}


function close(){
app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);
app.quit();
}



Expand Down
17 changes: 9 additions & 8 deletions avalon/aftereffects/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
import traceback
import logging

from wsrpc_aiohttp import (
WebSocketRoute,
WebSocketAsync
)

from Qt import QtWidgets

from openpype.lib.remote_publish import headless_publish

from openpype.tools.utils import host_tools
from .launch_logic import ProcessLauncher, stub


log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)

Expand All @@ -37,8 +33,13 @@ def main(*subprocess_args):
launcher = ProcessLauncher(subprocess_args)
launcher.start()

# Launch aftereffects and the websocket server.
if os.environ.get("AVALON_PHOTOSHOP_WORKFILES_ON_LAUNCH", True):
if os.environ.get("HEADLESS_PUBLISH"):
# reusing ConsoleTrayApp approach as it was already implemented
launcher.execute_in_main_thread(lambda: headless_publish(
log,
"CloseAE",
os.environ.get("IS_TEST")))
elif os.environ.get("AVALON_PHOTOSHOP_WORKFILES_ON_LAUNCH", True):
save = False
if os.getenv("WORKFILES_SAVE_AS"):
save = True
Expand Down
11 changes: 8 additions & 3 deletions avalon/aftereffects/ws_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,6 @@ def get_audio_url(self, item_id):

return res

def close(self):
self.client.close()

def import_background(self, comp_id, comp_name, files):
"""
Imports backgrounds images to existing or new composition.
Expand Down Expand Up @@ -533,6 +530,14 @@ def render(self, folder_url):
('AfterEffects.render',
folder_url=folder_url))

def get_extension_version(self):
"""Returns version number of installed extension."""
return self.websocketserver.call(self.client.call(
'AfterEffects.get_extension_version'))

def close(self):
self.websocketserver.call(self.client.call('AfterEffects.close'))

def _to_records(self, res):
"""
Converts string json representation into list of AEItem
Expand Down
4 changes: 4 additions & 0 deletions avalon/photoshop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ For easier debugging of Javascript:
https://community.adobe.com/t5/download-install/adobe-extension-debuger-problem/td-p/10911704?page=1
Add --enable-blink-features=ShadowDOMV0,CustomElementsV0 when starting Chrome
then localhost:8078 (port set in `photoshop\extension\.debug`)

Or use Visual Studio Code https://medium.com/adobetech/extendscript-debugger-for-visual-studio-code-public-release-a2ff6161fa01

Or install CEF client from https://github.com/Adobe-CEP/CEP-Resources/tree/master/CEP_9.x
## Resources
- https://github.com/lohriialo/photoshop-scripting-python
- https://www.adobe.com/devnet/photoshop/scripting.html
Expand Down
Binary file modified avalon/photoshop/extension.zxp
Binary file not shown.
2 changes: 1 addition & 1 deletion avalon/photoshop/extension/CSXS/manifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<ExtensionManifest ExtensionBundleId="com.openpype.PS.panel" ExtensionBundleVersion="1.0.10" Version="7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ExtensionManifest ExtensionBundleId="com.openpype.PS.panel" ExtensionBundleVersion="1.0.11" Version="7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ExtensionList>
<Extension Id="com.openpype.PS.panel" Version="1.0.1" />
</ExtensionList>
Expand Down
31 changes: 30 additions & 1 deletion avalon/photoshop/extension/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@
// run rest only after resolved promise
main(res);
}

function get_extension_version(){
/** Returns version number from extension manifest.xml **/
log.debug("get_extension_version")
var path = csInterface.getSystemPath(SystemPath.EXTENSION);
log.debug("extension path " + path);

var result = window.cep.fs.readFile(path + "/CSXS/manifest.xml");
var version = undefined;
if(result.err === 0){
if (window.DOMParser) {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(result.data.toString(), 'text/xml');
const children = xmlDoc.children;

for (let i = 0; i <= children.length; i++) {
if (children[i] && children[i].getAttribute('ExtensionBundleVersion')) {
version = children[i].getAttribute('ExtensionBundleVersion');
}
}
}
}
return version
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

}

function main(websocket_url){
// creates connection to 'websocket_url', registers routes
Expand Down Expand Up @@ -249,10 +273,15 @@
});
});

RPC.addRoute('Photoshop.get_extension_version', function (data) {
log.warn('Server called client route "get_extension_version":', data);
return get_extension_version();
});

RPC.addRoute('Photoshop.close', function (data) {
log.warn('Server called client route "close":', data);
return runEvalScript("close()");
});
});

RPC.call('Photoshop.ping').then(function (data) {
log.warn('Result for calling server route "ping": ', data);
Expand Down
26 changes: 5 additions & 21 deletions avalon/photoshop/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

from openpype.tools.utils import host_tools

from openpype.lib.remote_publish import (
get_webpublish_conn, publish_and_log
)
from openpype.lib.remote_publish import headless_publish

from .launch_logic import ProcessLauncher, stub

Expand All @@ -37,9 +35,10 @@ def main(*subprocess_args):
launcher.start()

if os.environ.get("HEADLESS_PUBLISH"):
# reusing ConsoleTrayApp approach as it was already implemented
launcher.execute_in_main_thread(headless_publish)

launcher.execute_in_main_thread(lambda: headless_publish(
log,
"ClosePS",
os.environ.get("IS_TEST")))
elif os.environ.get("AVALON_PHOTOSHOP_WORKFILES_ON_LAUNCH", True):
save = False
if os.getenv("WORKFILES_SAVE_AS"):
Expand All @@ -52,21 +51,6 @@ def main(*subprocess_args):
sys.exit(app.exec_())


def headless_publish():
"""Runs publish in a opened host with a context and closes Python process.

Host is being closed via ClosePS pyblish plugin which triggers 'exit'
method in ConsoleTrayApp.
"""
dbcon = get_webpublish_conn()
_id = os.environ.get("BATCH_LOG_ID")
if not _id:
log.warning("Unable to store log records, batch will be unfinished!")
return

publish_and_log(dbcon, _id, log, 'ClosePS')


@contextlib.contextmanager
def maintained_selection():
"""Maintain selection during context."""
Expand Down
5 changes: 5 additions & 0 deletions avalon/photoshop/ws_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ def remove_instance(self, instance_id):
('Photoshop.imprint', payload=payload)
)

def get_extension_version(self):
"""Returns version number of installed extension."""
return self.websocketserver.call(self.client.call
('Photoshop.get_extension_version'))

def close(self):
"""Shutting down PS and process too.

Expand Down