X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/6eae78b3d8ed73a0266ef09a30e4b09e791dd9fb..30380c4b5b28df9670ea5952e14bc485d1d34133:/wizard/app/mediawiki.py diff --git a/wizard/app/mediawiki.py b/wizard/app/mediawiki.py index 9931b1b..c6ac8ae 100644 --- a/wizard/app/mediawiki.py +++ b/wizard/app/mediawiki.py @@ -1,20 +1,192 @@ import re +import distutils.version +import os +import lxml.cssselect +import lxml.etree +import StringIO +import logging -from wizard import deploy +from wizard import app, install, resolve, shell, util +from wizard.app import php -def make_regex(var): - return re.compile('^\$' + var + r'''\s*=\s*((["\']).*\2;)$''', re.M) +def make_filename_regex(var): + return 'LocalSettings.php', php.re_var(var) -wizard_to_var = \ - {'WIZARD_IP': 'IP' # obsolete - ,'WIZARD_SITENAME': 'wgSitename' - ,'WIZARD_SCRIPTPATH': 'wgScriptPath' - ,'WIZARD_EMERGENCYCONTACT': 'wgEmergencyContact' - ,'WIZARD_DBSERVER': 'wgDBserver' - ,'WIZARD_DBNAME': 'wgDBname' - ,'WIZARD_DBUSER': 'wgDBuser' - ,'WIZARD_DBPASSWORD': 'wgDBpassword' - ,'WIZARD_PROXYKEY': 'wgProxyKey'} +seed = util.dictmap(make_filename_regex, { + 'WIZARD_IP': 'IP', # obsolete, remove after we're done + 'WIZARD_SITENAME': 'wgSitename', + 'WIZARD_SCRIPTPATH': 'wgScriptPath', + 'WIZARD_EMERGENCYCONTACT': ('wgEmergencyContact', 'wgPasswordSender'), + 'WIZARD_DBSERVER': 'wgDBserver', + 'WIZARD_DBNAME': 'wgDBname', + 'WIZARD_DBUSER': 'wgDBuser', + 'WIZARD_DBPASSWORD': 'wgDBpassword', + 'WIZARD_SECRETKEY': ('wgSecretKey', 'wgProxyKey'), + }) + +class Application(app.Application): + database = "mysql" + parametrized_files = ['LocalSettings.php'] + php.parametrized_files + deprecated_keys = set(['WIZARD_IP']) | php.deprecated_keys + 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("LocalSettings.php") + def detectVersion(self, deployment): + return self.detectVersionFromFile("includes/DefaultSettings.php", php.re_var("wgVersion")) + def checkWeb(self, deployment): + return self.checkWebPage(deployment, "/index.php?title=Main_Page", "