From fade460c6534a587b7f61fa4ebb308d04769c030 Mon Sep 17 00:00:00 2001 From: Nabil Ghodbane Date: Thu, 10 Feb 2022 10:37:50 +0100 Subject: [PATCH] PPGP: back port shell fix --- products/GUI.pyconf | 5 ++ products/patches/GUI-V9_2_0-visualCode.patch | 54 ++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 products/patches/GUI-V9_2_0-visualCode.patch diff --git a/products/GUI.pyconf b/products/GUI.pyconf index 9307bfe..cabd1ce 100644 --- a/products/GUI.pyconf +++ b/products/GUI.pyconf @@ -163,6 +163,11 @@ version_V9_3_0_win : patches : ['GUI-V9_3_0-LightApplication_windows.patch'] } +version_9_2_0_PPGP: +{ + patches: ['GUI-V9_2_0-visualCode.patch'] +} + # OP 19/04/2018 Add section for SALOME 7.8.0 to 8.4.0 due to new dependencies in SALOME 8.5.0 version_7_8_0_to_8_4_0 : { diff --git a/products/patches/GUI-V9_2_0-visualCode.patch b/products/patches/GUI-V9_2_0-visualCode.patch new file mode 100644 index 0000000..6bc7b4c --- /dev/null +++ b/products/patches/GUI-V9_2_0-visualCode.patch @@ -0,0 +1,54 @@ +diff --git a/src/SalomeApp/pluginsdemo/salome_plugins.py b/src/SalomeApp/pluginsdemo/salome_plugins.py +index 451b944e4..f8fbda4a9 100755 +--- a/src/SalomeApp/pluginsdemo/salome_plugins.py ++++ b/src/SalomeApp/pluginsdemo/salome_plugins.py +@@ -261,17 +261,16 @@ if DEMO_IS_ACTIVATED: + def runSalomeShellSession(context): + import os,subprocess + import salome_version ++ from PyQt5.Qt import QMessageBox ++ from SalomePyQt import SalomePyQt + version = salome_version.getVersion(full=True) + kernel_appli_dir = os.environ['KERNEL_ROOT_DIR'] + command = "" +- if os.path.exists("/usr/bin/gnome-terminal"): +- command = 'gnome-terminal -t "SALOME %s - Shell session" -e "%s/salome shell" &'%(version,kernel_appli_dir) +- elif os.path.exists("/usr/bin/konsole"): +- command = 'PATH="/usr/bin:/sbin:/bin" LD_LIBRARY_PATH="" konsole -e "%s/salome shell" &'%(kernel_appli_dir) +- elif os.path.exists("/usr/bin/xterm"): +- command = 'xterm -T "SALOME %s - Shell session" -e "%s/salome shell" &'%(version,kernel_appli_dir) ++ if os.path.exists("/usr/bin/xterm"): ++ command = 'xterm -T "SALOME %s - Shell session" -e "%s" shell &' % (version, command) + else: +- print("Neither xterm nor gnome-terminal nor konsole is installed.") ++ QMessageBox.critical(SalomePyQt.getDesktop(), "Error", "xterm does not seem to be installed") ++ return + + if command is not "": + try: +@@ -283,3 +282,25 @@ def runSalomeShellSession(context): + salome_pluginsmanager.AddFunction('SALOME shell session', + 'Execute a SALOME shell session in an external xterm', + runSalomeShellSession) ++# Example 4: run CODE ++def runCodeEditor(context): ++ import os,subprocess ++ import salome_version ++ import shutil ++ from PyQt5.Qt import QMessageBox ++ from SalomePyQt import SalomePyQt ++ try: ++ command = shutil.which('code') ++ if command: ++ try: ++ subprocess.check_call(command, shell = True) ++ except Exception as e: ++ print("Error: ",e) ++ else: ++ QMessageBox.critical(SalomePyQt.getDesktop(), "Error", "Visual Studio Code executable is not found") ++ except Exception as e: ++ print("Error: ",e) ++ ++salome_pluginsmanager.AddFunction('Launch VS Code (debugger)', ++ 'Execute Visual Studio Code', ++ runCodeEditor) -- 2.39.2