]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/scripts.py
Add support for a working dir in wizard.shell
[wizard.git] / wizard / scripts.py
index 0834b250430137532dad646199d347fef5bb0708..9092f268d0be2a96cbe33344fba7c701e8bde536 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")
@@ -117,6 +124,7 @@ def get_disk_usage(dir=None, excluded_dir=".git"):
             if not os.path.join(root, name).startswith(dir + excluded_dir):
                 file = os.path.join(root, name)
                 try:
+                    if os.path.islink(file): continue
                     sum_sizes += os.path.getsize(file)
                 except OSError as e:
                     if e.errno == errno.ENOENT: