Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all 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
7 changes: 0 additions & 7 deletions pype/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from .settings import (
system_settings,
project_settings
)
from pypeapp import (
Logger,
Anatomy,
Expand Down Expand Up @@ -53,9 +49,6 @@
from .lib import _subprocess as subprocess

__all__ = [
"system_settings",
"project_settings",

"Logger",
"Anatomy",
"project_overrides_dir_path",
Expand Down
7 changes: 6 additions & 1 deletion pype/hosts/harmony/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ def set_scene_settings(settings):
if (args[0]["frameStart"] && args[0]["frameEnd"])
{
var duration = args[0]["frameEnd"] - args[0]["frameStart"] + 1

if (frame.numberOf() > duration)
{
frame.remove(
duration, frame.numberOf() - duration
);
}
if (frame.numberOf() < duration)
{
frame.insert(
Expand Down
29 changes: 0 additions & 29 deletions pype/hosts/maya/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,6 @@ def update(self, container, representation):

assert os.path.exists(path), "%s does not exist." % path

# Need to save alembic settings and reapply, cause referencing resets
# them to incoming data.
alembic_attrs = ["speed", "offset", "cycleType"]
alembic_data = {}
if representation["name"] == "abc":
alembic_nodes = cmds.ls(
"{}:*".format(members[0].split(":")[0]), type="AlembicNode"
)
if alembic_nodes:
for attr in alembic_attrs:
node_attr = "{}.{}".format(alembic_nodes[0], attr)
alembic_data[attr] = cmds.getAttr(node_attr)
else:
cmds.warning(
"No alembic nodes found in {}".format(
cmds.ls("{}:*".format(members[0].split(":")[0]))
)
)

try:
content = cmds.file(path,
loadReference=reference_node,
Expand All @@ -214,16 +195,6 @@ def update(self, container, representation):

self.log.warning("Ignoring file read error:\n%s", exc)

# Reapply alembic settings.
if representation["name"] == "abc":
alembic_nodes = cmds.ls(
"{}:*".format(members[0].split(":")[0]), type="AlembicNode"
)
if alembic_nodes:
for attr in alembic_attrs:
value = alembic_data[attr]
cmds.setAttr("{}.{}".format(alembic_nodes[0], attr), value)

# Fix PLN-40 for older containers created with Avalon that had the
# `.verticesOnlySet` set to True.
if cmds.getAttr("{}.verticesOnlySet".format(node)):
Expand Down
4 changes: 2 additions & 2 deletions pype/hosts/nukestudio/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def add_tags_from_presets():
# Get project task types.
tasks = io.find_one({"type": "project"})["config"]["tasks"]
nks_pres_tags["[Tasks]"] = {}
for task in tasks:
nks_pres_tags["[Tasks]"][task["name"]] = {
for task_type in tasks.keys():
nks_pres_tags["[Tasks]"][task_type] = {
"editable": "1",
"note": "",
"icon": {
Expand Down
171 changes: 3 additions & 168 deletions pype/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from avalon import io, pipeline
import six
import avalon.api
from .api import config, Anatomy, Logger
from .api import config, Anatomy

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -1622,7 +1622,7 @@ class ApplicationAction(avalon.api.Action):
parsed application `.toml` this can launch the application.

"""
_log = None

config = None
group = None
variant = None
Expand All @@ -1632,12 +1632,6 @@ class ApplicationAction(avalon.api.Action):
"AVALON_TASK"
)

@property
def log(self):
if self._log is None:
self._log = Logger().get_logger(self.__class__.__name__)
return self._log

def is_compatible(self, session):
for key in self.required_session_keys:
if key not in session:
Expand All @@ -1650,165 +1644,6 @@ def process(self, session, **kwargs):
project_name = session["AVALON_PROJECT"]
asset_name = session["AVALON_ASSET"]
task_name = session["AVALON_TASK"]
launch_application(
return launch_application(
project_name, asset_name, task_name, self.name
)

self._ftrack_after_launch_procedure(
project_name, asset_name, task_name
)

def _ftrack_after_launch_procedure(
self, project_name, asset_name, task_name
):
# TODO move to launch hook
required_keys = ("FTRACK_SERVER", "FTRACK_API_USER", "FTRACK_API_KEY")
for key in required_keys:
if not os.environ.get(key):
self.log.debug((
"Missing required environment \"{}\""
" for Ftrack after launch procedure."
).format(key))
return

try:
import ftrack_api
session = ftrack_api.Session(auto_connect_event_hub=True)
self.log.debug("Ftrack session created")
except Exception:
self.log.warning("Couldn't create Ftrack session")
return

try:
entity = self._find_ftrack_task_entity(
session, project_name, asset_name, task_name
)
self._ftrack_status_change(session, entity, project_name)
self._start_timer(session, entity, ftrack_api)
except Exception:
self.log.warning(
"Couldn't finish Ftrack procedure.", exc_info=True
)
return

finally:
session.close()

def _find_ftrack_task_entity(
self, session, project_name, asset_name, task_name
):
project_entity = session.query(
"Project where full_name is \"{}\"".format(project_name)
).first()
if not project_entity:
self.log.warning(
"Couldn't find project \"{}\" in Ftrack.".format(project_name)
)
return

potential_task_entities = session.query((
"TypedContext where parent.name is \"{}\" and project_id is \"{}\""
).format(asset_name, project_entity["id"])).all()
filtered_entities = []
for _entity in potential_task_entities:
if (
_entity.entity_type.lower() == "task"
and _entity["name"] == task_name
):
filtered_entities.append(_entity)

if not filtered_entities:
self.log.warning((
"Couldn't find task \"{}\" under parent \"{}\" in Ftrack."
).format(task_name, asset_name))
return

if len(filtered_entities) > 1:
self.log.warning((
"Found more than one task \"{}\""
" under parent \"{}\" in Ftrack."
).format(task_name, asset_name))
return

return filtered_entities[0]

def _ftrack_status_change(self, session, entity, project_name):
presets = config.get_presets(project_name)["ftrack"]["ftrack_config"]
statuses = presets.get("status_update")
if not statuses:
return

actual_status = entity["status"]["name"].lower()
already_tested = set()
ent_path = "/".join(
[ent["name"] for ent in entity["link"]]
)
while True:
next_status_name = None
for key, value in statuses.items():
if key in already_tested:
continue
if actual_status in value or "_any_" in value:
if key != "_ignore_":
next_status_name = key
already_tested.add(key)
break
already_tested.add(key)

if next_status_name is None:
break

try:
query = "Status where name is \"{}\"".format(
next_status_name
)
status = session.query(query).one()

entity["status"] = status
session.commit()
self.log.debug("Changing status to \"{}\" <{}>".format(
next_status_name, ent_path
))
break

except Exception:
session.rollback()
msg = (
"Status \"{}\" in presets wasn't found"
" on Ftrack entity type \"{}\""
).format(next_status_name, entity.entity_type)
self.log.warning(msg)

def _start_timer(self, session, entity, _ftrack_api):
self.log.debug("Triggering timer start.")

user_entity = session.query("User where username is \"{}\"".format(
os.environ["FTRACK_API_USER"]
)).first()
if not user_entity:
self.log.warning(
"Couldn't find user with username \"{}\" in Ftrack".format(
os.environ["FTRACK_API_USER"]
)
)
return

source = {
"user": {
"id": user_entity["id"],
"username": user_entity["username"]
}
}
event_data = {
"actionIdentifier": "start.timer",
"selection": [{"entityId": entity["id"], "entityType": "task"}]
}
session.event_hub.publish(
_ftrack_api.event.base.Event(
topic="ftrack.action.launch",
data=event_data,
source=source
),
on_error="ignore"
)
self.log.debug("Timer start triggered successfully.")
2 changes: 1 addition & 1 deletion pype/modules/clockify/launcher_actions/ClockifySync.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def process(self, session, **kwargs):

projects_info = {}
for project in projects_to_sync:
task_types = [task['name'] for task in project['config']['tasks']]
task_types = project['config']['tasks'].keys()
projects_info[project['name']] = task_types

clockify_projects = self.clockapi.get_projects()
Expand Down
27 changes: 3 additions & 24 deletions pype/modules/ftrack/events/event_sync_to_avalon.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,6 @@ def process_removed(self):
if not self.ftrack_removed:
return
ent_infos = self.ftrack_removed
self.log.debug(
"Processing removed entities: {}".format(str(ent_infos))
)
removable_ids = []
recreate_ents = []
removed_names = []
Expand Down Expand Up @@ -881,9 +878,8 @@ def process_removed(self):
self.process_session.commit()

found_idx = None
proj_doc, asset_docs = self._avalon_ents
for idx, asset_doc in enumerate(asset_docs):
if asset_doc["_id"] == avalon_entity["_id"]:
for idx, _entity in enumerate(self._avalon_ents):
if _entity["_id"] == avalon_entity["_id"]:
found_idx = idx
break

Expand All @@ -898,8 +894,7 @@ def process_removed(self):
new_entity_id
)
# Update cached entities
asset_docs[found_idx] = avalon_entity
self._avalon_ents = proj_doc, asset_docs
self._avalon_ents[found_idx] = avalon_entity

if self._avalon_ents_by_id is not None:
mongo_id = avalon_entity["_id"]
Expand Down Expand Up @@ -1263,10 +1258,6 @@ def process_renamed(self):
if not ent_infos:
return

self.log.debug(
"Processing renamed entities: {}".format(str(ent_infos))
)

renamed_tasks = {}
not_found = {}
changeable_queue = queue.Queue()
Expand Down Expand Up @@ -1462,10 +1453,6 @@ def process_added(self):
if not ent_infos:
return

self.log.debug(
"Processing added entities: {}".format(str(ent_infos))
)

cust_attrs, hier_attrs = self.avalon_cust_attrs
entity_type_conf_ids = {}
# Skip if already exit in avalon db or tasks entities
Expand Down Expand Up @@ -1742,10 +1729,6 @@ def process_moved(self):
if not self.ftrack_moved:
return

self.log.debug(
"Processing moved entities: {}".format(str(self.ftrack_moved))
)

ftrack_moved = {k: v for k, v in sorted(
self.ftrack_moved.items(),
key=(lambda line: len(
Expand Down Expand Up @@ -1876,10 +1859,6 @@ def process_updated(self):
if not self.ftrack_updated:
return

self.log.debug(
"Processing updated entities: {}".format(str(self.ftrack_updated))
)

ent_infos = self.ftrack_updated
ftrack_mongo_mapping = {}
not_found_ids = []
Expand Down
9 changes: 1 addition & 8 deletions pype/modules/ftrack/ftrack_server/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,10 @@ def wait(self, duration=None):
else:
try:
self._handle(event)

mongo_id = event["data"].get("_event_mongo_id")
if mongo_id is None:
continue

self.dbcon.update_one(
{"_id": mongo_id},
{"id": event["id"]},
{"$set": {"pype_data.is_processed": True}}
)

except pymongo.errors.AutoReconnect:
self.pypelog.error((
"Mongo server \"{}\" is not responding, exiting."
Expand Down Expand Up @@ -250,7 +244,6 @@ def load_events(self):
}
try:
event = ftrack_api.event.base.Event(**new_event_data)
event["data"]["_event_mongo_id"] = event_data["_id"]
except Exception:
self.logger.exception(L(
'Failed to convert payload into event: {0}',
Expand Down
Loading