]> scripts.mit.edu Git - wizard.git/commitdiff
Check for old style URLs.
authorEdward Z. Yang <ezyang@mit.edu>
Sun, 7 Feb 2010 00:26:35 +0000 (19:26 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Sun, 7 Feb 2010 00:26:35 +0000 (19:26 -0500)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
wizard/app/wordpress.py
wizard/deploy.py
wizard/scripts.py

index 00352090553a1e237ac28f5829cc627a0912fe32..546827fa53e4b9ae6376fdf89bcee04da7ec9b6a 100644 (file)
@@ -41,9 +41,15 @@ class Application(app.Application):
         return os.path.isfile("wp-config.php")
     def checkWeb(self, deployment):
         # XXX: this sucks pretty hard
-        return self.checkWebPage(deployment, "",
-                outputs=["<html", "WordPress", "feed"],
-                exclude=["Error establishing a database connection"])
+        def doCheck():
+            return self.checkWebPage(deployment, "",
+                    outputs=["<html", "WordPress", "feed"],
+                    exclude=["Error establishing a database connection"])
+        if not doCheck():
+            deployment.enableOldStyleUrls()
+            return doCheck()
+        else:
+            return True
     def detectVersion(self, deployment):
         return self.detectVersionFromFile("wp-includes/version.php", php.re_var("wp_version"))
     def install(self, version, options):
index 500f89d60b1a511cd8b7a76c2c9ded1def4c9804..4fdff7d5dde202d63fcfbc4fa769ebd6f4425eb1 100644 (file)
@@ -302,6 +302,12 @@ class Deployment(object):
         if not self._url:
             raise UnknownWebPath
         return self._url
+    def enableOldStyleUrls(self):
+        """
+        Switches to using http://user.scripts.mit.edu/~user/app URLs.
+        No effect if they have an explicit .scripts/url override.
+        """
+        self._url = scripts.fill_url(self.location, self.application.url(self), old_style = True)
     @staticmethod
     def parse(line):
         """
index 0834b250430137532dad646199d347fef5bb0708..50af4afb3c95870b53c63d0fd677bfd80e4c052d 100644 (file)
@@ -13,7 +13,7 @@ import errno
 import wizard
 from wizard import shell, util
 
-def fill_url(dir, url=None):
+def fill_url(dir, url=None, old_style=False):
     """
     Attempts to determine the URL a directory would be web-accessible at.
     If ``url`` is specified, automatically use it.
@@ -26,11 +26,18 @@ def fill_url(dir, url=None):
     # try the directory
     homedir, _, web_path = dir.partition("/web_scripts")
     if web_path:
-        return urlparse.ParseResult(
-                "http",
-                util.get_dir_owner(homedir) + ".scripts.mit.edu",
-                web_path.rstrip('/'),
-                "", "", "")
+        if old_style:
+            return urlparse.ParseResult(
+                    "http",
+                    "scripts.mit.edu",
+                    "/~" + util.get_dir_owner(homedir) + web_path.rstrip('/'),
+                    "", "", "")
+        else:
+            return urlparse.ParseResult(
+                    "http",
+                    util.get_dir_owner(homedir) + ".scripts.mit.edu",
+                    web_path.rstrip('/'),
+                    "", "", "")
 
     # try the environment
     host = os.getenv("WIZARD_WEB_HOST")