From d2f04b315ae6834554b4cc6085dcb43726bcda5e Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 12 Dec 2018 18:28:41 -0600 Subject: [PATCH] Add `apache.get_php_version()` convenience function --- rattail_fabric/apache.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rattail_fabric/apache.py b/rattail_fabric/apache.py index b9bf70a..8061271 100644 --- a/rattail_fabric/apache.py +++ b/rattail_fabric/apache.py @@ -51,6 +51,17 @@ def get_version(): return float(match.group(1)) +def get_php_version(): + """ + Fetch the version of PHP running on the target system + """ + result = sudo('php --version') + if result.succeeded: + match = re.match(r'^PHP (\d+\.\d+)\.\d+-', result) + if match: + return float(match.group(1)) + + def install_wsgi(python_home=None, python3=False): """ Install the mod_wsgi Apache module, with optional ``WSGIPythonHome`` value.