import os.path import os import subprocess def get_exception_name(output): """Reads the stderr output of another Python command and grabs the fully qualified exception name""" lines = output.split("\n") for line in lines[1:]: # skip the "traceback" line line = line.rstrip() if line[0] == ' ': continue if line[-1] == ":": return line[:-1] else: return line def get_dir_uid(dir): """Finds the uid of the person who owns this directory.""" return os.stat(dir).st_uid 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]