示例#1
0
文件: search.py 项目: akrherz/pals
def results():
	day = functs.get_content("day")
	month = functs.get_content("month")
	year = functs.get_content("year")
	
	str_month = functs.convert_month(month)
	std_date = str(year+'-'+month+'-'+day)
	str_date = str_month+' '+day+', '+year
	dir = '/home/httpd/html/archivewx/data/'+std_date

	print '<H4> Data for '+str_date+'</H4>'

	try:
		files = os.listdir(dir)
		files.sort()
		print '<MULTICOL cols="3">'
		for i in range(len(files)):
			file = files[i]
			print '<a href="/archivewx/data/'+std_date+'/'+file+'">'+file+'</a><BR>'
		print '</MULTICOL>'

	except:
		print 'There is currently no data available for this day<BR>'
示例#2
0
文件: download.py 项目: akrherz/pals
def Main():
    style.header("Download Dataset from IowaWx Archive", "white")
    print "<H2>Instructions for downloading from the PALS server</H2>"

    query_option = functs.get_content("query_option")
    city = functs.get_content("city")
    year = functs.get_content("year")
    month = functs.get_content("month")
    day = functs.get_content("day")

    if month == "None":
        str_month = "None"
    else:
        str_month = functs.convert_month("0" + month)

    if city == "None":
        str_city = "None"
    else:
        str_city = functs.convert_station(city)

    print "<HR><H3>1. Review Search Parameters....</H3>"
    print "<TABLE NOBORDER>"
    print '<TR><TH colspan="4">Search Paramenters:</TH><TH colspan="6"><font color="red">Time Constraints:</red></TH></TR>'
    print '<TR><TH bgcolor="#EEEEE">Query Option:</TH><TD>' + query_option + "</TD>"
    print '<TH bgcolor="#EEEEE">Station Option:</TH><TD>' + str_city + "</TD>"
    print '<TH bgcolor="#EEEEE"><font color="red">Year:</font></TH><TD>' + year + "</TD>"
    print '<TH bgcolor="#EEEEE"><font color="red">Month:</font></TH><TD>' + str_month + "</TD>"
    print '<TH bgcolor="#EEEEE"><font color="red">Day:</font></TH><TD>' + day + "</TD>"
    print "</TR></TABLE>"
    print "<HR>"

    print "<H3>2. Instructions for downloading this data.</H3>"
    print "Below a link with appear and you need to hold the shift key down and click on the link.<BR>"
    print "This should allow you to save the text file locally, so then you can do what ever you want with it.<BR>"
    print "<HR>"

    url = "/archivewx/iowawx/tmp/" + filename + ".txt"

    print "<H3>3. Creating data file... (May take a few seconds.)</H3>"

    results = engine.search(query_option, city, year, month, day)

    for i in range(len(results)):
        city = results[i][0]
        year = results[i][1]
        month = results[i][2]
        day = results[i][3]
        climoweek = results[i][4]
        high = results[i][5]
        low = results[i][6]
        rain = results[i][7]
        snow = results[i][8]
        file.write(city + "\t" + year + "\t" + month + "\t" + day + "\t" + climoweek + "\t" + high + "\t")
        file.write(low + "\t" + rain + "\t" + snow + "\n")
    file.close()

    print "<BR>File created successfully!! <BR><HR>"

    print "<H3>4. Download file</H3>"
    print '<a href="' + url + '">Shift-Click Here, to download file</a><BR>'

    style.std_bot()
示例#3
0
文件: search.py 项目: akrherz/pals
def Main():

	form = FormContent()

	query_option = form["query_option"][0]			# Determine which option is desired

	city = "None"			# Code for 
	city_name = "None"
	if form.has_key("city"):
		city = form["city"][0]
		city_name = functs.convert_station(city)

	year = "None"
	if form.has_key("year"):
		year = form["year"][0]

	month = "None"
	str_month = "None"
	if form.has_key("month"):
		month = form["month"][0]
		str_month = functs.convert_month("0"+month)

	day = "None"
	if form.has_key("day"):
		day = form["day"][0]

	if year == "none" or year == "None":
		style.SendError("You need to specify a search date.")

	style.header("Historical Iowa Weather Data Search Engine","white")	# Standard Setup HTML Document
	style.std_top("Query Results in Iowa Weather Data")			# Standard Header Information

	print '<TABLE NOBORDER>'
	print '<TR><TH colspan="4">Search Paramenters:</TH><TH colspan="6"><font color="red">Time Constraints:</red></TH></TR>'
	print '<TR><TH bgcolor="#EEEEE">Query Option:</TH><TD>'+query_option+'</TD>'
	print '<TH bgcolor="#EEEEE">Station Option:</TH><TD>'+city_name+'</TD>'
	print '<TH bgcolor="#EEEEE"><font color="red">Year:</font></TH><TD>'+year+'</TD>'
	print '<TH bgcolor="#EEEEE"><font color="red">Month:</font></TH><TD>'+str_month+'</TD>'
	print '<TH bgcolor="#EEEEE"><font color="red">Day:</font></TH><TD>'+day+'</TD>'
	print '</TR></TABLE>'

	if city == "None":
		print '<H2 align="center"><font color="blue"><U>Please Enter a city!!</U></font></H2>'
		style.std_bot()
		sys.exit()

	results = engine.search(query_option, city, year, month, day)

	print '<HR>'

	junk_string = 'query_option='+query_option+'&city='+city+'&year='+year+'&month='+month+'&day='+day
	print '<a href="download.py?'+junk_string+'"><B>Click to download this data set</B></a>'

	print '<HR>'

	if len(results) == 0:
		print '<P>This Query did not find any results in the Database system.<BR>'
		print '<P>Please review your query above and try again.<BR>'

	else:
		print '<H2 align="center"><font color="blue"><U>Weather Data for '+city_name+', Iowa</U></font></H2>'
		table_header()
		for i in range(len(results)):
			city = results[i][0]
	                day = results[i][1]
	                climoweek = results[i][2]
	                high  = results[i][3]
	                low = results[i][4]
	                rain = results[i][5]
	                snow = results[i][6]

			result_row(city, day, str(high), str(low), str(rain), str(snow) )
		table_footer()	

	style.std_bot()