import os.path
-import ldap
+import os
+import subprocess
def get_exception_name(output):
"""Reads the stderr output of another Python command and grabs the
else:
return line
-def get_dir_user(dir):
- """Finds the username of the person who owns this directory, via LDAP.
- Only works for directories under web_scripts"""
- dir = os.path.realpath(dir)
- homedir, _, _ = dir.partition("/web_scripts")
- if homedir == dir: return None
- con = ldap.initialize('ldap://scripts.mit.edu')
- return con.search_s(
- "ou=People,dc=scripts,dc=mit,dc=edu", # base
- ldap.SCOPE_SUBTREE, # default
- "homeDirectory=" + homedir, # search
- ['uid'] # attr
- )[0][1]["uid"][0] # unwrap the result
+def get_dir_uid(dir):
+ """Finds the uid of the person who owns this directory."""
+ return os.stat(dir).st_uid
-def get_dir_url(dir):
- """Finds the URL a path would correspond to in the filesystem"""
- _, _, path = dir.partition("/web_scripts")
- return "http://%s.scripts.mit.edu%s" % (get_dir_user(dir), path)
+def get_version():
+ """Returns the commit ID of the current Wizard install."""
+ wizard_git = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), ".git")
+ return subprocess.Popen(["git", "--git-dir=" + wizard_git, "rev-parse", "HEAD"]).communicate()[0]