Updated to use new template and pulled most recent gradaudit changes

parent d467e747
import os
import re
import gradaudit.gradaudit as gradaudit
from flask import Flask, render_template, request
from response import Response
app = Flask(__name__)
......@@ -26,17 +25,7 @@ def submit():
degree, major, year, spec,
classes)
student_data = gradaudit.parse_transcript(transcript)
main_contents = gradaudit.gen_main(*student_data)
with open('main.lp','w') as main_file:
main_file.write(main_contents)
response = os.popen('sasp main.lp').read()
can_grad = 'ableToGraduate({0})'.format(name) in response
reqClasses = re.findall('[a-zA-z]+[1-4][0-9][0-9V][0-9]',response)
resp = Response(student_data)
return render_template('GASTemplate.html',
ableToGraduate=can_grad,
studentName=name,
requiredClasses=reqClasses,
degree=major)
return render_template('GASTemplate.html', response=resp)
Subproject commit a5835170b08901c4248b0c4a28a632892b38776c
Subproject commit cf3a8e7274f4573bec383d2b4a308436ad86f488
import re
from tempfile import NamedTemporaryFile
import gradaudit.gradaudit as gradaudit
from subprocess import check_output
class Response:
def __init__(self, student_data):
self.name = student_data[0]
self.degree = student_data[1]
self.major = student_data[2]
self.year = student_data[3]
self.spec = student_data[4]
self.classes_taken = student_data[5]
main_contents = gradaudit.gen_main(*student_data)
with NamedTemporaryFile() as fil:
fil.write(main_contents)
fil.flush()
answer_set = check_output(['sasp',fil.name])
self.missing_classes = re.findall('hasNotTaken\({},([a-z]+[1-4][0-9V][0-9][0-9])\)'
.format(self.name),answer_set)
self.missing_hours = re.findall('needsHours\({},([a-zA-Z]+),([0-9]+)\)'.format(self.name),answer_set)
self.missing_electives = re.findall('needsElectiveHours\({},([0-9])\)'.format(self.name),answer_set)
self.can_grad = 'ableToGraduate({0})'.format(self.name) in answer_set
if self.missing_electives == []:
self.missing_electives = 0
else:
self.missing_electives = self.missing_electives[0]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment