appearance tracking
[QuestHelper.git] / utility.py
blob6f43556b90dadd3f5d84718d295523a2ab4ca99f
2 import subprocess
4 def exe(line):
5 return str(subprocess.Popen(line.split(" "), stdout=subprocess.PIPE).communicate()[0], "ascii")
7 def exe_bin(line):
8 sp = subprocess.Popen(line.split(" "), stdout=subprocess.PIPE)
9 dt = sp.communicate()[0]
10 assert(sp.returncode == 0)
11 return dt
13 def exe_rv(line):
14 ldat = line.split(" ")
15 if line.find("BASHHACK") != -1:
16 ldat = ["bash", "-c", line.split(" ", 1)[1]]
18 sp = subprocess.Popen(ldat, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
19 so, se = sp.communicate()
20 so = str(so, "ascii")
21 se = str(se, "ascii")
22 rv = sp.returncode
23 assert(rv != None)
24 return so, se, rv