mirror of
https://github.com/moodle/moodle.git
synced 2025-07-19 05:11:33 +02:00
MDL-64994 analytics: Improve the Python package version check
Use the new method to check that the installed Python package has high enough yet still API-compatible version.
This commit is contained in:
@@ -78,7 +78,9 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso
|
||||
// Execute it sending the standard error to $output.
|
||||
$result = exec($cmd . ' 2>&1', $output, $exitcode);
|
||||
|
||||
if ($result === self::REQUIRED_PIP_PACKAGE_VERSION) {
|
||||
$vercheck = self::check_pip_package_version($result);
|
||||
|
||||
if ($vercheck === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,8 +89,17 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$a = (object)array('installed' => $result, 'required' => self::REQUIRED_PIP_PACKAGE_VERSION);
|
||||
return get_string('packageinstalledshouldbe', 'mlbackend_python', $a);
|
||||
$a = [
|
||||
'installed' => $result,
|
||||
'required' => self::REQUIRED_PIP_PACKAGE_VERSION,
|
||||
];
|
||||
|
||||
if ($vercheck < 0) {
|
||||
return get_string('packageinstalledshouldbe', 'mlbackend_python', $a);
|
||||
|
||||
} else if ($vercheck > 0) {
|
||||
return get_string('packageinstalledtoohigh', 'mlbackend_python', $a);
|
||||
}
|
||||
}
|
||||
|
||||
return get_string('pythonpackagenotinstalled', 'mlbackend_python', $cmd);
|
||||
|
Reference in New Issue
Block a user