Bearsampp
2026.7.11
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-2024 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
{
20
const
ROOT_CFG_VERSION
=
'pythonVersion'
;
21
22
const
LOCAL_CFG_EXE
=
'pythonExe'
;
23
const
LOCAL_CFG_IDLE_EXE
=
'pythonIdleExe'
;
24
25
private
$exe
;
26
private
$idleExe
;
27
34
public
function
__construct
(
$id
,
$type
) {
35
Log::initClass
($this);
36
$this->
reload
(
$id
,
$type
);
37
}
38
45
public
function
reload
(
$id
=
null
,
$type
=
null
) {
46
global
$bearsamppConfig
,
$bearsamppLang
;
47
Log::reloadClass
($this);
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
Log::info
($this->name .
' is not enabled!'
);
60
return
;
61
}
62
if
(!is_dir($this->currentPath)) {
63
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->currentPath));
64
}
65
if
(!is_dir($this->symlinkPath)) {
66
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->symlinkPath));
67
return
;
68
}
69
if
(!is_file($this->bearsamppConf)) {
70
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_CONF_NOT_FOUND
), $this->name .
' '
. $this->version, $this->bearsamppConf));
71
}
72
if
(!is_file($this->exe)) {
73
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_EXE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->exe));
74
}
75
if
(!is_file($this->idleExe)) {
76
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_EXE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->idleExe));
77
}
78
}
79
85
public
function
setVersion
(
$version
) {
86
global
$bearsamppConfig
;
87
$this->version =
$version
;
88
$bearsamppConfig
->replace(self::ROOT_CFG_VERSION,
$version
);
89
$this->
reload
();
90
}
91
97
public
function
getExe
() {
98
return
$this->exe
;
99
}
100
106
public
function
getIdleExe
() {
107
return
$this->idleExe
;
108
}
109
}
110
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
Lang\ERROR_EXE_NOT_FOUND
const ERROR_EXE_NOT_FOUND
Definition
class.lang.php:154
Lang\ERROR_CONF_NOT_FOUND
const ERROR_CONF_NOT_FOUND
Definition
class.lang.php:153
Lang\PYTHON
const PYTHON
Definition
class.lang.php:149
Lang\ERROR_FILE_NOT_FOUND
const ERROR_FILE_NOT_FOUND
Definition
class.lang.php:155
Log\info
static info($data, $file=null)
Definition
class.log.php:627
Log\reloadClass
static reloadClass($classInstance)
Definition
class.log.php:670
Log\error
static error($data, $file=null)
Definition
class.log.php:650
Log\initClass
static initClass($classInstance)
Definition
class.log.php:660
Module
Definition
class.module.php:15
Module\$version
$version
Definition
class.module.php:24
Module\$type
$type
Definition
class.module.php:20
Module\$id
$id
Definition
class.module.php:21
ToolPython
Definition
class.tool.python.php:19
ToolPython\getExe
getExe()
Definition
class.tool.python.php:97
ToolPython\LOCAL_CFG_EXE
const LOCAL_CFG_EXE
Definition
class.tool.python.php:22
ToolPython\LOCAL_CFG_IDLE_EXE
const LOCAL_CFG_IDLE_EXE
Definition
class.tool.python.php:23
ToolPython\setVersion
setVersion($version)
Definition
class.tool.python.php:85
ToolPython\$idleExe
$idleExe
Definition
class.tool.python.php:26
ToolPython\reload
reload($id=null, $type=null)
Definition
class.tool.python.php:45
ToolPython\getIdleExe
getIdleExe()
Definition
class.tool.python.php:106
ToolPython\ROOT_CFG_VERSION
const ROOT_CFG_VERSION
Definition
class.tool.python.php:20
ToolPython\__construct
__construct($id, $type)
Definition
class.tool.python.php:34
ToolPython\$exe
$exe
Definition
class.tool.python.php:25
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:41
sandbox
core
classes
tools
class.tool.python.php
Generated by
1.17.0