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

[draft] convert premiere to pype2 #92

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0c4e560
Merge branch 'develop' into feature/PYPE-624-convert-premiere-to-pype2
Mar 31, 2020
3a3bb0a
feat(premiere): conversion to pype2 - wip
Mar 31, 2020
0ce4a3d
feat(premiere): adding pysync.py to vendors
Apr 1, 2020
3facd29
feat(premiere): updating pysync in vendors
Apr 1, 2020
70ef1d8
feat(premiere): extension package.json for node_modules
Apr 1, 2020
124e61a
feat(premiere): wip wrapper
Apr 1, 2020
a0ab0fe
feat(premiere): update static page
Apr 2, 2020
082fbb3
allow multiple statics server and fixed few smaller bugs
iLLiCiTiT Apr 2, 2020
64bdfe9
put process route back
iLLiCiTiT Apr 2, 2020
e34d21c
basic implementation of premiere communicator
iLLiCiTiT Apr 2, 2020
352ec7d
feat(ppro): prelaunch finalized wrapping
Apr 3, 2020
d4c773d
feat(ppro): changing url for restapi
Apr 3, 2020
fd08af2
feat(ppro): lib pep8 fixes
Apr 3, 2020
ef307e9
feat(ppro): moving static gui pages to ppro
Apr 3, 2020
a88b808
feat(service): adding adobe restapi service
Apr 3, 2020
0c6a078
feat(service): missing init added
Apr 3, 2020
21197ec
feat(ppre): updating extension and its dependencies
Apr 3, 2020
9de1d2c
feat(premiere): wip extension to pype2
Apr 7, 2020
16840a9
feat(ppro): reworking `api` to `pras` > pype rest api server
Apr 7, 2020
5436a39
feat(): pype.jsx, pype.js fix syntax
Apr 8, 2020
f2c5beb
feat(): improving batchRenamer loading
Apr 8, 2020
6ffacaa
gitignore debug log
Apr 8, 2020
977879c
feat(): wip aport to restapi
Apr 9, 2020
e1395fb
Merge branch 'develop' into feature/PYPE-624-convert-premiere-to-pype2
Apr 9, 2020
405eaeb
feat(ppro): wip on refactory to pype2
Apr 10, 2020
12ceadf
feat(ppro): wip on refactoring
Apr 10, 2020
ba9524d
feat(ppro): wip on extension
Apr 13, 2020
a22ae98
feat(ppro): wip publishing from premiere
Apr 15, 2020
8a484e8
feat(ppro): unnecessary imports
Apr 15, 2020
b04805a
feat(ppro): wip publishing clips
Apr 16, 2020
3070e17
fix(adobe, ppro): clearing code
Apr 17, 2020
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ coverage.xml
##################
node_modules/
package-lock.json

pype/premiere/ppro/js/debug.log
25 changes: 22 additions & 3 deletions pype/avalon_apps/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def get_project(self, request):
if not project_name:
output = {}
for project_name in self.dbcon.tables():
project = self.dbcon[project_name].find_one({"type": "project"})
project = self.dbcon[project_name].find_one({
"type": "project"
})
output[project_name] = project

return CallbackResult(data=self.result_to_json(output))
Expand All @@ -44,7 +46,7 @@ def get_assets(self, request):

if not self.dbcon.exist_table(_project_name):
abort(404, "Project \"{}\" was not found in database".format(
project_name
_project_name
))

if not _asset:
Expand All @@ -65,9 +67,26 @@ def get_assets(self, request):
return asset

abort(404, "Asset \"{}\" with {} was not found in project {}".format(
_asset, identificator, project_name
_asset, identificator, _project_name
))

@RestApi.route("/publish/<asset_name>", url_prefix="/premiere", methods="GET")
def publish(self, request):
"""
http://localhost:8021/premiere/publish/shot021?json_in=this/path/file_in.json&json_out=this/path/file_out.json
"""
asset_name = request.url_data["asset_name"]
query = request.query
data = request.request_data

output = {
"message": "Got your data. Thanks.",
"your_data": data,
"your_query": query,
"your_asset_is": asset_name
}
return CallbackResult(data=self.result_to_json(output))

