From edbbe8da05405f38da8e227283fe3b80f9845974 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 27 Apr 2020 16:25:09 +0300 Subject: [PATCH] bos #19032 [CEA] Debugging a python script with VS Code --- src/SalomeApp/pluginsdemo/salome_plugins.py | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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) -- 2.39.2