Bearsampp 2025.8.29
Loading...
Searching...
No Matches
ToolPython Class Reference
Inheritance 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 ()
 getCurrentPath ()
 getId ()
 getName ()
 getRelease ()
 getRootPath ()
 getSymlinkPath ()
 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
const BUNDLE_RELEASE = 'bundleRelease'

Private Attributes

 $exe
 $idleExe

Additional Inherited Members

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
 $currentPath
 $enable
 $name
 $release = 'N/A'
 $rootPath
 $symlinkPath
 $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 34 of file class.tool.python.php.

34 {
35 Util::logInitClass($this);
36 $this->reload($id, $type);
37 }
reload($id=null, $type=null)
static logInitClass($classInstance)

References Module\$id, Module\$type, Util\logInitClass(), and reload().

Member Function Documentation

◆ getExe()

getExe ( )

Gets the path to the Python executable.

Returns
string The path to the Python executable.

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

97 {
98 return $this->exe;
99 }

References $exe.

◆ getIdleExe()

getIdleExe ( )

Gets the path to the Python IDLE executable.

Returns
string The path to the Python IDLE executable.

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

106 {
107 return $this->idleExe;
108 }

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 45 of file class.tool.python.php.

45 {
48
49 $this->name = $bearsamppLang->getValue(Lang::PYTHON);
50 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
51 parent::reload($id, $type);
52
53 if ($this->bearsamppConfRaw !== false) {
54 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
55 $this->idleExe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_IDLE_EXE];
56 }
57
58 if (!$this->enable) {
59 Util::logInfo($this->name . ' is not enabled!');
60 return;
61 }
62 if (!is_dir($this->currentPath)) {
63 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
64 }
65 if (!is_dir($this->symlinkPath)) {
66 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
67 return;
68 }
69 if (!is_file($this->bearsamppConf)) {
70 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
71 }
72 if (!is_file($this->exe)) {
73 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
74 }
75 if (!is_file($this->idleExe)) {
76 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->idleExe));
77 }
78 }
global $bearsamppLang
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const PYTHON
const ERROR_FILE_NOT_FOUND
static logError($data, $file=null)
static logInfo($data, $file=null)
static logReloadClass($classInstance)
global $bearsamppConfig
Definition homepage.php:27

References $bearsamppConfig, $bearsamppLang, Module\$id, Module\$type, Lang\ERROR_CONF_NOT_FOUND, Lang\ERROR_EXE_NOT_FOUND, Lang\ERROR_FILE_NOT_FOUND, Util\logError(), Util\logInfo(), Util\logReloadClass(), and Lang\PYTHON.

Referenced by __construct(), and setVersion().

◆ 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 85 of file class.tool.python.php.

85 {
86 global $bearsamppConfig;
87 $this->version = $version;
88 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
89 $this->reload();
90 }

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

Field Documentation

◆ $exe

$exe
private

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

Referenced by getExe().

◆ $idleExe

$idleExe
private

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

Referenced by getIdleExe().

◆ LOCAL_CFG_EXE

const LOCAL_CFG_EXE = 'pythonExe'

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

◆ LOCAL_CFG_IDLE_EXE

const LOCAL_CFG_IDLE_EXE = 'pythonIdleExe'

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

◆ ROOT_CFG_VERSION

const ROOT_CFG_VERSION = 'pythonVersion'

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


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