chg: [fix] Some fixed to the python virtualenv tweaks

pull/3762/head
Steve Clement 2018-09-28 14:54:59 +02:00
parent 61de2c49d7
commit 05e0c412ef
2 changed files with 31 additions and 4 deletions

View File

@ -84,7 +84,8 @@ class PubSubTool
public function checkIfPythonLibInstalled()
{
$result = trim(shell_exec('python3 ' . APP . 'files' . DS . 'scripts' . DS . 'mispzmq' . DS . 'mispzmqtest.py'));
$my_server = ClassRegistry::init('Server');
$result = trim(shell_exec($my_server->getPythonVersion() . ' ' . APP . 'files' . DS . 'scripts' . DS . 'mispzmq' . DS . 'mispzmqtest.py'));
if ($result === "OK") {
return true;
}
@ -94,9 +95,10 @@ class PubSubTool
private function __setupPubServer()
{
App::uses('File', 'Utility');
$my_server = ClassRegistry::init('Server');
$settings = $this->__getSetSettings();
if ($this->checkIfRunning() === false) {
shell_exec('python3 ' . APP . 'files' . DS . 'scripts' . DS . 'mispzmq' . DS . 'mispzmq.py > ' . APP . 'tmp' . DS . 'logs' . DS . 'mispzmq.log 2> ' . APP . 'tmp' . DS . 'logs' . DS . 'mispzmq.error.log &');
shell_exec($my_server->getPythonVersion() . ' ' . APP . 'files' . DS . 'scripts' . DS . 'mispzmq' . DS . 'mispzmq.py > ' . APP . 'tmp' . DS . 'logs' . DS . 'mispzmq.log 2> ' . APP . 'tmp' . DS . 'logs' . DS . 'mispzmq.error.log &');
}
return $settings;
}

View File

@ -168,10 +168,11 @@ class Server extends AppModel
'python_bin' => array(
'level' => 1,
'description' => __('It is highly recommended to install all the python dependencies in a virtualenv. The recommended location is: %s/venv', ROOT),
'value' => ROOT . '/venv/bin/python', # GUI display purpose only.
'value' => false,
'errorMessage' => '',
'null' => false,
'test' => 'testForEmpty',
'test' => 'testForBinExec',
'beforeHook' => 'beforeHookBinExec',
'type' => 'string',
),
'disable_auto_logout' => array(
@ -2676,6 +2677,30 @@ class Server extends AppModel
return 'Invalid characters in the path.';
}
public function beforeHookBinExec($setting, $value)
{
return $this->testForBinExec($value);
}
public function testForBinExec($value)
{
$finfo = finfo_open(FILEINFO_MIME_TYPE);
if ($value === '') {
return true;
}
if (is_executable($value)) {
if (finfo_file($finfo, $value) == "application/x-executable") {
finfo_close($finfo);
return true;
} else {
return 'Binary file not executable.';
}
}
else {
return false;
}
}
public function testForWritableDir($value)
{
if (!is_dir($value)) {