[SOLVED] CS python # Please use python3 to run this script

$25

File Name: CS_python_#_Please_use_python3_to_run_this_script.zip
File Size: 461.58 KB

5/5 - (1 vote)

# Please use python3 to run this script
import os
import subprocess

cdir = os.getcwd()
hwDir = cdir+/hw/

if not os.path.exists(hw):
os.makedirs(hw)

os.system(cp hw.zip ./hw)
os.chdir(cdir+/hw)
os.system(unzip hw.zip)

os.system(gcc -fprofile-arcs -ftest-coverage hw.c -o hwX)

for fname in os.listdir(./):
if fname.endswith(.run):
## We will grab the first line, the command-line args
## Then we will read all of the remaining lines.

rfile = open(fname, r)
cmdArgs = rfile.readline().rstrip()
stdinArgs = rfile.read()
rfile.close()

## Now we run the program with its command-line args, and we
## pass it the stdin args from the file.

cmdList = [hwDir+hwX] + cmdArgs.split()
result = subprocess.run(cmdList, input=str.encode(stdinArgs))

os.system(gcov hw.c)

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS python # Please use python3 to run this script
$25