]> scripts.mit.edu Git - wizard.git/commitdiff
When MediaWiki installs fail due to bad user input, give useful errors.
authorDuncan Townsend <duncant@mit.edu>
Tue, 10 Nov 2009 03:01:47 +0000 (22:01 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Tue, 10 Nov 2009 05:25:11 +0000 (00:25 -0500)
Signed-off-by: Duncan Townsend <duncant@mit.edu>
wizard/app/__init__.py
wizard/app/mediawiki.py

index cd518c416bb05833b6cfd05de317d987b28b167b..adb9a189b6be8bbd58f557c5c47b781c888c2306 100644 (file)
@@ -522,6 +522,10 @@ class Error(wizard.Error):
     """Generic error class for this module."""
     pass
 
+class NonfatalFailure(Error):
+    """Bad parameters given to installer."""
+    pass
+
 class NoRepositoryError(Error):
     """
     :class:`Application` does not appear to have a Git repository
index cf9fa01b570d535012bbba1d05aae840c37e7986..4e36c9c3e86d504a0ab43d5468565b44f62f2679 100644 (file)
@@ -1,6 +1,9 @@
 import re
 import distutils.version
 import os
+import lxml.cssselect
+import lxml.etree
+import StringIO
 
 from wizard import app, install, resolve, shell, util
 from wizard.app import php
@@ -66,9 +69,14 @@ class Application(app.Application):
             'SysopPass2': options.admin_password,
             }
         result = install.fetch(options, '/config/index.php', post=postdata)
+        result_etree = lxml.etree.parse(StringIO.StringIO(result), lxml.etree.HTMLParser())
+        selector = lxml.cssselect.CSSSelector(".error")
+        error_messages = [e.text for e in selector(result_etree)]
         if options.verbose or options.debug: print result
         if result.find("Installation successful") == -1:
-            raise install.Failure()
+            if not error_messages:
+                raise install.Failure()
+            raise app.NonfatalFailure(error_messages)
         os.rename('config/LocalSettings.php', 'LocalSettings.php')
     def upgrade(self, d, version, options):
         sh = shell.Shell()