Skip to content

Instantly share code, notes, and snippets.

@renatooliveira
Created July 11, 2012 03:36
Show Gist options
  • Save renatooliveira/3087833 to your computer and use it in GitHub Desktop.
Save renatooliveira/3087833 to your computer and use it in GitHub Desktop.
Corrector
import os
from subprocess import Popen
path = os.path.dirname(os.path.abspath(__file__))
#to avoid all the *.py files to be in the list
folders = filter(os.path.isdir, os.listdir('.'))
for folder in folders:
#copying the entrada.txt and saidaM.txt file into each folder
Popen(['cp','entrada.txt',folder])
Popen(['cp','saidaM.txt',folder])
try:
#try java
Popen('javac ' + folder + '/P2.java')
Popen('java ' + folder +'/P2')
except:
#or c plus plus
comp = ['gcc ' + path + '/' + folder + '/P2.cpp -o ' + path + '/' + folder + '/P2']
run = ['.' + path + '/' + folder + '/P2']
print comp
print run
Popen(comp)
Popen(run)
try:
outStudent = open(folder + '/saida.txt', 'r')
outMonitor = open(folder + '/saidaM.txt', 'r')
linhas1 = []
linhas2 = []
for l1 in outStudent:
linhas1.append(l1[:-2])
for l2 in outMonitor:
linhas2.append(l2[:-2])
linhas3 = zip(linhas1, linhas2)
print linhas3
qtd = 0
for l1, l2 in linhas3:
if l1 == l2:
qtd = qtd + 1
print folder
print 10*(float(qtd) / float(linhas1.__len__()))
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment