import os.path import os 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