#!/usr/bin/env python """ A cgi to warn people before downloading ppmxl; this also should fend off robots. You'll want to have it in your apache config with something like ScriptAlias /ppmxl /data/gavo/inputs/ppmxl/bin/download.cgi and a link from $DOCUMENT_ROOT/textdumps/ppmxl.gz to $GAVO_INPUTS/ppmxl/static/dump-for-web.gz """ import cgi import os from nevow import tags as T from nevow import flat destLink = "http://vo.ari.uni-heidelberg.de/textdumps/ppmxl.gz" def makeFwdDoc(): return T.html[ T.head[ T.title["PPMXL Download"], T.meta(**{"http-equiv": "Refresh", "content": "0;URL="+destLink})], T.body[ T.h1["PPMXL Download"], T.p["If you are seeing this, you probably have to click ", T.a(href=destLink)["this link"], " manually. It will start a download of more than 42 Gigabytes."]]] def makeFwdDocIfBroken(): return T.html[ T.head[ T.title["PPMXL Download Not Available"], T.body[ T.h1["PPMXL Download Not Available"], T.p["The download of a PPMXL dump is not available at this time." " Please contact gavo@ari.uni-heidelberg.de, and we'll make a" " dump again."]]]] def makeFormDoc(): return T.html[ T.head[ T.title["PPMXL Download"]], T.body[ T.h1["PPMXL Download"], T.p["You are about to download PPMXL, a catalog of about 10", T.sup["9"], " stars. For details, see ", T.a(href="http://dc.zah.uni-heidelberg.de/ppmxl/q/cone/info")[ "the service info on PPMXL cone search"], " in the GAVO data center and the ", T.a(href="http://dc.zah.uni-heidelberg.de/__system__/dc_tables/show/tableinfo/ppmxl.main?dbOrder=True")[ "Column description"], "."], T.form(action=os.environ.get("SCRIPT_NAME"), method="GET", style="border:2pt solid red;padding:0.5cm; width:6cm;" "margin-left:auto;margin-right:auto;margin-top:1cm")[ T.p[ "I have noticed that I am about to download about ", T.strong["43.5 GiB"], " and that that would take about ", T.strong[ "80 hours on a line with a constant throughput of 1 Mbit/s."], " I have enough free space on my drive" " and will not waste the bandwidth I am going to consume by" ' clicking "Go ahead" below.'], T.div(style="text-align:center")[ T.input(type="hidden", name="clickedOK", value="True"), T.input(type="submit", value="Go ahead")]]]] def writeDoc(stan): print "content-type: text/html" print "" print flat.flatten(stan) def main(): fs = cgi.FieldStorage() if fs.getfirst("clickedOK")=="True": writeDoc(makeFwdDoc()) else: writeDoc(makeFormDoc()) if __name__=="__main__": main()