def result_to_json(self, result):
""" Converts result of MongoDB query to dict without $oid (ObjectId)
keys with help of regex matching.
Expand Down
45 changes: 45 additions & 0 deletions pype/hooks/premiere/prelaunch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os
import traceback
from pype.lib import PypeHook
from pypeapp import Logger
import importlib
import avalon.api
import pype.premiere
from pype.premiere import lib as prlib


class PremierePrelaunch(PypeHook):
"""
This hook will check if current workfile path has Adobe Premiere
project inside. IF not, it initialize it and finally it pass
path to the project by environment variable to Premiere launcher
shell script.
"""

def __init__(self, logger=None):
if not logger:
self.log = Logger().get_logger(self.__class__.__name__)
else:
self.log = logger

self.signature = "( {} )".format(self.__class__.__name__)

def execute(self, *args, env: dict = None) -> bool:

if not env:
env = os.environ

try:
__import__("pype.premiere")
__import__("pyblish")

except ImportError as e:
Copy link
Member

Choose a reason for hiding this comment

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

__import__() can return in some cases ValueError on python < 3.9. See (https://bugs.python.org/issue37444)

print(traceback.format_exc())
print("pyblish: Could not load integration: %s " % e)

else:
# Premiere Setup integration
importlib.reload(prlib)
prlib.setup(env)

return True
91 changes: 91 additions & 0 deletions pype/plugins/adobecommunicator/publish/collect_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import os
import pyblish.api
from avalon import (
io,
api as avalon
)
import json
from pathlib import Path


class CollectContextDataFromAport(pyblish.api.ContextPlugin):
"""
Collecting temp json data sent from a host context
and path for returning json data back to hostself.

Setting avalon session into correct context

Args:
context (obj): pyblish context session

"""

label = "AdobeCommunicator Collect Context"
order = pyblish.api.CollectorOrder - 0.49

def process(self, context):
self.log.info("registred_hosts: `{}`".format(pyblish.api.registered_hosts()))
io.install()
# get json paths from data
input_json_path = os.environ.get("AC_PUBLISH_INPATH")
output_json_path = os.environ.get("AC_PUBLISH_OUTPATH")

rqst_json_data_path = Path(input_json_path)
post_json_data_path = Path(output_json_path)

context.data['post_json_data_path'] = str(post_json_data_path)

# get avalon session data and convert \ to /
_S = avalon.session

projects = Path(_S["AVALON_PROJECTS"]).resolve()
asset = _S["AVALON_ASSET"]
workdir = Path(_S["AVALON_WORKDIR"]).resolve()
_S["AVALON_PROJECTS"] = str(projects)
_S["AVALON_WORKDIR"] = str(workdir)

context.data["avalonSession"] = _S
self.log.info(f"__ avalonSession: `{_S}`")

# get stagin directory from recieved path to json
context.data["stagingDir"] = post_json_data_path.parent

# get data from json file recieved
with rqst_json_data_path.open(mode='r') as f:
context.data["jsonData"] = json_data = json.load(f)
assert json_data, "No `data` in json file"

# get and check host type
host = json_data.get("host", None)
host_version = json_data.get("hostVersion", None)
assert host, "No `host` data in json file"
assert host_version, "No `hostVersion` data in json file"
context.data["host"] = _S["AVALON_APP"] = host
context.data["hostVersion"] = \
_S["AVALON_APP_VERSION"] = host_version

# get current file
current_file = json_data.get("currentFile", None)
assert current_file, "No `currentFile` data in json file"
context.data["currentFile"] = Path(current_file).resolve()

# get project data from avalon
project_data = io.find_one({'type': 'project'})
assert project_data, "No `project_data` data in avalon db"
context.data["projectData"] = project_data
self.log.debug("project_data: {}".format(project_data))

# get asset data from avalon and fix all paths
asset_data = io.find_one({
"type": 'asset',
"name": asset
})["data"]
assert asset_data, "No `asset_data` data in avalon db"

context.data["assetData"] = asset_data

self.log.debug("asset_data: {}".format(asset_data))
self.log.info("rqst_json_data_path is: {}".format(rqst_json_data_path))
self.log.info("post_json_data_path is: {}".format(post_json_data_path))

# self.log.info("avalon.session is: {}".format(avalon.session))
Loading