Bearsampp 2026.9.23
Loading...
Searching...
No Matches
ToolPython Class Reference
Inheritance diagram for ToolPython:
Collaboration diagram for ToolPython:

Public Member Functions

 __construct ($id, $type)
 getExe ()
 getIdleExe ()
 reload ($id=null, $type=null)
 setVersion ($version)
Public Member Functions inherited from Module
 __toString ()
 getId ()
 getName ()
 getRelease ()
 getType ()
 getVersion ()
 getVersionList ()
 isEnable ()
 update ($sub=0, $showWindow=false)

Data Fields

const LOCAL_CFG_EXE = 'pythonExe'
const LOCAL_CFG_IDLE_EXE = 'pythonIdleExe'
const ROOT_CFG_VERSION = 'pythonVersion'
Data Fields inherited from Module
 $currentPath
 $rootPath
 $symlinkPath

Private Attributes

 $exe
 $idleExe

Additional Inherited Members

Static Public Member Functions inherited from Module
static clearMemoryCache ()
static invalidateConfigCacheForPath ($sourcePath)
Protected Member Functions inherited from Module
 __construct ()
 replace ($key, $value)
 replaceAll ($params)
 updateConfig ($version=null, $sub=0, $showWindow=false)
Protected Attributes inherited from Module
 $bearsamppConf
 $bearsamppConfRaw
 $enable
 $name
 $release = 'N/A'
 $version

Detailed Description

Class ToolPython

This class represents a Python tool module in the Bearsampp application. It extends the abstract Module class and provides specific functionalities for managing Python executables and configurations.

Definition at line 18 of file class.tool.python.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $id,
$type )

Constructor for the ToolPython class.

Parameters
string$idThe ID of the module.
string$typeThe type of the module.

Definition at line 49 of file class.tool.python.php.

50 {
51 Log::initClass($this);
52 $this->reload($id, $type);
53 }
static initClass($classInstance)
reload($id=null, $type=null)

References Module\$id, Module\$type, Log\initClass(), and reload().

Here is the call graph for this function:

Member Function Documentation

◆ getExe()

getExe ( )

Gets the path to the Python executable.

Returns
string The path to the Python executable.

Definition at line 117 of file class.tool.python.php.

118 {
119 return $this->exe;
120 }

References $exe.

◆ getIdleExe()

getIdleExe ( )

Gets the path to the Python IDLE executable.

Returns
string The path to the Python IDLE executable.

Definition at line 127 of file class.tool.python.php.

128 {
129 return $this->idleExe;
130 }

References $idleExe.

◆ reload()

reload ( $id = null,
$type = null )

Reloads the module configuration based on the provided ID and type.

Parameters
string | null$idThe ID of the module. If null, the current ID is used.
string | null$typeThe type of the module. If null, the current type is used.

Reimplemented from Module.

Definition at line 61 of file class.tool.python.php.

62 {
64 Log::reloadClass($this);
65
66 $this->name = $bearsamppLang->getValue(Lang::PYTHON);
67 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
68 parent::reload($id, $type);
69
70 if ($this->bearsamppConfRaw !== false) {
71 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
72 $this->idleExe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_IDLE_EXE];
73 }
74
75 if (!$this->enable) {
76 Log::info($this->name . ' is not enabled!');
77
78 return;
79 }
80 if (!is_dir($this->currentPath)) {
81 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
82 }
83 if (!is_dir($this->symlinkPath)) {
84 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
85
86 return;
87 }
88 if (!is_file($this->bearsamppConf)) {
89 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
90 }
91 if (!is_file($this->exe)) {
92 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
93 }
94 if (!is_file($this->idleExe)) {
95 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->idleExe));
96 }
97 }
global $bearsamppLang
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const PYTHON
const ERROR_FILE_NOT_FOUND
static info($data, $file=null)
static reloadClass($classInstance)
static error($data, $file=null)
global $bearsamppConfig
Definition homepage.php:46

References $bearsamppConfig, $bearsamppLang, Module\$id, Module\$type, Log\error(), Lang\ERROR_CONF_NOT_FOUND, Lang\ERROR_EXE_NOT_FOUND, Lang\ERROR_FILE_NOT_FOUND, Log\info(), Lang\PYTHON, and Log\reloadClass().

Referenced by __construct(), and setVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVersion()

setVersion ( $version)

Sets the version of the Python module and reloads the configuration.

Parameters
string$versionThe version to set.

Reimplemented from Module.

Definition at line 104 of file class.tool.python.php.

105 {
106 global $bearsamppConfig;
107 $this->version = $version;
108 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
109 $this->reload();
110 }

References $bearsamppConfig, Module\$version, and reload().

Here is the call graph for this function:

Field Documentation

◆ $exe

$exe
private

Definition at line 37 of file class.tool.python.php.

Referenced by getExe().

◆ $idleExe

$idleExe
private

Definition at line 41 of file class.tool.python.php.

Referenced by getIdleExe().

◆ LOCAL_CFG_EXE

const LOCAL_CFG_EXE = 'pythonExe'

Configuration key for the Python executable in the local configuration.

Definition at line 28 of file class.tool.python.php.

◆ LOCAL_CFG_IDLE_EXE

const LOCAL_CFG_IDLE_EXE = 'pythonIdleExe'

Configuration key for the Python IDLE executable in the local configuration.

Definition at line 32 of file class.tool.python.php.

◆ ROOT_CFG_VERSION

const ROOT_CFG_VERSION = 'pythonVersion'

Configuration key for the Python version in the root configuration.

Definition at line 23 of file class.tool.python.php.


The documentation for this class was generated from the following file: