I am building an online judge that takes a user's c++ code, and tells them whether or not the output from it is correct. Currently, I'm looking at an open source python project to see how to do it. In the example code, they run both subprocess.check_output() and subprocess.call(), even though they pretty much do the same thing. Since I am a beginner at subprocess and command line arguments in general, I was wondering if there is a reason for this. Thanks!
if language == "C++":
filename = "submissions/" + str(runID) + ".cpp"
try :
subprocess.check_output('g++ ' + filename, stderr = subprocess.STDOUT , shell=True);
except subprocess.CalledProcessError, e:
return (-1 , e.output)
retval = subprocess.call('g++ ' + filename , shell = True)
subprocess.call('timeout 1s ./a.out < ' + inpfile + ' > ' + outfile , shell = True)