def findgrep(command='findgrep', file_pattern='', grep_pattern=''): print 'searching ' + grep_pattern + ' in ' + file_pattern + ' ...' files = getout('git ls-files ' + getout('git rev-parse --show-toplevel')[1])[1].split('\n') files = [file for file in files if file_pattern in file] lines = [ printf(file, str(index + 1), line.rstrip('\n').lstrip()) for file in files for index, line in enumerate(open(file)) if grep_pattern.lower() in line.lower() ]
def create_student_output(): try : student_code_file = open("student_code.sh") exec_string = "./" + student_code_file.name getout(exec_string) #Generates the student's out file to be compared except : print 'Couldn\'t load student code' finally: student_code_file.close()
def check_student_case(): try: student_file = open("out",'r') correct_file = open("sout" ,'r') command_diff = str("diff -y --suppress-common-lines "+ \ str(student_file.name) + " " +str(correct_file.name) + \ " | grep ^ | wc -l") status,ans = getout(command_diff) ans = int(ans) if ans>100:ans = 100 print 'Fibonacci Score for ',student_file.name + ' is : ', 100 - int(ans) except IOError,OSError: print 'Error Occured'
import cgi import commands import time print("Content-Type:text/html") #ignores unnecessary Information print("") data = cgi.FeildStorage( ) #extracts full html page ,taking data from apache and storing in web variable #only want to access data in c command = data.getvalue('c') if command == "date": print("executing...") time.sleep(2) print("<pre>") #pre tag is used to show output as in the command print(commands.getout("date")) print("</pre>") if command == "cal": print("executing...") time.sleep(2) print(commands.getout("cal")) #give the page execution permission