Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make debug and show behaviour consistent for all tools #513

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master' into implement-512
  • Loading branch information
jasperges committed Feb 24, 2020
commit 8f003c21ff945a7a621888e2773b169b1dcc8a09
8 changes: 2 additions & 6 deletions avalon/fusion/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def ls():
yield container


def install(config):
def install():
"""Install Fusion-specific functionality of avalon-core.

This function is called automatically on calling `api.install(fusion)`.
Expand All @@ -76,14 +76,10 @@ def install(config):
logger.setLevel(logging.DEBUG)


def uninstall(config):
def uninstall():
"""Uninstall Fusion-specific functionality of avalon-core.

This function is called automatically on calling `api.uninstall()`.

Args:
config: configuration module

"""

pyblish.api.deregister_host("fusion")
Expand Down
7 changes: 3 additions & 4 deletions avalon/fusion/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ def current_file():
return current_filepath


def work_root():
from avalon import Session
def work_root(session):

work_dir = Session["AVALON_WORKDIR"]
scene_dir = Session.get("AVALON_SCENEDIR")
work_dir = session["AVALON_WORKDIR"]
scene_dir = session.get("AVALON_SCENEDIR")
if scene_dir:
return os.path.join(work_dir, scene_dir)
else:
Expand Down
8 changes: 2 additions & 6 deletions avalon/houdini/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
IS_HEADLESS = not hasattr(hou, "ui")


def install(config):
def install():
"""Setup integration
Register plug-ins and integrate into the host

Expand All @@ -40,14 +40,10 @@ def install(config):
self._has_been_setup = True


def uninstall(config):
def uninstall():
"""Uninstall Houdini-specific functionality of avalon-core.

This function is called automatically on calling `api.uninstall()`.

Args:
config: configuration module

"""

pyblish.api.deregister_host("hython")
Expand Down
7 changes: 3 additions & 4 deletions avalon/houdini/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ def current_file():
return current_filepath


def work_root():
from avalon import Session
def work_root(session):

work_dir = Session["AVALON_WORKDIR"]
scene_dir = Session.get("AVALON_SCENEDIR")
work_dir = session["AVALON_WORKDIR"]
scene_dir = session.get("AVALON_SCENEDIR")
if scene_dir:
return os.path.join(work_dir, scene_dir)
else:
Expand Down
8 changes: 8 additions & 0 deletions avalon/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ def _from_environment():
# Optional path to scenes directory (see Work Files API)
("AVALON_SCENEDIR", None),

# Optional hierarchy for the current Asset. This can be referenced
# as `{hierarchy}` in your file templates.
# This will be (re-)computed when you switch the context to another
# asset. It is computed by checking asset['data']['parents'] and
# joining those together with `os.path.sep`.
# E.g.: ['ep101', 'scn0010'] -> 'ep101/scn0010'.
("AVALON_HIERARCHY", None),

# Name of current Config
# TODO(marcus): Establish a suitable default config
("AVALON_CONFIG", "no_config"),
Expand Down
31 changes: 14 additions & 17 deletions avalon/maya/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
IS_HEADLESS = not hasattr(cmds, "about") or cmds.about(batch=True)


def install(config):
def install():
"""Install Maya-specific functionality of avalon-core.

This function is called automatically on calling `api.install(maya)`.
Expand Down Expand Up @@ -90,7 +90,7 @@ def get_main_window():
return self._parent


def uninstall(config):
def uninstall():
"""Uninstall Maya-specific functionality of avalon-core.

This function is called automatically on calling `api.uninstall()`.
Expand All @@ -110,8 +110,7 @@ def _install_menu():
creator,
loader,
publish,
sceneinventory,
contextmanager
sceneinventory
)

from . import interactive
Expand All @@ -125,19 +124,17 @@ def deferred():
parent="MayaWindow")

# Create context menu
context_label = "{}, {}".format(api.Session["AVALON_ASSET"],
api.Session["AVALON_TASK"])
context_menu = cmds.menuItem("currentContext",
label=context_label,
parent=self._menu,
subMenu=True)

cmds.menuItem("setCurrentContext",
label="Edit Context..",
parent=context_menu,
command=lambda *args: contextmanager.show(
parent=self._parent
))
context_label = "{}, {}".format(
api.Session["AVALON_ASSET"],
api.Session["AVALON_TASK"]
)

cmds.menuItem(
"currentContext",
label=context_label,
parent=self._menu,
enable=False
)

cmds.setParent("..", menu=True)

Expand Down
37 changes: 30 additions & 7 deletions avalon/maya/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,33 @@ def current_file():
return current_filepath


def work_root():

# Base the root on the current Maya workspace.
return os.path.join(
cmds.workspace(query=True, rootDirectory=True),
cmds.workspace(fileRuleEntry="scene")
)
def work_root(session):
work_dir = session["AVALON_WORKDIR"]
scene_dir = None

# Query scene file rule from workspace.mel if it exists in WORKDIR
# We are parsing the workspace.mel manually as opposed to temporarily
# setting the Workspace in Maya in a context manager since Maya had a
# tendency to crash on frequently changing the workspace when this
# function was called many times as one scrolled through Work Files assets.
workspace_mel = os.path.join(work_dir, "workspace.mel")
if os.path.exists(workspace_mel):
scene_rule = 'workspace -fr "scene" '
# We need to use builtins as `open` is overridden by the workio API
open_file = __builtins__["open"]
with open_file(workspace_mel, "r") as f:
for line in f:
if line.strip().startswith(scene_rule):
# remainder == "rule";
remainder = line[len(scene_rule):]
# scene_dir == rule
scene_dir = remainder.split('"')[1]
else:
# We can't query a workspace that does not exist
# so we return similar to what we do in other hosts.
scene_dir = session.get("AVALON_SCENEDIR")

if scene_dir:
return os.path.join(work_dir, scene_dir)
else:
return work_dir
15 changes: 6 additions & 9 deletions avalon/nuke/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def ls():
yield container


def install(config):
def install():
"""Install Nuke-specific functionality of avalon-core.

This is where you install menus and register families, data
Expand Down Expand Up @@ -241,7 +241,7 @@ def get_main_window():
return self._parent


def uninstall(config):
def uninstall():
"""Uninstall all that was previously installed

This is where you undo everything that was done in `install()`.
Expand All @@ -266,8 +266,7 @@ def _install_menu():
publish,
workfiles,
loader,
sceneinventory,
contextmanager
sceneinventory
)

# Create menu
Expand All @@ -277,11 +276,9 @@ def _install_menu():
label = "{0}, {1}".format(
api.Session["AVALON_ASSET"], api.Session["AVALON_TASK"]
)
context_menu = menu.addMenu(label)
context_menu.addCommand("Set Context",
lambda: contextmanager.show(
parent=get_main_window())
)
context_action = menu.addCommand(label)
context_action.setEnabled(False)

menu.addSeparator()
menu.addCommand("Create...",
lambda: creator.show(parent=get_main_window()))
Expand Down
13 changes: 10 additions & 3 deletions avalon/nuke/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def current_file():
return os.path.normpath(current_file).replace("\\", "/")


def work_root():
from avalon import Session
return os.path.normpath(Session["AVALON_WORKDIR"]).replace("\\", "/")
def work_root(session):

work_dir = session["AVALON_WORKDIR"]
scene_dir = session.get("AVALON_SCENEDIR")
if scene_dir:
path = os.path.join(work_dir, scene_dir)
else:
path = work_dir

return os.path.normpath(path).replace("\\", "/")
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.