]> scripts.mit.edu Git - wizard.git/commitdiff
Add infrastructure for app subclasses.
authorEdward Z. Yang <ezyang@mit.edu>
Thu, 30 Jul 2009 05:39:22 +0000 (01:39 -0400)
committerEdward Z. Yang <ezyang@mit.edu>
Thu, 30 Jul 2009 05:39:22 +0000 (01:39 -0400)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
wizard/app/__init__.py [new file with mode: 0644]
wizard/app/mediawiki.py [new file with mode: 0644]
wizard/app/php.py [new file with mode: 0644]
wizard/command/summary/__init__.py
wizard/deploy.py
wizard/tests/log_test.py

diff --git a/wizard/app/__init__.py b/wizard/app/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/wizard/app/mediawiki.py b/wizard/app/mediawiki.py
new file mode 100644 (file)
index 0000000..9931b1b
--- /dev/null
@@ -0,0 +1,20 @@
+import re
+
+from wizard import deploy
+
+def make_regex(var):
+    return re.compile('^\$' + var + r'''\s*=\s*((["\']).*\2;)$''', re.M)
+
+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'}
+
+class Application(deploy.Application):
+    pass
diff --git a/wizard/app/php.py b/wizard/app/php.py
new file mode 100644 (file)
index 0000000..0d9fcfd
--- /dev/null
@@ -0,0 +1,3 @@
+php_ini_regexes = \
+        {'WIZARD_SESSIONNAME': None,
+         'WIZARD_TMPDIR': None}
index d59492c5595775a88ed84d5211dc83fa13ed4256..7284f8c3faa977c299b1fc8f0c5f900ffdac7567 100644 (file)
@@ -49,7 +49,7 @@ Use %prog summary SUBCOMMAND --help for more information."""
 ## -- some generic helper stuff --
 
 def parse_install_lines(show, options, yield_errors = False):
-    if not show: show = deploy.applications
+    if not show: show = deploy.applications()
     show = frozenset(show)
     for line in deploy.getInstallLines(options.versions_path):
         # construction
index 39d15034af567237c9dd957f975f02c077c3706f..b6d6f6648630c2455d703a6974079175097d8fe0 100644 (file)
@@ -77,8 +77,13 @@ class Application(object):
             self.versions[version] = ApplicationVersion(distutils.version.LooseVersion(version), self)
         return self.versions[version]
     @staticmethod
-    def make(self, name):
-        pass
+    def make(name):
+        """Makes an application, but uses the correct subtype if available."""
+        try:
+            __import__("wizard.app." + name)
+            return getattr(wizard.app, name).Application(name)
+        except ImportError:
+            return Application(name)
 
 class ApplicationVersion(object):
     """Represents an abstract notion of a version for an application"""
@@ -115,7 +120,7 @@ class ApplicationVersion(object):
                 version = "trunk"
         except ValueError: # mostly from the a, b = foo.split(' ')
             raise DeploymentParseError(deploydir, location)
-        if not applookup: applookup = applications
+        if not applookup: applookup = applications()
         try:
             # defer to the application for version creation
             return applookup[app].makeVersion(version)
@@ -163,7 +168,12 @@ application_list = [
     # these are technically deprecated
     "advancedpoll", "gallery",
 ]
-
-"""Hash table for looking up string application name to instance"""
-applications = dict([(n,Application(n)) for n in application_list ])
+_applications = None
+
+def applications():
+    """Hash table for looking up string application name to instance"""
+    global _applications
+    if not _applications:
+        _applications = dict([(n,Application.make(n)) for n in application_list ])
+    return _applications
 
index c07560197dcfd2697ba93c5993d75bc7e727b16b..a59de34e319dcbe0aac405f69fbf21b11369e8cc 100644 (file)
@@ -16,16 +16,16 @@ def test_deploy_log_load():
     assert isinstance(dlog[0].source, log.TarballInstall)
     assert dlog[0].source.location == "/afs/athena.mit.edu/contrib/scripts/deploy/mediawiki.tar.gz"
     assert dlog[0].source.isDev == False
-    assert dlog[0].version == deploy.applications["mediawiki"].makeVersion('1.5.6')
+    assert dlog[0].version == deploy.applications()["mediawiki"].makeVersion('1.5.6')
 
     assert dlog[1].datetime == datetime(2007, 10, 17, 3, 38, 2, tzinfo=tzoffset(None, -4 * 60 * 60))
     assert dlog[1].user == "quentin@QUICHE-LORRAINE.MIT.EDU"
     assert isinstance(dlog[1].source, log.OldUpdate)
     assert dlog[1].source.isDev == True
-    assert dlog[1].version == deploy.applications["mediawiki"].makeVersion('1.5.6')
+    assert dlog[1].version == deploy.applications()["mediawiki"].makeVersion('1.5.6')
 
     assert dlog[2].datetime == datetime(2009, 6, 13, 21, 33, 0, tzinfo=tzoffset(None, -4 * 60 * 60))
     assert dlog[2].user == "ezyang@mit.edu"
     assert isinstance(dlog[2].source, log.WizardUpdate)
-    assert dlog[2].version == deploy.applications["mediawiki"].makeVersion('1.14.0-scripts')
+    assert dlog[2].version == deploy.applications()["mediawiki"].makeVersion('1.14.0-scripts')