From 0461ddd4924bb52766772b5333f8a626599d2390 Mon Sep 17 00:00:00 2001 From: gdd Date: Mon, 11 Jun 2012 14:03:35 +0000 Subject: [PATCH] Update demo plugin (shell session): in case xterm is not installed, check for gnome-terminal --- src/SalomeApp/pluginsdemo/salome_plugins.py | 33 +++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/SalomeApp/pluginsdemo/salome_plugins.py b/src/SalomeApp/pluginsdemo/salome_plugins.py index 57a94fef0..edb361b5f 100755 --- a/src/SalomeApp/pluginsdemo/salome_plugins.py +++ b/src/SalomeApp/pluginsdemo/salome_plugins.py @@ -21,11 +21,14 @@ import salome_pluginsmanager -DEMO_IS_ACTIVATED=True -try: - import geompy, smesh -except: - DEMO_IS_ACTIVATED=False +DEMO_IS_ACTIVATED = False + +if DEMO_IS_ACTIVATED: + # Check that GEOM and SMESH modules are present + try: + import geompy, smesh + except: + DEMO_IS_ACTIVATED = False if DEMO_IS_ACTIVATED: # ------------------------------------------------------------------------- @@ -254,11 +257,23 @@ if DEMO_IS_ACTIVATED: # ------------------------------------------------------------------------- # Example 3: run a shell session in a xterm to get a SALOME python console def runSalomeShellSession(context): - import os + import os,subprocess import salome_version - ld_library_path= os.getenv("LD_LIBRARY_PATH") - command = 'xterm -T "SALOME %s - Shell session" -e env LD_LIBRARY_PATH=%s %s/runSession&'%(salome_version.getVersion(full=True),ld_library_path,os.environ['KERNEL_ROOT_DIR']) - os.system(command) + version = salome_version.getVersion(full=True) + kernel_appli_dir = os.environ['KERNEL_ROOT_DIR'] + command = "" + if os.path.exists("/usr/bin/xterm"): + command = 'xterm -T "SALOME %s - Shell session" -e %s/runSession &'%(version,kernel_appli_dir) + elif os.path.exists("/usr/bin/gnome-terminal"): + command = 'gnome-terminal -t "SALOME %s - Shell session" -e %s/runSession &'%(version,kernel_appli_dir) + else: + print "Neither xterm nor gnome-terminal is installed." + + if command is not "": + try: + subprocess.check_call(command, shell = True) + except Exception, e: + print "Error: ",e salome_pluginsmanager.AddFunction('SALOME shell session', -- 2.39.2