
cherokee at cherokee-project
Aug 2, 2011, 2:23 PM
Post #1 of 1
(123 views)
Permalink
|
|
[6784] wizards2: WIP: Prerequisites, PHP modules and MySQL.
|
|
Revision: 6784 http://svn.cherokee-project.com/changeset/6784 Author: alo Date: 2011-08-02 23:23:07 +0200 (Tue, 02 Aug 2011) Log Message: ----------- WIP: Prerequisites, PHP modules and MySQL. Modified Paths: -------------- wizards2/cherokee-wizard wizards2/templates/PHP.py wizards2/wizards/01-Development Platforms/php-fpm.py wizards2/wizards/02-Content Management Systems/wordpress.py Modified: wizards2/cherokee-wizard =================================================================== --- wizards2/cherokee-wizard 2011-08-02 10:52:08 UTC (rev 6783) +++ wizards2/cherokee-wizard 2011-08-02 21:23:07 UTC (rev 6784) @@ -129,4 +129,9 @@ if __name__ == "__main__": - main() + try: + main() + except KeyboardInterrupt: + print + print "Exiting now.." + os._exit(1) Modified: wizards2/templates/PHP.py =================================================================== --- wizards2/templates/PHP.py 2011-08-02 10:52:08 UTC (rev 6783) +++ wizards2/templates/PHP.py 2011-08-02 21:23:07 UTC (rev 6784) @@ -29,6 +29,7 @@ import vserver import Wizard2 import Wizard2_GUI +import popen from util import * @@ -67,6 +68,8 @@ 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 @@ # 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 [] Modified: wizards2/wizards/01-Development Platforms/php-fpm.py =================================================================== --- wizards2/wizards/01-Development Platforms/php-fpm.py 2011-08-02 10:52:08 UTC (rev 6783) +++ wizards2/wizards/01-Development Platforms/php-fpm.py 2011-08-02 21:23:07 UTC (rev 6784) @@ -73,9 +73,7 @@ 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 @@ # 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() Modified: wizards2/wizards/02-Content Management Systems/wordpress.py =================================================================== --- wizards2/wizards/02-Content Management Systems/wordpress.py 2011-08-02 10:52:08 UTC (rev 6783) +++ wizards2/wizards/02-Content Management Systems/wordpress.py 2011-08-02 21:23:07 UTC (rev 6784) @@ -108,6 +108,13 @@ tarball_url = TARBALL, params = params) + def Check_Prerequisites (self): + errors = php_tpl.Install.Check_Prerequisites (self) + errors += self._Prerequisite__MySQL() + return errors + + + # # GUI #
|