OpendTect  6.6
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 &)
 
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 &, const OS::CommandExecPars &, int *pid=nullptr, uiString *errmsg=nullptr) const
 
bool executeScript (const BufferStringSet &, bool wait4finish=true) const
 
bool executeScript (const char *, bool wait4finish=true) const
 
const BufferStringSetgetBasePythonPath () const
 
uiRetVal getModules (ManagedObjectSet< ModuleInfo > &)
 
BufferString getPacmanExecNm () const
 
BufferStringSet getUserPythonPath () const
 
uiRetVal hasModule (const char *modname, const char *minversion=nullptr) const
 
bool isModuleUsable (const char *nm) 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
 
bool openTerminal (const char *cmd, const BufferStringSet *args=nullptr, const char *workdir=nullptr) const
 
uiString pySummary () const
 
BufferString pyVersion () const
 
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
 

Static Public Member Functions

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 void GetPythonEnvPath (FilePath &)
 
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 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 createFireWallExeList (ManagedObjectSet< FilePath > &)
 
bool doExecute (const OS::MachineCommand &, const OS::CommandExecPars *, int *pid, const FilePath *activatefp, const char *envnm) const
 
void envChangeCB (CallBacker *)
 
bool isEnvUsable (const FilePath *pythonenvfp, const char *envnm, const char *scriptstr, const char *scriptexpectedout)
 
bool isUsable_ (bool force=false, const char *scriptstr=nullptr, const char *scriptexpectedout=nullptr)
 
bool retrievePythonVersionStr ()
 

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_
 
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 )

◆ createFireWallExeList()

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

◆ doExecute()

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

◆ envChangeCB()

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

◆ execute() [1/3]

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

◆ execute() [2/3]

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

◆ execute() [3/3]

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

◆ executeScript() [1/2]

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

◆ executeScript() [2/2]

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

◆ getActivateScript()

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

◆ getBasePythonPath()

const BufferStringSet& OD::PythonAccess::getBasePythonPath ( ) const

◆ 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

◆ 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

◆ GetPythonEnvPath()

static void OD::PythonAccess::GetPythonEnvPath ( FilePath )
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()

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

◆ isModuleUsable()

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

◆ isUsable()

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

◆ isUsable_()

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

◆ openTerminal() [2/2]

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

◆ pySummary()

uiString OD::PythonAccess::pySummary ( ) const

◆ pyVersion()

BufferString OD::PythonAccess::pyVersion ( ) const

◆ retrievePythonVersionStr()

bool OD::PythonAccess::retrievePythonVersionStr ( )
private

◆ 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)

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

◆ 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-2022