]> SALOME platform Git repositories - tools/sat_salome.git/commitdiff
Salome HOME
PPGP: back port shell fix
authorNabil Ghodbane <nabil.ghodbane@cea.fr>
Thu, 10 Feb 2022 09:37:50 +0000 (10:37 +0100)
committerNabil Ghodbane <nabil.ghodbane@cea.fr>
Thu, 10 Feb 2022 09:37:56 +0000 (10:37 +0100)
products/GUI.pyconf
products/patches/GUI-V9_2_0-visualCode.patch [new file with mode: 0644]

index 9307bfe28949b073aeff2048af6d3fdf12262ad3..cabd1ce194fe56465447915db1c586af5a43d891 100644 (file)
@@ -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 (file)
index 0000000..6bc7b4c
--- /dev/null
@@ -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)