Skip to content

Commit

Permalink
Refactor shell to terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
BigRoy committed Sep 2, 2024
1 parent 450294c commit 9890f91
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 32 deletions.
6 changes: 3 additions & 3 deletions client/ayon_applications/hooks/prelaunch_shell_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from ayon_applications import PreLaunchHook, LaunchTypes


class LaunchShellWindowsCreationflags(PreLaunchHook):
"""Avoid running the shell without new console"""
class LaunchTerminalWindowsCreationflags(PreLaunchHook):
"""Avoid running the terminal without new console"""

# Should be as last hook because must change launch arguments to string
order = 1000
app_groups = {"shell"}
app_groups = {"terminal"}
platforms = {"windows"}
launch_types = {LaunchTypes.local}

Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def get_application_qt_icon(application: Application) -> Optional[QtGui.QIcon]:
return QtGui.QIcon()


class DebugShell(LauncherAction):
"""Run any host environment in command line."""
name = "debugshell"
label = "Shell"
class DebugTerminal(LauncherAction):
"""Run any host environment in command line terminal."""
name = "debugterminal"
label = "Terminal"
icon = "terminal"
color = "#e8770e"
order = 10
Expand All @@ -49,22 +49,24 @@ def process(self, selection, **kwargs):
pos = QtGui.QCursor.pos()
application_manager = ApplicationManager()

# Choose shell
shell_applications = self.get_shell_applications(application_manager)
if len(shell_applications) == 0:
# Choose terminal
terminal_applications = self.get_terminal_applications(
application_manager)
if len(terminal_applications) == 0:
raise ValueError(
"Missing application variants for shell application. Please "
"configure 'ayon+settings://applications/applications/shell'"
"Missing application variants for terminal application. "
"Please configure "
"'ayon+settings://applications/applications/terminal'"
)
elif len(shell_applications) == 1:
elif len(terminal_applications) == 1:
# If only one configured shell application, always use that one
shell_app = shell_applications[0]
print("Only one shell application variant is configured. "
f"Defaulting to {shell_app.full_label}")
terminal_app = terminal_applications[0]
print("Only one terminal application variant is configured. "
f"Defaulting to {terminal_app.full_label}")
else:
shell_app = self.choose_app(shell_applications, pos,
show_variant_name_only=True)
if not shell_app:
terminal_app = self.choose_app(
terminal_applications, pos, show_variant_name_only=True)
if not terminal_app:
return

# Get applications
Expand Down Expand Up @@ -93,10 +95,10 @@ def process(self, selection, **kwargs):
if cwd:
print(f"Setting Work Directory: {cwd}")

print(f"Launching shell in environment of {app.full_label}..")
self.launch_app_as_shell(
print(f"Launching terminal in environment of {app.full_label}..")
self.launch_terminal_with_app_context(
application_manager,
shell_app,
terminal_app,
project_name=selection.project_name,
folder_path=selection.folder_path,
task_name=selection.task_name,
Expand Down Expand Up @@ -146,13 +148,14 @@ def get_project_applications(application_manager: ApplicationManager,
return applications

@staticmethod
def get_shell_applications(application_manager) -> list[Application]:
"""Return all configured shell applications"""
# TODO: Maybe filter out shell applications not configured for your
def get_terminal_applications(application_manager) -> list[Application]:
"""Return all configured terminal applications"""
# TODO: Maybe filter out terminal applications not configured for your
# current platform
return list(application_manager.app_groups["shell"].variants.values())
return list(
application_manager.app_groups["terminal"].variants.values())

def launch_app_as_shell(
def launch_terminal_with_app_context(
self,
application_manager: ApplicationManager,
application: Application,
Expand Down
7 changes: 3 additions & 4 deletions server/applications.json
Original file line number Diff line number Diff line change
Expand Up @@ -1278,17 +1278,16 @@
}
]
},
"shell": {
"terminal": {
"enabled": true,
"label": "Shell",
"icon": "{}/app_icons/shell.png",
"label": "Terminal",
"icon": "{}/app_icons/terminal.png",
"host_name": "",
"environment": "{}",
"variants": [
{
"name": "main",
"label": "Main",
"use_python_2": false,
"executables": {
"windows": ["cmd.exe"],
"darwin": ["Terminal.app"],
Expand Down
1 change: 1 addition & 0 deletions server/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"photoshop": "Photoshop",
"resolve": "Resolve",
"substancepainter": "Substance Painter",
"terminal": "Terminal",
"tvpaint": "TVPaint",
"unreal": "Unreal Editor",
"wrap": "Wrap",
Expand Down
3 changes: 2 additions & 1 deletion server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"zbrush",
"equalizer",
"motionbuilder",
"terminal"
}


Expand Down Expand Up @@ -319,7 +320,7 @@ class ApplicationsSettings(BaseSettingsModel):
default_factory=AppGroup, title="3DEqualizer")
motionbuilder: AppGroup = SettingsField(
default_factory=AppGroup, title="Motion Builder")
shell: AppGroup = SettingsField(
terminal: AppGroup = SettingsField(
default_factory=AppGroup,
title="Terminal",
description="Terminal shell application")
Expand Down

0 comments on commit 9890f91

Please sign in to comment.