build/pymake/tests/pycmd.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 import os, sys, subprocess
michael@0 2
michael@0 3 def writetofile(args):
michael@0 4 with open(args[0], 'w') as f:
michael@0 5 f.write(' '.join(args[1:]))
michael@0 6
michael@0 7 def writeenvtofile(args):
michael@0 8 with open(args[0], 'w') as f:
michael@0 9 f.write(os.environ[args[1]])
michael@0 10
michael@0 11 def writesubprocessenvtofile(args):
michael@0 12 with open(args[0], 'w') as f:
michael@0 13 p = subprocess.Popen([sys.executable, "-c",
michael@0 14 "import os; print os.environ['%s']" % args[1]],
michael@0 15 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
michael@0 16 stdout, stderr = p.communicate()
michael@0 17 assert p.returncode == 0
michael@0 18 f.write(stdout)
michael@0 19
michael@0 20 def convertasplode(arg):
michael@0 21 try:
michael@0 22 return int(arg)
michael@0 23 except:
michael@0 24 return (None if arg == "None" else arg)
michael@0 25
michael@0 26 def asplode(args):
michael@0 27 arg0 = convertasplode(args[0])
michael@0 28 sys.exit(arg0)
michael@0 29
michael@0 30 def asplode_return(args):
michael@0 31 arg0 = convertasplode(args[0])
michael@0 32 return arg0
michael@0 33
michael@0 34 def asplode_raise(args):
michael@0 35 raise Exception(args[0])
michael@0 36
michael@0 37 def delayloadfn(args):
michael@0 38 import delayload

mercurial