X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/e44406f8baa8d92acedfc69c528d6afe41af22e1..ee8e5d33462267936f1b03e1d22c075c65d36854:/wizard/app/mediawiki.py diff --git a/wizard/app/mediawiki.py b/wizard/app/mediawiki.py index 6b39c8f..5e71b4d 100644 --- a/wizard/app/mediawiki.py +++ b/wizard/app/mediawiki.py @@ -6,15 +6,13 @@ import logging import shlex import shutil -from wizard import app, deploy, install, scripts, shell, util +from wizard import app, deploy, install, resolve, scripts, shell, util from wizard.app import php def make_filename_regex(var): return 'LocalSettings.php', re.compile('^(\$' + app.expand_re(var) + r'''\s*=\s*)(.*)(;)''', re.M) -make_extractor = app.filename_regex_extractor(make_filename_regex) -make_substitution = app.filename_regex_substitution(make_filename_regex) -seed = { +seed = util.dictmap(make_filename_regex, { 'WIZARD_IP': 'IP', # obsolete, remove after we're done 'WIZARD_SITENAME': 'wgSitename', 'WIZARD_SCRIPTPATH': 'wgScriptPath', @@ -24,28 +22,17 @@ seed = { 'WIZARD_DBUSER': 'wgDBuser', 'WIZARD_DBPASSWORD': 'wgDBpassword', 'WIZARD_SECRETKEY': ('wgSecretKey', 'wgProxyKey'), - } + }) -class Application(deploy.Application): +class Application(app.Application): parametrized_files = ['LocalSettings.php', 'php.ini'] deprecated_keys = set(['WIZARD_IP']) | php.deprecated_keys - @property - def extractors(self): - if not self._extractors: - self._extractors = util.dictmap(make_extractor, seed) - self._extractors.update(php.extractors) - return self._extractors - @property - def substitutions(self): - if not self._substitutions: - self._substitutions = util.dictkmap(make_substitution, seed) - self._substitutions.update(php.substitutions) - return self._substitutions - @property - def install_handler(self): - handler = install.ArgHandler("mysql", "admin", "email") - handler.add(install.Arg("title", help="Title of your new MediaWiki install")) - return handler + extractors = app.make_extractors(seed) + extractors.update(php.extractors) + substitutions = app.make_substitutions(seed) + substitutions.update(php.substitutions) + install_handler = install.ArgHandler("mysql", "admin", "email") + install_handler.add(install.Arg("title", help="Title of your new MediaWiki install")) def checkConfig(self, deployment): return os.path.isfile(os.path.join(deployment.location, "LocalSettings.php")) def detectVersion(self, deployment): @@ -54,9 +41,13 @@ class Application(deploy.Application): match = regex.search(contents) if not match: return None return distutils.version.LooseVersion(match.group(2)[1:-1]) - def checkWeb(self, d): - page = d.fetch("index.php?title=Special:Version") - return page.find("MediaWiki is free software") != -1 + def checkWeb(self, deployment, out=None): + page = deployment.fetch("/index.php?title=Main_Page") + if type(out) is list: + out.append(page) + return page.find("