All pastes #215352 Raw Edit

Casanova

public text v1 · immutable
#215352 ·published 2006-10-22 15:56 UTC
rendered paste body
    def run (self, exec_file, input_file):
        import tempfile
        import time
        output_file = tempfile.NameTemporaryFile ()
        kws = {}
        cmd = exec_file + ' < ' + input_file + ' > ' + output_file.name
        start_time = time.time()
        p = subproces.Popen (cmd, **kws)
        #         (status, output) = commands.getstatusoutput (exec_file + ' < ' \
        #                                                      + input_file)
        while True:
            if time.time() - start_time >= 5 or p.poll() != None:
                break
            time.sleep (0.5)
        if status != 0:
            raise EvaluatorError ('Run-Time Error')
        else:
            return output