OpendTect  7.0
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
OD::PythonAccess Class Reference
Inheritance diagram for OD::PythonAccess:
[legend]

Classes

struct  ModuleInfo
 

Public Member Functions

 PythonAccess ()
 
 ~PythonAccess ()
 
void addBasePath (const FilePath &)
 
CNotifier< PythonAccess, const uiRetVal & > & envVerified ()
 
bool execute (const OS::MachineCommand &, bool wait4finish=true) const
 
bool execute (const OS::MachineCommand &, BufferString &stdoutstr, BufferString *stderrstr, uiString *errmsg=nullptr) const
 
bool execute (const OS::MachineCommand &, BufferString &stdoutstr, uiRetVal &, BufferString *stderrstr=nullptr) const
 
bool execute (const OS::MachineCommand &, const OS::CommandExecPars &, int *pid=nullptr, uiString *errmsg=nullptr) const
 
bool execute (const OS::MachineCommand &, const OS::CommandExecPars &, uiRetVal &, int *pid=nullptr, BufferString *stdoutstr=nullptr, BufferString *stderrstr=nullptr) const
 
bool execute (const OS::MachineCommand &, uiRetVal &, bool wait4finish=true, BufferString *stdoutstr=nullptr, BufferString *stderrstr=nullptr) const
 
bool executeScript (const BufferStringSet &, bool wait4finish, uiRetVal &, BufferString *stdoutstr=nullptr, BufferString *stderrstr=nullptr) const
 
bool executeScript (const BufferStringSet &, bool wait4finish=true) const
 
bool executeScript (const BufferStringSet &, BufferString &stdoutstr, uiRetVal &, BufferString *stderrstr=nullptr) const
 
bool executeScript (const char *, bool wait4finish, uiRetVal &, BufferString *stdoutstr=nullptr, BufferString *stderrstr=nullptr) const
 
bool executeScript (const char *, bool wait4finish=true) const
 
bool executeScript (const char *, BufferString &stdoutstr, uiRetVal &, BufferString *stderrstr=nullptr) const
 
const FilePathgetActivateFp () const
 
BufferStringSet getBasePythonPath () const
 
const char * getEnvName () const
 
uiRetVal getModules (ManagedObjectSet< ModuleInfo > &)
 
BufferString getPacmanExecNm () const
 
FilePath getPythonEnvFp () const
 
PythonSource getPythonSource () const
 
BufferStringSet getUserPythonPath () const
 
uiRetVal hasModule (const char *modname, const char *minversion=nullptr) const
 
bool isModuleUsable (const char *nm) const
 
bool isModuleUsable (const char *nm, uiRetVal &) const
 
uiRetVal isUsable (bool force=false, BufferString *stdoutstr=nullptr, BufferString *stderrstr=nullptr) const
 
uiRetVal isUsable (bool force=false, const char *scriptstr=nullptr, const char *scriptexpectedout=nullptr) const
 
BufferString lastOutput (bool stderrout, uiString *launchermsg) const
 
bool openTerminal (const char *cmd, const BufferStringSet *args=nullptr, const char *workdir=nullptr) const
 
bool openTerminal (const char *cmd, uiRetVal &, const BufferStringSet *args=nullptr, const char *workdir=nullptr) const
 
uiString pySummary () const
 
BufferString pyVersion () const
 
uiRetVal setEnvironment (const FilePath *rootfp, const char *envnm)
 
void setForScript (const char *scriptnm, OS::MachineCommand &) const
 
uiRetVal updateModuleInfo (const char *defprog="pip", const char *defarg="list")
 
void updatePythonPath () const
 
uiRetVal verifyEnvironment (const char *piname)
 
- Public Member Functions inherited from CallBacker
 CallBacker ()
 
 CallBacker (const CallBacker &)
 
virtual ~CallBacker ()
 
bool attachCB (const NotifierAccess &, const CallBack &, bool onlyifnew=false) const
 
bool attachCB (const NotifierAccess *notif, const CallBack &cb, bool onlyifnew=false) const
 
void detachAllNotifiers () const
 Call from the destructor of your inherited object. More...
 
void detachCB (const NotifierAccess &, const CallBack &) const
 
void detachCB (const NotifierAccess *notif, const CallBack &cb) const
 
virtual bool isCapsule () const
 
bool isNotifierAttached (const NotifierAccess *) const
 Only for debugging purposes, don't use. More...
 
void stopReceivingNotifications () const
 
virtual CallBackertrueCaller ()
 

Static Public Member Functions

static uiString firewallDesc ()
 
