X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/3c391e8d97efac20e9b9f52b5446bfac1b4239c2..30380c4b5b28df9670ea5952e14bc485d1d34133:/wizard/app/mediawiki.py diff --git a/wizard/app/mediawiki.py b/wizard/app/mediawiki.py index d77b0c3..c6ac8ae 100644 --- a/wizard/app/mediawiki.py +++ b/wizard/app/mediawiki.py @@ -1,19 +1,18 @@ import re import distutils.version import os -import datetime +import lxml.cssselect +import lxml.etree +import StringIO import logging -import shlex -from wizard import app, deploy, install, scripts, shell, util +from wizard import app, install, resolve, 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) + return 'LocalSettings.php', php.re_var(var) -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', @@ -23,95 +22,171 @@ seed = { 'WIZARD_DBUSER': 'wgDBuser', 'WIZARD_DBPASSWORD': 'wgDBpassword', 'WIZARD_SECRETKEY': ('wgSecretKey', 'wgProxyKey'), - } + }) -class Application(deploy.Application): - parametrized_files = ['LocalSettings.php', 'php.ini'] +class Application(app.Application): + database = "mysql" + parametrized_files = ['LocalSettings.php'] + php.parametrized_files 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_schema = install.ArgSchema("db", "admin", "email", "title") def checkConfig(self, deployment): - return os.path.isfile(os.path.join(deployment.location, "LocalSettings.php")) + return os.path.isfile("LocalSettings.php") def detectVersion(self, deployment): - contents = deployment.read("includes/DefaultSettings.php") - regex = make_filename_regex("wgVersion")[1] - match = regex.search(contents) - if not match: return None - return distutils.version.LooseVersion(match.group(2)[1:-1]) + return self.detectVersionFromFile("includes/DefaultSettings.php", php.re_var("wgVersion")) + def checkWeb(self, deployment): + return self.checkWebPage(deployment, "/index.php?title=Main_Page", "