diff --git a/openpype/modules/ftrack/ftrack_module.py b/openpype/modules/ftrack/ftrack_module.py index f99e189082..048e5ebfb1 100644 --- a/openpype/modules/ftrack/ftrack_module.py +++ b/openpype/modules/ftrack/ftrack_module.py @@ -42,6 +42,9 @@ class FtrackModule( self.ftrack_url = ftrack_url + ftrack_open_as_app = ftrack_settings["ftrack_open_as_app"] + self.ftrack_open_as_app = ftrack_open_as_app + current_dir = os.path.dirname(os.path.abspath(__file__)) low_platform = platform.system().lower() diff --git a/openpype/modules/ftrack/tray/ftrack_tray.py b/openpype/modules/ftrack/tray/ftrack_tray.py index 7ac994e967..065528dcff 100644 --- a/openpype/modules/ftrack/tray/ftrack_tray.py +++ b/openpype/modules/ftrack/tray/ftrack_tray.py @@ -1,9 +1,14 @@ +from hashlib import new +from operator import pos import os import time import datetime import threading import platform import subprocess +import posixpath, ntpath +import webbrowser +import shutil from Qt import QtCore, QtWidgets, QtGui import ftrack_api @@ -14,7 +19,6 @@ from ..ftrack_module import FTRACK_MODULE_DIR from . import login_dialog from openpype.api import Logger, resources -from openpype.settings import get_system_settings log = Logger().get_logger("FtrackModule") @@ -52,29 +56,42 @@ class FtrackTrayWrapper: self.widget_login.raise_() def show_ftrack_browser(self): - cur_os = platform.system().lower() - settings = get_system_settings()["modules"]["ftrack"] - browser_paths = settings["ftrack_browser_path"][cur_os] - browser_args = settings["ftrack_browser_arguments"][cur_os] - browser_args.append(self.module.ftrack_url) - path = "" - for p in browser_paths: - if os.path.exists(p): - path = p - log.debug(f"Found valid executable at path: {p}") - break + env_pf64 = os.environ['ProgramW6432'].replace( + ntpath.sep, posixpath.sep) + env_pf32 = os.environ['ProgramFiles(x86)'].replace( + ntpath.sep, posixpath.sep) + env_loc = os.environ['LocalAppData'].replace( + ntpath.sep, posixpath.sep) + chromium_paths_win = [ + f"{env_pf64}/Google/Chrome/Application/chrome.exe", + f"{env_pf32}/Google/Chrome/Application/chrome.exe", + f"{env_loc}/Google/Chrome/Application/chrome.exe", + f"{env_pf32}/Microsoft/Edge/Application/msedge.exe" + ] + cur_os = cur_os = platform.system().lower() + if cur_os == "windows": + is_chromium = False + for p in chromium_paths_win: + if os.path.exists(p): + is_chromium = True + chromium_path = p + break + if is_chromium and self.module.ftrack_open_as_app: + webbrowser.get(f"{chromium_path} %s").open_new( + f"--app={self.module.ftrack_url}") else: - log.warning(f"Path: {p} is not valid, please \ - doublecheck your settings!") - if path == "": - log.warning("Found no valid executables to launch \ - Ftrack with. Feature will not work as expected!") - return - args = " ".join(str(item) for item in browser_args).replace("= ", "=") - log.debug(f"Computed arguments: {args}") - cmd = f"{path} {args}" - log.debug(f"Opening Ftrack Browser...") - subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + webbrowser.get(using="windows-default").open_new( + self.module.ftrack_url) + + else: + if self.module.ftrack_open_as_app: + try: + webbrowser.get(using='chrome').open_new( + f"--app={self.module.ftrack_url}") + except webbrowser.Error: + webbrowser.open_new(self.module.ftrack_url) + else: + webbrowser.open_new(self.module.ftrack_url) def validate(self): validation = False diff --git a/openpype/settings/defaults/system_settings/modules.json b/openpype/settings/defaults/system_settings/modules.json index aaf01b1631..6d09652bb9 100644 --- a/openpype/settings/defaults/system_settings/modules.json +++ b/openpype/settings/defaults/system_settings/modules.json @@ -15,20 +15,7 @@ "ftrack": { "enabled": false, "ftrack_server": "", - "ftrack_browser_path": { - "windows": [ - "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" - ], - "darwin": [], - "linux": [] - }, - "ftrack_browser_arguments": { - "windows": [ - "--app=" - ], - "darwin": [], - "linux": [] - }, + "ftrack_open_as_app": false, "ftrack_actions_path": { "windows": [], "darwin": [], diff --git a/openpype/settings/entities/schemas/system_schema/module_settings/schema_ftrack.json b/openpype/settings/entities/schemas/system_schema/module_settings/schema_ftrack.json index 268c5479fe..570d856cf8 100644 --- a/openpype/settings/entities/schemas/system_schema/module_settings/schema_ftrack.json +++ b/openpype/settings/entities/schemas/system_schema/module_settings/schema_ftrack.json @@ -17,45 +17,9 @@ "label": "Server" }, { - "type": "splitter" - }, - { - "type": "path", - "key": "ftrack_browser_path", - "label": "Browser Path", - "use_label_wrap": true, - "multipath": true, - "multiplatform": true - }, - { - "type": "dict", - "key": "ftrack_browser_arguments", - "label": "Browser Arguments", - "use_label_wrap": true, - "children": [ - { - "type": "label", - "label": "Any arguent which is used to open Ftrack URL (as in \"app=\" for chrome) needs to be placed last in the list!" - }, - { - "key": "windows", - "label": "Windows", - "type": "list", - "object_type": "text" - }, - { - "key": "darwin", - "label": "MacOS", - "type": "list", - "object_type": "text" - }, - { - "key": "linux", - "label": "Linux", - "type": "list", - "object_type": "text" - } - ] + "type": "boolean", + "key": "ftrack_open_as_app", + "label": "Open in app mode" }, { "type": "splitter" diff --git a/tools/run_ftrack_eventserver.ps1 b/tools/run_ftrack_eventserver.ps1 deleted file mode 100644 index 9c22f3d88e..0000000000 --- a/tools/run_ftrack_eventserver.ps1 +++ /dev/null @@ -1,39 +0,0 @@ -<# -.SYNOPSIS - Helper script to start OpenPype Ftrack EventServer without relying on built executables. - -.DESCRIPTION - - -.EXAMPLE - -PS> .\run_eventserver.ps1 - -#> -$script_dir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent -$openpype_root = (Get-Item $script_dir).parent.FullName - -$env:_INSIDE_OPENPYPE_TOOL = "1" -$env:OPENPYPE_DEBUG = "1" -# $env:OPENPYPE_MONGO = "mongodb://127.0.0.1:27017" - -# make sure Poetry is in PATH -if (-not (Test-Path 'env:POETRY_HOME')) { - $env:POETRY_HOME = "$openpype_root\.poetry" -} -$env:PATH = "$($env:PATH);$($env:POETRY_HOME)\bin" - -Set-Location -Path $openpype_root - -Write-Host ">>> " -NoNewline -ForegroundColor Green -Write-Host "Reading Poetry ... " -NoNewline -if (-not (Test-Path -PathType Container -Path "$($env:POETRY_HOME)\bin")) { - Write-Host "NOT FOUND" -ForegroundColor Yellow - Write-Host "*** " -NoNewline -ForegroundColor Yellow - Write-Host "We need to install Poetry create virtual env first ..." - & "$openpype_root\tools\create_env.ps1" -} else { - Write-Host "OK" -ForegroundColor Green -} - -& "$($env:POETRY_HOME)\bin\poetry" run python "$($openpype_root)\start.py" eventserver \ No newline at end of file diff --git a/tools/run_ftrack_eventserver.sh b/tools/run_ftrack_eventserver.sh deleted file mode 100644 index 97daa14c2d..0000000000 --- a/tools/run_ftrack_eventserver.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env bash - -art () { - cat <<-EOF - - . . .. . .. - _oOOP3OPP3Op_. . - .PPpo~· ·· ~2p. ·· ···· · · - ·Ppo · .pPO3Op.· · O:· · · · - .3Pp · oP3'· 'P33· · 4 ·· · · · ·· · · · - ·~OP 3PO· .Op3 : · ·· _____ _____ _____ - ·P3O · oP3oP3O3P' · · · · / /·/ /·/ / - O3:· O3p~ · ·:· · ·/____/·/____/ /____/ - 'P · 3p3· oP3~· ·.P:· · · ·· · · ·· · · · - · ': · Po' ·Opo'· .3O· . o[ by Pype Club ]]]==- - - · · - · '_ .. · . _OP3·· · ·https://openpype.io·· · - ~P3·OPPPO3OP~ · ·· · - · ' '· · ·· · · · ·· · - -EOF -} - -# Colors for terminal - -RST='\033[0m' # Text Reset - -# Regular Colors -Black='\033[0;30m' # Black -Red='\033[0;31m' # Red -Green='\033[0;32m' # Green -Yellow='\033[0;33m' # Yellow -Blue='\033[0;34m' # Blue -Purple='\033[0;35m' # Purple -Cyan='\033[0;36m' # Cyan -White='\033[0;37m' # White - -# Bold -BBlack='\033[1;30m' # Black -BRed='\033[1;31m' # Red -BGreen='\033[1;32m' # Green -BYellow='\033[1;33m' # Yellow -BBlue='\033[1;34m' # Blue -BPurple='\033[1;35m' # Purple -BCyan='\033[1;36m' # Cyan -BWhite='\033[1;37m' # White - -# Bold High Intensity -BIBlack='\033[1;90m' # Black -BIRed='\033[1;91m' # Red -BIGreen='\033[1;92m' # Green -BIYellow='\033[1;93m' # Yellow -BIBlue='\033[1;94m' # Blue -BIPurple='\033[1;95m' # Purple -BICyan='\033[1;96m' # Cyan -BIWhite='\033[1;97m' # White - - -############################################################################## -# Return absolute path -# Globals: -# None -# Arguments: -# Path to resolve -# Returns: -# None -############################################################################### -realpath () { - echo $(cd $(dirname "$1"); pwd)/$(basename "$1") -} - -# Main -main () { - echo -e "${BGreen}" - art - echo -e "${RST}" - - # Directories - openpype_root=$(realpath $(dirname $(dirname "${BASH_SOURCE[0]}"))) - - if [[ -z $POETRY_HOME ]]; then - export POETRY_HOME="$openpype_root/.poetry" - fi - - echo -e "${BIGreen}>>>${RST} Reading Poetry ... \c" - if [ -f "$POETRY_HOME/bin/poetry" ]; then - echo -e "${BIGreen}OK${RST}" - else - echo -e "${BIYellow}NOT FOUND${RST}" - echo -e "${BIYellow}***${RST} We need to install Poetry and virtual env ..." - . "$openpype_root/tools/create_env.sh" || { echo -e "${BIRed}!!!${RST} Poetry installation failed"; return; } - fi - - pushd "$openpype_root" > /dev/null || return > /dev/null - - echo -e "${BIGreen}>>>${RST} Running Ftrack Eventserver ..." - "$POETRY_HOME/bin/poetry" run python $openpype_root/start.py eventserver -} - -main