static OD::DataRepType getDataType (const char *)
 
static BufferString getDataTypeStr (OD::DataRepType)
 
static void getPathToInternalEnv (FilePath &, bool userdef)
 
static const char * getPythonActivatorPath ()
 
static void GetPythonEnvBinPath (FilePath &)
 
static FilePath getPythonEnvFp (const FilePath &activatefp)
 
static void GetPythonEnvPath (FilePath &)
 
static PythonSource getPythonSource (const FilePath *envrootfp)
 
static bool hasInternalEnvironment (bool allowuserdef=true)
 
static uiRetVal hasModule (const ObjectSet< ModuleInfo > &, const char *modname, const char *minversion=nullptr)
 
static void initClass ()
 
static bool needCheckRunScript ()
 
static void reReadFWRules (const BufferString &fpstr)
 
static void setPythonActivator (const char *)
 
static const char * sKeyActivatePath ()
 
static const char * sKeyEnviron ()
 
static const char * sKeyPythonPath ()
 
static const char * sKeyPythonSrc ()
 
static BufferString sKeyUseExtPyPath ()
 
static const char * sPythonExecNm (bool v3=false, bool v2=false)
 
static bool validInternalEnvironment (const FilePath &)
 
- Static Public Member Functions inherited from CallBacker
static void createReceiverForCurrentThread ()
 
static void removeReceiverForCurrentThread ()
 

Public Attributes

Notifier< PythonAccessenvChange
 

Private Member Functions

void appToBeStartedCB (CallBacker *)
 
void createFireWallExeList (ManagedObjectSet< FilePath > &)
 
bool doExecute (const OS::MachineCommand &, const OS::CommandExecPars *, int *pid, const FilePath *activatefp, const char *envnm) const
 
uiRetVal doExecute (const OS::MachineCommand &, const OS::CommandExecPars *, int *pid, const FilePath *activatefp, const char *envnm, BufferString *stdoutstr, BufferString *stderrstr) const
 
const BufferStringSetgetBasePythonPath_ () const
 
bool isEnvUsable (const FilePath *pythonenvfp, const char *envnm, const char *scriptstr, const char *scriptexpectedout)
 
bool isEnvUsable (const FilePath *pythonenvfp, const char *envnm, uiRetVal &, BufferString *stdoutstr=nullptr, BufferString *stderrstr=nullptr)
 
bool isUsable_ (bool force, uiRetVal &, BufferString *stdoutstr=nullptr, BufferString *stderrstr=nullptr)
 
bool isUsable_ (bool force=false, const char *scriptstr=nullptr, const char *scriptexpectedout=nullptr)
 
void pluginsLoaded (CallBacker *)
 
bool retrievePythonVersionStr ()
 
void verifyEnvironmentCB (CallBacker *)
 

Static Private Member Functions

static FilePathgetActivateScript (const FilePath &root)
 
static FilePathgetCommand (OS::MachineCommand &, bool background, const FilePath *activatefp, const char *envnm)
 
static bool getCondaEnvFromTxtPath (ObjectSet< FilePath > &)
 
static bool getCondaEnvsFromTxt (BufferStringSet &)
 
static bool getInternalEnvironmentLocation (FilePath &, bool userdef)
 
static FilePath getInternalEnvPath (bool userdef)
 
static OS::CommandLaunchergetLauncher (const OS::MachineCommand &, bool background, const FilePath *activatefp, const char *envnm, FilePath &scriptfp)
 
static void getPIDFromFile (const char *pidfnm, int *pid)
 
static bool getSortedVirtualEnvironmentLoc (ObjectSet< FilePath > &, BufferStringSet &envnms, const BufferString *envnm=nullptr, const FilePath *extroot=nullptr)
 

Private Attributes

FilePathactivatefp_ = nullptr
 
PtrMan< OS::CommandLaunchercl_
 
bool istested_ = false
 
bool isusable_ = false
 
BufferString laststderr_
 
BufferString laststdout_
 
Threads::Lock lock_
 
ManagedObjectSet< ModuleInfomoduleinfos_
 
uiString msg_
 
BufferString pythversion_
 
BufferString virtenvnm_
 

Static Private Attributes

static BufferStringSet pystartpath_
 

Friends

class ::ServiceMgrBase
 
class ::uiPythonSettings
 

Detailed Description

<>

Constructor & Destructor Documentation

◆ PythonAccess()

OD::PythonAccess::PythonAccess ( )

◆ ~PythonAccess()

OD::PythonAccess::~PythonAccess ( )

Member Function Documentation

◆ addBasePath()

