def run_exec(x, infilename, outfilename):
    args = list(x.args)
    if os.path.exists(outfilename):
        os.remove(outfilename)
    if (x.outp == StdOut):
        outfile = open(outfilename, 'wb')
        pipe_out = outfile
    else:
        outfile = None
        pipe_out = logfile
        args += ([x.outp, outfilename] if (x.outp != None) else [outfilename])
    if (x.inp == StdIn):
        infile = open(infilename, 'rb')
        pipe_in = infile
    else:
        infile = None
        pipe_in = None
        args += ([x.inp, infilename] if (x.inp != None) else [infilename])
    t0 = time.time()
    subprocess.check_call(args, stdin=pipe_in, stdout=pipe_out, stderr=logfile)
    (outfile.close() if outfile else None)
    (infile.close() if infile else None)
    return (time.time() - t0)
def run_exec(x, infilename, outfilename):
    args = list(x.args)
    if os.path.exists(outfilename):
        os.remove(outfilename)
    if (x.outp == StdOut):
        outfile = open(outfilename, 'wb')
        pipe_out = outfile
    else:
        outfile = None
        pipe_out = logfile
        args += ([x.outp, outfilename] if (x.outp != None) else [outfilename])
    if (x.inp == StdIn):
        infile = open(infilename, 'rb')
        pipe_in = infile
    else:
        infile = None
        pipe_in = None
        args += ([x.inp, infilename] if (x.inp != None) else [infilename])
    t0 = time.time()
    subprocess.check_call(args, stdin=pipe_in, stdout=pipe_out, stderr=logfile)
    (outfile.close() if outfile else None)
    (infile.close() if infile else None)
    return (time.time() - t0)