From: Edward Z. Yang Date: Wed, 25 Nov 2009 07:37:50 +0000 (-0500) Subject: Refactor more boilerplate out. X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/commitdiff_plain/d2221e2bb2203f73d633d0aeccabf2b0002a4e8a Refactor more boilerplate out. Signed-off-by: Edward Z. Yang --- diff --git a/wizard/app/__init__.py b/wizard/app/__init__.py index ab4d008..483f7ee 100644 --- a/wizard/app/__init__.py +++ b/wizard/app/__init__.py @@ -246,13 +246,10 @@ class Application(object): this application. """ raise NotImplementedError - def checkWeb(self, deployment, output=None): + def checkWeb(self, deployment): """ - Checks if the autoinstall is viewable from the web. To get - the HTML source that was retrieved, pass a variable containing - an empty list to ``output``; it will be mutated to have its - first element be the output. Subclasses should provide an - implementation. + Checks if the autoinstall is viewable from the web. Subclasses should + provide an implementation. .. note:: Finding a reasonable heuristic that works across skinning @@ -262,6 +259,13 @@ class Application(object): not to depend on pages that are not the main page. """ raise NotImplementedError + def checkWebPage(self, deployment, page, output): + """ + Checks if a given page of an autoinstall contains a particular string. + """ + page = deployment.fetch(page) + logging.info("checkWebPage:\n\n" + page) + return page.find(output) != -1 def checkConfig(self, deployment): """ Checks whether or not an autoinstall has been configured/installed diff --git a/wizard/app/mediawiki.py b/wizard/app/mediawiki.py index fc81613..adfdd42 100644 --- a/wizard/app/mediawiki.py +++ b/wizard/app/mediawiki.py @@ -4,6 +4,7 @@ import os import lxml.cssselect import lxml.etree import StringIO +import logging from wizard import app, install, resolve, shell, util from wizard.app import php @@ -35,19 +36,12 @@ class Application(app.Application): return os.path.isfile("LocalSettings.php") def detectVersion(self, deployment): return self.detectVersionFromFile("includes/DefaultSettings.php", php.re_var("wgVersion")) - 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("