void OD::PythonAccess::addBasePath ( const FilePath )

◆ appToBeStartedCB()

void OD::PythonAccess::appToBeStartedCB ( CallBacker )
private

◆ createFireWallExeList()

void OD::PythonAccess::createFireWallExeList ( ManagedObjectSet< FilePath > &  )
private

◆ doExecute() [1/2]

bool OD::PythonAccess::doExecute ( const OS::MachineCommand ,
const OS::CommandExecPars ,
int *  pid,
const FilePath activatefp,
const char *  envnm 
) const
private

◆ doExecute() [2/2]

uiRetVal OD::PythonAccess::doExecute ( const OS::MachineCommand ,
const OS::CommandExecPars ,
int *  pid,
const FilePath activatefp,
const char *  envnm,
BufferString stdoutstr,
BufferString stderrstr 
) const
private

◆ envVerified()

CNotifier<PythonAccess,const uiRetVal&>& OD::PythonAccess::envVerified ( )

◆ execute() [1/6]

bool OD::PythonAccess::execute ( const OS::MachineCommand ,
bool  wait4finish = true 
) const

◆ execute() [2/6]

bool OD::PythonAccess::execute ( const OS::MachineCommand ,
BufferString stdoutstr,
BufferString stderrstr,
uiString errmsg = nullptr 
) const

◆ execute() [3/6]

bool OD::PythonAccess::execute ( const OS::MachineCommand ,
BufferString stdoutstr,
uiRetVal ,
BufferString stderrstr = nullptr 
) const

◆ execute() [4/6]

bool OD::PythonAccess::execute ( const OS::MachineCommand ,
const OS::CommandExecPars ,
int *  pid = nullptr,
uiString errmsg = nullptr 
) const

◆ execute() [5/6]

bool OD::PythonAccess::execute ( const OS::MachineCommand ,
const OS::CommandExecPars ,
uiRetVal ,
int *  pid = nullptr,
BufferString stdoutstr = nullptr,
BufferString stderrstr = nullptr 
) const

◆ execute() [6/6]

bool OD::PythonAccess::execute ( const OS::MachineCommand ,
uiRetVal ,
bool  wait4finish = true,
BufferString stdoutstr = nullptr,
BufferString stderrstr = nullptr 
) const

◆ executeScript() [1/6]

bool OD::PythonAccess::executeScript ( const BufferStringSet ,
bool  wait4finish,
uiRetVal ,
BufferString stdoutstr = nullptr,
BufferString stderrstr = nullptr 
) const

◆ executeScript() [2/6]

bool OD::PythonAccess::executeScript ( const BufferStringSet ,
bool  wait4finish = true 
) const

◆ executeScript() [3/6]

bool OD::PythonAccess::executeScript ( const BufferStringSet ,
BufferString stdoutstr,
uiRetVal ,
BufferString stderrstr = nullptr 
) const

◆ executeScript() [4/6]

bool OD::PythonAccess::executeScript ( const char *  ,
bool  wait4finish,
uiRetVal ,
BufferString stdoutstr = nullptr,
BufferString stderrstr = nullptr 
) const

◆ executeScript() [5/6]

bool OD::PythonAccess::executeScript ( const char *  ,
bool  wait4finish = true 
) const

◆ executeScript() [6/6]

bool OD::PythonAccess::executeScript ( const char *  ,
BufferString stdoutstr,
uiRetVal ,
BufferString stderrstr = nullptr 
) const

◆ firewallDesc()

static uiString OD::PythonAccess::firewallDesc ( )
static

◆ getActivateFp()

const FilePath* OD::PythonAccess::getActivateFp ( ) const
inline

◆ getActivateScript()

static FilePath* OD::PythonAccess::getActivateScript ( const FilePath root)
staticprivate

◆ getBasePythonPath()

BufferStringSet OD::PythonAccess::getBasePythonPath ( ) const

◆ getBasePythonPath_()

const BufferStringSet& OD::PythonAccess::getBasePythonPath_ ( ) const
private

◆ getCommand()

static FilePath* OD::PythonAccess::getCommand ( OS::MachineCommand ,
bool  background,
const FilePath activatefp,
const char *  envnm 
)
staticprivate

◆ getCondaEnvFromTxtPath()

static bool OD::PythonAccess::getCondaEnvFromTxtPath ( ObjectSet< FilePath > &  )
staticprivate

◆ getCondaEnvsFromTxt()

static bool OD::PythonAccess::getCondaEnvsFromTxt ( BufferStringSet )
staticprivate

◆ getDataType()

