Salome HOME
spns #32926: backport KERNEL & CONFIGURATION fixes on more recent platforms to ensure...
[tools/sat_salome.git] / products / patches / GUI-V9_2_0-visualCode.patch
1 diff --git a/src/SalomeApp/pluginsdemo/salome_plugins.py b/src/SalomeApp/pluginsdemo/salome_plugins.py
2 index 451b944e4..f8fbda4a9 100755
3 --- a/src/SalomeApp/pluginsdemo/salome_plugins.py
4 +++ b/src/SalomeApp/pluginsdemo/salome_plugins.py
5 @@ -261,17 +261,16 @@ if DEMO_IS_ACTIVATED:
6  def runSalomeShellSession(context):
7      import os,subprocess
8      import salome_version
9 +    from PyQt5.Qt import QMessageBox
10 +    from SalomePyQt import SalomePyQt
11      version = salome_version.getVersion(full=True)
12      kernel_appli_dir = os.environ['KERNEL_ROOT_DIR']
13      command = ""
14 -    if os.path.exists("/usr/bin/gnome-terminal"):
15 -      command = 'gnome-terminal -t "SALOME %s - Shell session" -e "%s/salome shell" &'%(version,kernel_appli_dir)
16 -    elif os.path.exists("/usr/bin/konsole"):
17 -      command = 'PATH="/usr/bin:/sbin:/bin" LD_LIBRARY_PATH="" konsole -e "%s/salome shell" &'%(kernel_appli_dir)
18 -    elif os.path.exists("/usr/bin/xterm"):
19 -      command = 'xterm -T "SALOME %s - Shell session" -e "%s/salome shell" &'%(version,kernel_appli_dir)
20 +    if os.path.exists("/usr/bin/xterm"):
21 +      command = 'xterm -T "SALOME %s - Shell session" -e "%s" shell &' % (version, command)
22      else:
23 -      print("Neither xterm nor gnome-terminal nor konsole is installed.")
24 +      QMessageBox.critical(SalomePyQt.getDesktop(), "Error", "xterm does not seem to be installed")
25 +      return
26  
27      if command is not "":
28        try:
29 @@ -283,3 +282,25 @@ def runSalomeShellSession(context):
30  salome_pluginsmanager.AddFunction('SALOME shell session',
31                                    'Execute a SALOME shell session in an external xterm',
32                                    runSalomeShellSession)
33 +# Example 4: run CODE
34 +def runCodeEditor(context):
35 +    import os,subprocess
36 +    import salome_version
37 +    import shutil
38 +    from PyQt5.Qt import QMessageBox
39 +    from SalomePyQt import SalomePyQt
40 +    try:
41 +      command = shutil.which('code')
42 +      if command:
43 +        try:
44 +          subprocess.check_call(command, shell = True)
45 +        except Exception as e:
46 +          print("Error: ",e)
47 +      else:
48 +        QMessageBox.critical(SalomePyQt.getDesktop(), "Error", "Visual Studio Code executable is not found")
49 +    except Exception as e:
50 +      print("Error: ",e)
51 +
52 +salome_pluginsmanager.AddFunction('Launch VS Code (debugger)',
53 +                                  'Execute Visual Studio Code',
54 +                                  runCodeEditor)