From: vsr Date: Mon, 27 Apr 2020 13:25:09 +0000 (+0300) Subject: bos #19032 [CEA] Debugging a python script with VS Code X-Git-Tag: V9_5_0b1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=edbbe8da05405f38da8e227283fe3b80f9845974;p=modules%2Fgui.git bos #19032 [CEA] Debugging a python script with VS Code --- diff --git a/src/SalomeApp/pluginsdemo/salome_plugins.py b/src/SalomeApp/pluginsdemo/salome_plugins.py index 38d8f12c7..c9f0eb7fd 100644 --- a/src/SalomeApp/pluginsdemo/salome_plugins.py +++ b/src/SalomeApp/pluginsdemo/salome_plugins.py @@ -279,7 +279,30 @@ def runSalomeShellSession(context): except Exception as e: print("Error: ",e) - 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)