1 #===----------------------------------------------------------------------===##
3 # The LLVM Compiler Infrastructure
5 # This file is dual licensed under the MIT and the University of Illinois Open
6 # Source Licenses. See LICENSE.TXT for details.
8 #===----------------------------------------------------------------------===##
10 from contextlib import contextmanager
15 def cleanFile(filename):
23 def guardedTempFilename(suffix='', prefix='', dir=None):
24 # Creates and yeilds a temporary filename within a with statement. The file
25 # is removed upon scope exit.
26 handle, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)
33 def guardedFilename(name):
34 # yeilds a filename within a with statement. The file is removed upon scope
41 def nullContext(value):
42 # yeilds a variable within a with statement. No action is taken upon scope
47 def makeReport(cmd, out, err, rc):
48 report = "Command: %s\n" % cmd
49 report += "Exit Code: %d\n" % rc
51 report += "Standard Output:\n--\n%s--\n" % out
53 report += "Standard Error:\n--\n%s--\n" % err