Permalink
Browse files

WIP: Prerequisites, PHP modules and MySQL.

git-svn-id: svn://cherokee-project.com/wizards2@6784 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
1 parent c52a392 commit a3663708bb81301abc21e56ae438603c9d1eff31 @alobbs alobbs committed Aug 2, 2011
View
@@ -129,4 +129,9 @@ def main():
if __name__ == "__main__":
- main()
+ try:
+ main()
+ except KeyboardInterrupt:
+ print
+ print "Exiting now.."
+ os._exit(1)
View
@@ -29,6 +29,7 @@
import vserver
import Wizard2
import Wizard2_GUI
+import popen
from util import *
@@ -67,6 +68,8 @@ def Check_Prerequisites (self):
errors = self.php.Check_Prerequisites()
if errors: return errors
+ return []
+
def Download_Unpack (self):
# Download
errors = self._Handle_Download (tarball = self._tarball_url)
@@ -103,3 +106,71 @@ def Configure_Cherokee (self):
# Normalize rules
CTK.cfg.normalize ('vserver!%s!rule'%(self.vserver_num))
+
+ return []
+
+
+ #
+ # Modules
+ #
+
+ def _get_PHP_modules (self):
+ # PHP binary
+ php_path = php_fpm._find_binary()
+ if not php_path:
+ return []
+
+ # Execute php -m
+ ret = popen.popen_sync ('%s -m' %(php_path))
+
+ # Parse output
+ modules = re.findall('(^[a-zA-Z0-9].*$)', ret['stdout'], re.MULTILINE)
+ return modules
+
+ def _check_PHP_modules (self, modules):
+ # Preformat
+ if type(modules) == list:
+ mods = modules
+ else:
+ mods = [modules]
+
+ # List of PHP modules
+ available_modules = self._get_PHP_modules()
+ if not available_modules:
+ return False
+
+ # Cross the list
+ result = {}
+ for m in mods:
+ result[m] = m in available_modules
+
+ return result
+
+ def _Prerequisite__check_PHP_modules (self, modules):
+ errors = []
+ results = self._check_PHP_modules (modules)
+
+ for module in results:
+ if not results[module]:
+ errors += ["The PHP module '%(name)s' was not found" %({'name': module})]
+
+ return errors
+
+ def _Prerequisite__MySQL (self, check_mysql=True, check_mysqli=True):
+ # Check the modules
+ if check_mysql:
+ error_mysql = self._Prerequisite__check_PHP_modules ('mysql')
+ if check_mysqli:
+ error_mysqli = self._Prerequisite__check_PHP_modules ('mysqli')
+
+ # Interpret the return values
+ if check_mysql and check_mysqli and error_mysql and error_mysqli:
+ return [_("Wordpress requieres PHP to have either the 'mysql' or 'mysqli' modules")]
+
+ if check_mysqli and not check_mysql and error_mysqli:
+ return error_mysqli
+
+ if check_mysql and not check_mysqli and error_mysql:
+ return error_mysql
+
+ return []
@@ -73,9 +73,7 @@ def Check_Parameters (self):
def Check_Prerequisites (self):
# Find the binary
- self.php_bin = path_find_binary (FPM_BINS,
- extra_dirs = DEFAULT_PATHS,
- custom_test = _test_php_fcgi)
+ self.php_bin = _find_binary()
if not self.php_bin:
return ["Could not locate the php-fpm binary"]
@@ -170,6 +168,11 @@ def Configure_Cherokee (self):
# Helper functions
#
+def _find_binary ():
+ return path_find_binary (FPM_BINS,
+ extra_dirs = DEFAULT_PATHS,
+ custom_test = _test_php_fcgi)
+
def _test_php_fcgi (path):
f = os.popen('%s -v' %(path), 'r')
output = f.read()
@@ -108,6 +108,13 @@ def __init__ (self, params):
tarball_url = TARBALL,
params = params)
+ def Check_Prerequisites (self):
+ errors = php_tpl.Install.Check_Prerequisites (self)
+ errors += self._Prerequisite__MySQL()
+ return errors
+
+
+
#
# GUI
#

0 comments on commit a366370

Please sign in to comment.