2024.8.23
Loading...
Searching...
No Matches
ToolPython Class Reference
+ Inheritance diagram for ToolPython:
+ Collaboration diagram for ToolPython:

Public Member Functions

 __construct ($id, $type)
 
 getCpExe ()
 
 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_CP_EXE = 'pythonCpExe'
 
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

 $cpExe
 
 $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 17 of file class.tool.python.php.

Constructor & Destructor Documentation

◆ __construct()

ToolPython::__construct ( $id,
$type )

Constructor for the ToolPython class.

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

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

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

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

Member Function Documentation

◆ getCpExe()

ToolPython::getCpExe ( )

Gets the path to the Python CP executable.

Returns
string The path to the Python CP executable.

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

111 {
112 return $this->cpExe;
113 }

References $cpExe.

◆ getExe()

ToolPython::getExe ( )

Gets the path to the Python executable.

Returns
string The path to the Python executable.

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

102 {
103 return $this->exe;
104 }

References $exe.

◆ getIdleExe()

ToolPython::getIdleExe ( )

Gets the path to the Python IDLE executable.

Returns
string The path to the Python IDLE executable.

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

120 {
121 return $this->idleExe;
122 }

References $idleExe.

◆ reload()

ToolPython::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 46 of file class.tool.python.php.

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

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

Referenced by __construct(), and setVersion().

+ Here is the caller graph for this function:

◆ setVersion()

ToolPython::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 90 of file class.tool.python.php.

90 {
91 global $bearsamppConfig;
92 $this->version = $version;
93 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
94 $this->reload();
95 }

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

Field Documentation

◆ $cpExe

ToolPython::$cpExe
private

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

Referenced by getCpExe().

◆ $exe

ToolPython::$exe
private

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

Referenced by getExe().

◆ $idleExe

ToolPython::$idleExe
private

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

Referenced by getIdleExe().

◆ LOCAL_CFG_CP_EXE

const ToolPython::LOCAL_CFG_CP_EXE = 'pythonCpExe'

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

Referenced by reload().

◆ LOCAL_CFG_EXE

const ToolPython::LOCAL_CFG_EXE = 'pythonExe'

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

Referenced by reload().

◆ LOCAL_CFG_IDLE_EXE

const ToolPython::LOCAL_CFG_IDLE_EXE = 'pythonIdleExe'

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

Referenced by reload().

◆ ROOT_CFG_VERSION

const ToolPython::ROOT_CFG_VERSION = 'pythonVersion'

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


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