static OD::DataRepType OD::PythonAccess::getDataType ( const char *  )
static

◆ getDataTypeStr()

static BufferString OD::PythonAccess::getDataTypeStr ( OD::DataRepType  )
static

◆ getEnvName()

const char* OD::PythonAccess::getEnvName ( ) const
inline

◆ getInternalEnvironmentLocation()

static bool OD::PythonAccess::getInternalEnvironmentLocation ( FilePath ,
bool  userdef 
)
staticprivate

◆ getInternalEnvPath()

static FilePath OD::PythonAccess::getInternalEnvPath ( bool  userdef)
staticprivate

◆ getLauncher()

static OS::CommandLauncher* OD::PythonAccess::getLauncher ( const OS::MachineCommand ,
bool  background,
const FilePath activatefp,
const char *  envnm,
FilePath scriptfp 
)
staticprivate

◆ getModules()

uiRetVal OD::PythonAccess::getModules ( ManagedObjectSet< ModuleInfo > &  )

◆ getPacmanExecNm()

BufferString OD::PythonAccess::getPacmanExecNm ( ) const

◆ getPathToInternalEnv()

static void OD::PythonAccess::getPathToInternalEnv ( FilePath ,
bool  userdef 
)
static

◆ getPIDFromFile()

static void OD::PythonAccess::getPIDFromFile ( const char *  pidfnm,
int *  pid 
)
staticprivate

◆ getPythonActivatorPath()

static const char* OD::PythonAccess::getPythonActivatorPath ( )
static

◆ GetPythonEnvBinPath()

static void OD::PythonAccess::GetPythonEnvBinPath ( FilePath )
static

◆ getPythonEnvFp() [1/2]

FilePath OD::PythonAccess::getPythonEnvFp ( ) const

◆ getPythonEnvFp() [2/2]

static FilePath OD::PythonAccess::getPythonEnvFp ( const FilePath activatefp)
static

◆ GetPythonEnvPath()

static void OD::PythonAccess::GetPythonEnvPath ( FilePath )
static

◆ getPythonSource() [1/2]

PythonSource OD::PythonAccess::getPythonSource ( ) const

◆ getPythonSource() [2/2]

static PythonSource OD::PythonAccess::getPythonSource ( const FilePath envrootfp)
static

◆ getSortedVirtualEnvironmentLoc()

static bool OD::PythonAccess::getSortedVirtualEnvironmentLoc ( ObjectSet< FilePath > &  ,
BufferStringSet envnms,
const BufferString envnm = nullptr,
const FilePath extroot = nullptr 
)
staticprivate

◆ getUserPythonPath()

BufferStringSet OD::PythonAccess::getUserPythonPath ( ) const

◆ hasInternalEnvironment()

static bool OD::PythonAccess::hasInternalEnvironment ( bool  allowuserdef = true)
static

◆ hasModule() [1/2]

uiRetVal OD::PythonAccess::hasModule ( const char *  modname,
const char *  minversion = nullptr 
) const

◆ hasModule() [2/2]

static uiRetVal OD::PythonAccess::hasModule ( const ObjectSet< ModuleInfo > &  ,
const char *  modname,
const char *  minversion = nullptr 
)
static

◆ initClass()

static void OD::PythonAccess::initClass ( )
static

◆ isEnvUsable() [1/2]

bool OD::PythonAccess::isEnvUsable ( const FilePath pythonenvfp,
const char *  envnm,
const char *  scriptstr,
const char *  scriptexpectedout 
)
private

◆ isEnvUsable() [2/2]

bool OD::PythonAccess::isEnvUsable ( const FilePath pythonenvfp,
const char *  envnm,
uiRetVal ,
BufferString stdoutstr = nullptr,
BufferString stderrstr = nullptr 
)
private

◆ isModuleUsable() [1/2]

bool OD::PythonAccess::isModuleUsable ( const char *  nm) const

◆ isModuleUsable() [2/2]

bool OD::PythonAccess::isModuleUsable ( const char *  nm,
uiRetVal  
) const

◆ isUsable() [1/2]

uiRetVal OD::PythonAccess::isUsable ( bool  force = false,
BufferString stdoutstr = nullptr,
BufferString stderrstr = nullptr 
) const

◆ isUsable() [2/2]

uiRetVal OD::PythonAccess::isUsable ( bool  force = false,
const char *  scriptstr = nullptr,
const char *  scriptexpectedout = nullptr 
) const

◆ isUsable_() [1/2]

bool OD::PythonAccess::isUsable_ ( bool  force,
uiRetVal ,
BufferString stdoutstr = nullptr,
BufferString stderrstr = nullptr 
)
private

