--- fract/mandelzoom.cgi 2001/02/26 03:13:13 1.6 +++ fract/mandelzoom.cgi 2001/06/19 22:27:27 1.9 @@ -1,8 +1,14 @@ #!/usr/bin/python -import cgi, Image, ImageDraw, sys, math +import cgi, Image, ImageDraw, sys, math, signal, errno, os from string import atoi, atof +def handler(signum, frame): + raise os.error, (errno.ETIME, "Timer expired") + +signal.alarm(55) +signal.signal(signal.SIGALRM, handler) + # This is to get backtrace output sys.stderr = sys.stdout @@ -74,10 +80,10 @@ iy= atof(form['image.y'].value) owidth= atof(form['owidth'].value) oheight= atof(form['oheight'].value) - diagp= math.sqrt(width**2 + height**2) + diagp= math.sqrt(owidth**2 + oheight**2) scale= diagp/diag - cx= (ix/scale) + (cx - (width / (scale*2))) - cy= ((height-iy)/scale) + (cy - (height / (scale*2))) + cx= (ix/scale) + (cx - (owidth / (scale*2))) + cy= ((oheight-iy)/scale) + (cy - (oheight / (scale*2))) if form.has_key('zoom'): zoom=atof(form['zoom'].value) diag=diag/zoom @@ -117,7 +123,9 @@ print '' % var print '' - print """ + print """

+After changing any settings, don't forget to change the "Zoom" setting +to "Pan" if you don't want to zoom when applying them. """ sys.exit(0) @@ -247,7 +255,13 @@ else: yto= yorig # End at x axis -drawrect((0, yfrom), (xmax, yto)) +try: + drawrect((0, yfrom), (xmax, yto)) +except os.error, the_error: + if the_error[0] != errno.ETIME: + raise os.error, the_error + +signal.alarm(0) print "Content-type: image/png" print