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