Source code for web

""" A Python script to perform various web functionalities.


2008-08-31 02:00 IJC: Created while CV-observing at Lick Observatory
"""

from PIL import Image
from urllib import urlopen, urlretrieve

[docs]def aavsochart(target, fov, maglimit, res=100): """Get an AAVSO finder chart. INPUT: target: target name fov: size of chart FOV, in arcminutes maglimit: faint magnitude limit res: resolution of chart in DPI""" #2008-08-31 02:01 IJC: Created target = target.replace(' ', '+') url = "http://mira.aavso.org/cgi-bin/vsp.pl?action=render&name=" + \ target + "&ra=&dec=&charttitle=&chartcomment=&aavsoscale=Choose&" + \ "fov=" + str(fov) + "&resolution=" + str(res) + "&maglimit=" + \ str(maglimit) + "&othervars=&chartid=&Submit=Plot+Chartt" u = urlopen(url) d = u.read().lower() u.close() if d.find('Sorry')<>-1: # object not found print "Not found -- tough luck!" return else: pngind = d.find('.png') hrefind = d.find('a href=', pngind-50) charturl = d[hrefind+8:pngind+4] g = urlretrieve(charturl) im = Image.open(g[0]) im.show() return