From: abn Date: Mon, 13 Oct 2014 13:02:57 +0000 (+0200) Subject: Clearly identify when we execute Python code from SALOME embedded console. X-Git-Tag: V7_5_0b1~27^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fabn%2Frearch;p=modules%2Fparavis.git Clearly identify when we execute Python code from SALOME embedded console. --- diff --git a/src/PV_SWIG/no_wrap/pvsimple.py b/src/PV_SWIG/no_wrap/pvsimple.py index 87e0daba..470c8353 100644 --- a/src/PV_SWIG/no_wrap/pvsimple.py +++ b/src/PV_SWIG/no_wrap/pvsimple.py @@ -31,9 +31,19 @@ def __my_log(msg): def __getFromGUI(): """ Identify if we are running inside SALOME's embedded interpreter. + @return a value strictly greater than 0 if we are in SALOME's embedded interpreter + @return 2 if we are in Salome embedded Python console. """ import salome_iapp - return salome_iapp.IN_SALOME_GUI + ret = 0 + if salome_iapp.IN_SALOME_GUI: + ret += 1 + try: + if __IN_SALOME_GUI_CONSOLE: # only defined if we are in SALOME's embedded console (not only GUI) + ret += 1 + except NameError: + pass + return ret def ShowParaviewView(): """ @@ -88,7 +98,9 @@ def SalomeConnectToPVServer(): raise e pass -SalomeConnectToPVServer() +if __getFromGUI() < 1: + # Only if not in GUI (otherwise the createView will do the connection) + SalomeConnectToPVServer() del SalomeConnectToPVServer # Forward namespace of simple into current pvsimple: