]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
bos #19032 [CEA] Debugging a python script with VS Code
authorvsr <vsr@opencascade.com>
Mon, 27 Apr 2020 13:25:09 +0000 (16:25 +0300)
committervsr <vsr@opencascade.com>
Mon, 27 Apr 2020 13:25:09 +0000 (16:25 +0300)
src/SalomeApp/pluginsdemo/salome_plugins.py

index 38d8f12c7854e060b2746507cc48f6a5bf306dbd..c9f0eb7fdb0c9ceabc45633663ec92d516b48fbd 100644 (file)
@@ -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)