◆ isUsable_() [2/2]

bool OD::PythonAccess::isUsable_ ( bool  force = false,
const char *  scriptstr = nullptr,
const char *  scriptexpectedout = nullptr 
)
private

◆ lastOutput()

BufferString OD::PythonAccess::lastOutput ( bool  stderrout,
uiString launchermsg 
) const

◆ needCheckRunScript()

static bool OD::PythonAccess::needCheckRunScript ( )
static

◆ openTerminal() [1/2]

bool OD::PythonAccess::openTerminal ( const char *  cmd,
const BufferStringSet args = nullptr,
const char *  workdir = nullptr 
) const

◆ openTerminal() [2/2]

bool OD::PythonAccess::openTerminal ( const char *  cmd,
uiRetVal ,
const BufferStringSet args = nullptr,
const char *  workdir = nullptr 
) const

◆ pluginsLoaded()

void OD::PythonAccess::pluginsLoaded ( CallBacker )
private

◆ pySummary()

uiString OD::PythonAccess::pySummary ( ) const

◆ pyVersion()

BufferString OD::PythonAccess::pyVersion ( ) const

◆ reReadFWRules()

static void OD::PythonAccess::reReadFWRules ( const BufferString fpstr)
static

◆ retrievePythonVersionStr()

bool OD::PythonAccess::retrievePythonVersionStr ( )
private

◆ setEnvironment()

uiRetVal OD::PythonAccess::setEnvironment ( const FilePath rootfp,
const char *  envnm 
)

◆ setForScript()

void OD::PythonAccess::setForScript ( const char *  scriptnm,
OS::MachineCommand  
) const

◆ setPythonActivator()

static void OD::PythonAccess::setPythonActivator ( const char *  )
static

◆ sKeyActivatePath()

static const char* OD::PythonAccess::sKeyActivatePath ( )
static

◆ sKeyEnviron()

static const char* OD::PythonAccess::sKeyEnviron ( )
static

◆ sKeyPythonPath()

static const char* OD::PythonAccess::sKeyPythonPath ( )
static

◆ sKeyPythonSrc()

static const char* OD::PythonAccess::sKeyPythonSrc ( )
static

◆ sKeyUseExtPyPath()

static BufferString OD::PythonAccess::sKeyUseExtPyPath ( )
inlinestatic

◆ sPythonExecNm()

static const char* OD::PythonAccess::sPythonExecNm ( bool  v3 = false,
bool  v2 = false 
)
static

◆ updateModuleInfo()

uiRetVal OD::PythonAccess::updateModuleInfo ( const char *  defprog = "pip",
const char *  defarg = "list" 
)

◆ updatePythonPath()

void OD::PythonAccess::updatePythonPath ( ) const

◆ validInternalEnvironment()

static bool OD::PythonAccess::validInternalEnvironment ( const FilePath )
static

◆ verifyEnvironment()

uiRetVal OD::PythonAccess::verifyEnvironment ( const char *  piname)

◆ verifyEnvironmentCB()

void OD::PythonAccess::verifyEnvironmentCB ( CallBacker )
private

Friends And Related Function Documentation

◆ ::ServiceMgrBase

friend class ::ServiceMgrBase
friend

◆ ::uiPythonSettings

friend class ::uiPythonSettings
friend

Member Data Documentation

◆ activatefp_

FilePath* OD::PythonAccess::activatefp_ = nullptr
private

◆ cl_

PtrMan<OS::CommandLauncher> OD::PythonAccess::cl_
mutableprivate

◆ envChange

Notifier<PythonAccess> OD::PythonAccess::envChange

◆ istested_

bool OD::PythonAccess::istested_ = false
private

◆ isusable_

bool OD::PythonAccess::isusable_ = false
private

◆ laststderr_

BufferString OD::PythonAccess::laststderr_
mutableprivate

◆ laststdout_

BufferString OD::PythonAccess::laststdout_
mutableprivate

◆ lock_

Threads::Lock OD::PythonAccess::lock_
mutableprivate

◆ moduleinfos_

ManagedObjectSet<ModuleInfo> OD::PythonAccess::moduleinfos_
private

◆ msg_

uiString OD::PythonAccess::msg_
mutableprivate

◆ pystartpath_

BufferStringSet OD::PythonAccess::pystartpath_
staticprivate

◆ pythversion_

BufferString OD::PythonAccess::pythversion_
private

◆ virtenvnm_

BufferString OD::PythonAccess::virtenvnm_
private

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2024