From 98a64c50242f28f42028a09f6e9d27b7ff3eaaa6 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 8 Feb 2020 14:38:08 -0600 Subject: [PATCH] Add `apache.get_php_version()` convenience function --- rattail_fabric2/apache.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rattail_fabric2/apache.py b/rattail_fabric2/apache.py index 9f6ee3f..d7c96d4 100644 --- a/rattail_fabric2/apache.py +++ b/rattail_fabric2/apache.py @@ -67,6 +67,17 @@ def get_version(c): return float(match.group(1)) +def get_php_version(c): + """ + Fetch the version of PHP running on the target system + """ + result = c.sudo('php --version') + if not result.failed: + match = re.match(r'^PHP (\d+\.\d+)\.\d+-', result.stdout) + if match: + return float(match.group(1)) + + def enable_mod(c, *names): """ Enable the given Apache modules