Bearsampp
2026.9.23
Toggle main menu visibility
Loading...
Searching...
No Matches
class.tool.python.php
Go to the documentation of this file.
1
<?php
2
/*
3
*
4
* * Copyright (c) 2021-2026 Bearsampp
5
* * License: GNU General Public License version 3 or later; see LICENSE.txt
6
* * Website: https://bearsampp.com
7
* * Github: https://github.com/Bearsampp
8
*
9
*/
10
18
class
ToolPython
extends
Module
19
{
23
const
ROOT_CFG_VERSION
=
'pythonVersion'
;
24
28
const
LOCAL_CFG_EXE
=
'pythonExe'
;
32
const
LOCAL_CFG_IDLE_EXE
=
'pythonIdleExe'
;
33
37
private
$exe
;
41
private
$idleExe
;
42
49
public
function
__construct
(
$id
,
$type
)
50
{
51
Log::initClass
($this);
52
$this->
reload
(
$id
,
$type
);
53
}
54
61
public
function
reload
(
$id
=
null
,
$type
=
null
)
62
{
63
global
$bearsamppConfig
,
$bearsamppLang
;
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
}
98
104
public
function
setVersion
(
$version
)
105
{
106
global
$bearsamppConfig
;
107
$this->version =
$version
;
108
$bearsamppConfig
->replace(self::ROOT_CFG_VERSION,
$version
);
109
$this->
reload
();
110
}
111
117
public
function
getExe
()
118
{
119
return
$this->exe
;
120
}
121
127
public
function
getIdleExe
()
128
{
129
return
$this->idleExe
;
130
}
131
}
132
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
Lang\ERROR_EXE_NOT_FOUND
const ERROR_EXE_NOT_FOUND
Definition
class.lang.php:155
Lang\ERROR_CONF_NOT_FOUND
const ERROR_CONF_NOT_FOUND
Definition
class.lang.php:154
Lang\PYTHON
const PYTHON
Definition
class.lang.php:150
Lang\ERROR_FILE_NOT_FOUND
const ERROR_FILE_NOT_FOUND
Definition
class.lang.php:156
Log\info
static info($data, $file=null)
Definition
class.log.php:737
Log\reloadClass
static reloadClass($classInstance)
Definition
class.log.php:805
Log\error
static error($data, $file=null)
Definition
class.log.php:760
Log\initClass
static initClass($classInstance)
Definition
class.log.php:784
Module
Definition
class.module.php:15
Module\$version
$version
Definition
class.module.php:29
Module\$type
$type
Definition
class.module.php:20
Module\$id
$id
Definition
class.module.php:23
ToolPython
Definition
class.tool.python.php:19
ToolPython\getExe
getExe()
Definition
class.tool.python.php:117
ToolPython\LOCAL_CFG_EXE
const LOCAL_CFG_EXE
Definition
class.tool.python.php:28
ToolPython\LOCAL_CFG_IDLE_EXE
const LOCAL_CFG_IDLE_EXE
Definition
class.tool.python.php:32
ToolPython\setVersion
setVersion($version)
Definition
class.tool.python.php:104
ToolPython\$idleExe
$idleExe
Definition
class.tool.python.php:41
ToolPython\reload
reload($id=null, $type=null)
Definition
class.tool.python.php:61
ToolPython\getIdleExe
getIdleExe()
Definition
class.tool.python.php:127
ToolPython\ROOT_CFG_VERSION
const ROOT_CFG_VERSION
Definition
class.tool.python.php:23
ToolPython\__construct
__construct($id, $type)
Definition
class.tool.python.php:49
ToolPython\$exe
$exe
Definition
class.tool.python.php:37
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:46
sandbox
core
classes
tools
class.tool.python.php
Generated by
1.17.0