summaryrefslogtreecommitdiffstats
path: root/build/pymake/tests/pycmd.py
blob: 83b9b966b42926eec65b3745f78941d68b542e07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os, sys, subprocess

def writetofile(args):
  with open(args[0], 'w') as f:
    f.write(' '.join(args[1:]))

def writeenvtofile(args):
  with open(args[0], 'w') as f:
    f.write(os.environ[args[1]])

def writesubprocessenvtofile(args):
  with open(args[0], 'w') as f:
    p = subprocess.Popen([sys.executable, "-c",
                          "import os; print os.environ['%s']" % args[1]],
                          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout, stderr = p.communicate()
    assert p.returncode == 0
    f.write(stdout)

def convertasplode(arg):
  try:
    return int(arg)
  except:
    return (None if arg == "None" else arg)

def asplode(args):
  arg0 = convertasplode(args[0])
  sys.exit(arg0)

def asplode_return(args):
  arg0 = convertasplode(args[0])
  return arg0

def asplode_raise(args):
  raise Exception(args[0])

def delayloadfn(args):
    import delayload