Beispiel #1
0
def NoValidFunction(req, res, e):
    # We save the result in a temporary directory as well as the exception
    # message. Then we remove the ValidatorIcon.
    tmp = tempfile.mktemp()
    os.mkdir(tmp)
    fn = 'novalid_' + os.path.basename(req.path)
    Utils.FileString(os.path.join(tmp, fn), res[1])
    Utils.Error('Saved in dir ' + tmp, prefix='See: ')
    Utils.FileString(os.path.join(tmp, 'message'), str(e))
    # Remove ValidatorIcon:
    res[1] = string.replace(res[1], WebWorkers.ValidatorIconText, '')
    # Adjust Content-length:
    res[0]['Content-length'] = str(len(res[1]))
Beispiel #2
0
    sol = sheet.AllSolutions().strip()
    values['ExercisesTable'] = sheet.LatexSheetTable('')
    values['ExercisesNoTable'] = sheet.LatexSheetNoTable()
    if len(sol) > 0:
      values['ExercisesTable'] = values['ExercisesTable']+ \
        '\n\\newpage\n\n\\begin{verbatim}\n'+ sol +'\n\\end{verbatim}\n\n'
    latexinput = None
    pdf = None
    if opt.has_key('-n'):
      templ = Config.conf['PDFTemplateNoTable']
    else:
      templ = Config.conf['PDFTemplate']
    try:
      latexinput = SimpleTemplate.FillTemplate(templ, values)
    except:
      print('Cannot produce LaTeX input.')
    if latexinput:
      try:
        pdf = LatexImage.LatexToPDF(latexinput)
      except:
        pdf = None
    if latexinput:
      Utils.FileString(fname+'_'+sheet.name+'.tex',latexinput)
      print 'Wrote LaTeX code to '+fname+'_'+sheet.name+'.tex'
      if pdf:
        Utils.FileString(fname+'_'+sheet.name+'.pdf',pdf)    
        print 'Wrote PDF file to '+fname+'_'+sheet.name+'.pdf'
        shutil.rmtree('tmpsheettest')