def process_update (request,path): try: pest = None altref = None tech_choice = 'conventional' # retrieve input if path is None: if request and request.form: try: if request.form.has_key('pest'): pest = request.form['pest'] if request.form.has_key('altref'): altref = request.form['altref'] if request.form.has_key('tech_choice'): tech_choice = request.form['tech_choice'] except: print_exception() raise program_exit('Error processing request') else: return newaCommon_io.errmsg('Error processing form; check input') else: return newaCommon_io.errmsg('Error processing input') # send input to appropriate routine if pest and altref: return Crucifer().run_crucifer_update(pest,altref,tech_choice) else: return newaCommon_io.errmsg('Error processing input') except program_exit,msg: print msg return newaCommon_io.errmsg('Error processing input')
def run_stateInactiveStationList(options): try: reqvar = options['reqvar'] state = options['state'] if state == '': state = 'ALL' station_dict = {} station_dict['stations'] = [] unsortedDict = {} try: # only line that's different from stateStationList exec("from stn_info_" + state.lower() + "_inactive import stn_info") except: pass for stn in stn_info.keys(): if (reqvar == 'lwrh' and 'lwet' in stn_info[stn]['vars'] and 'rhum' in stn_info[stn]['vars']) \ or (reqvar == 'eslw' and ('lwet' in stn_info[stn]['vars'] or 'rhum' in stn_info[stn]['vars'])) \ or reqvar == 'all' or reqvar in stn_info[stn]['vars']\ or (reqvar == 'goodsr' and stn_info[stn].has_key('srqual') and stn_info[stn]['srqual'] == 'ok')\ or (reqvar == 'srad' and stn_info[stn]['network'] == 'icao'): sdict = {} sdict['id'] = stn for item in ['lat','lon','elev','name','network','state']: sdict[item] = stn_info[stn][item] unsortedDict[stn_info[stn]['name']] = sdict sortedKeys = unsortedDict.keys() sortedKeys.sort() #return alphabetized list for usk in sortedKeys: station_dict['stations'].append(unsortedDict[usk]) json_return = json.dumps(station_dict) return json_return except: return newaCommon_io.errmsg('Error processing request')
def get_hourly2 (self, stn, start_date_dt, end_date_dt): hourly_data = [] download_time = '' station_name = '' avail_vars = [] try: if stn[0:1] >= '1' and stn[0:1] <= '9' and stn[1:2] >= '0' and stn[1:2] <= '9': station_type = 'njwx' elif len(stn) == 4: station_type = 'icao' elif stn[0:3] == "cu_" or stn[0:3] == "um_" or stn[0:3] == "uc_" or stn[0:3] == "un_": station_type = 'cu_log' elif stn[0:3] == "ew_": stn = stn[3:] station_type = 'miwx' elif len(stn) == 3 or len(stn) == 6: station_type = 'newa' else: return newaCommon_io.errmsg('Error processing form; check station input') # get ucanid and station name from metadata ucanid,station_name = get_metadata (stn, station_type) if station_type == 'icao': staid = stn.upper() else: staid = ucanid # obtain all hourly data for station hourly_data,daily_data,avail_vars = get_newa_data (staid,stn,start_date_dt,end_date_dt,station_type) if len(hourly_data) > 0: # save time of last hour downloaded download_time = hourly_data[-1][0] except: print_exception() return hourly_data, download_time, station_name, avail_vars
def run_stationList(list_options='all'): try: from stn_info import stn_info station_dict = {} station_dict['stations'] = [] unsortedDict = {} for stn in stn_info.keys(): if (list_options == 'lwrh' and 'lwet' in stn_info[stn]['vars'] and 'rhum' in stn_info[stn]['vars']) \ or (list_options == 'eslw' and ('lwet' in stn_info[stn]['vars'] or 'rhum' in stn_info[stn]['vars'])) \ or list_options == 'all' or list_options in stn_info[stn]['vars']\ or (list_options == 'goodsr' and stn_info[stn].has_key('srqual') and stn_info[stn]['srqual'] == 'ok')\ or (list_options == 'srad' and stn_info[stn]['network'] == 'icao'): sdict = {} sdict['id'] = stn for item in ['lat','lon','elev','name','network','state']: sdict[item] = stn_info[stn][item] unsortedDict[stn_info[stn]['name']] = sdict unsortedKeys = unsortedDict.keys() unsortedKeys.sort() for state in ['NY','VT','MA','NH','RI','CT','NJ','PA','DE','ME','NH','WI','IA','NE']: for usk in unsortedKeys: if state == unsortedDict[usk]['state']: station_dict['stations'].append(unsortedDict[usk]) json_return = json.dumps(station_dict) return json_return except: return newaCommon_io.errmsg('Error processing request')
def get_metadata (station_id,id_type=None): ucanid = None station_name = station_id try: if not id_type: if station_id[0:1] >= '1' and station_id[0:1] <= '9' and station_id[1:2] >= '0' and station_id[1:2] <= '9': id_type = 'njwx' elif len(station_id) == 4: id_type = 'icao' elif station_id[0:3] == "cu_" or station_id[0:3] == "um_" or station_id[0:3] == "uc_" or station_id[0:3] == "un_": id_type = 'cu_log' elif station_id[0:3] == "ew_": station_id = station_id[3:] id_type = 'miwx' elif len(station_id) == 3 or len(station_id) == 6: id_type = 'newa' else: return newaCommon_io.errmsg('Error processing form; check station input') elif id_type == 'miwx' and len(station_id) == 6: station_id = station_id[3:] query = ucan.get_query() r = query.getUcanFromIdAsSeq(station_id,id_type) if len(r) > 0: ucanid = r[-1].ucan_id info = query.getInfoForUcanIdAsSeq(ucanid,()) fields = ucanCallMethods.NameAny_to_dict(info[-1].fields) station_name = fields['name'] query.release() except: print 'Error getting metadata for',station_id,id_type print_exception() if not query._non_existent(): query.release() raise return ucanid, station_name
def run_stationSisterInfo(options): from sister_info import sister_info try: stn = options['station'] network = options['network'] sister_dict = {} if network == 'miwx' and stn[0:3] != 'ew_': stn = "ew_%s" % stn if sister_info.has_key(stn): sister = sister_info[stn] for var in sister.keys(): if sister[var][0:1] >= '1' and sister[var][0:1] <= '9' and sister[var][1:2] >= '0' and sister[var][1:2] <= '9': station_type = 'njwx' elif len(sister[var]) == 4: station_type = "icao" elif sister[var][0:3] == "cu_" or sister[var][0:3] == "um_" or sister[var][0:3] == "uc_" or sister[var][0:3] == "un_": station_type = "culog" elif sister[var][0:3] == "ew_": sister[var] = sister[var][3:] station_type = 'miwx' else: station_type = "newa" sister_dict[var] = "%s %s" % (sister[var], station_type) json_return = json.dumps(sister_dict) return json_return except: return newaCommon_io.errmsg('Error processing request')
def run_crucifer_disease(self, stn, pest, accend, tech_choice, output): try: smry_dict = {} smry_dict['pest'] = pest if not accend: accend = DateTime.now() smry_dict['output'] = output if output == 'standalone': smry_dict['stn'] = stn smry_dict['accend'] = accend # determine information needed for particular disease pest_status_management = import_info_dict(pest) if not pest_status_management: return newaCommon_io.errmsg('A model is not available for the disease you selected.') smry_dict['pest_name'] = pest_status_management['pest_name'] smry_dict['crop_stages'] = pest_status_management['messages'].keys() # get station name - don't need this for Crucifers # ucanid,smry_dict['station_name'] = get_metadata (stn) # get status and recommendations smry_dict['stage'] = "Not defined" smry_dict['status'] = "Not defined" smry_dict['manage'] = "Not defined" for k in smry_dict['crop_stages']: psmk = pest_status_management['messages'][k] if psmk.has_key('datelo'): datelo = DateTime.DateTime(accend.year,*psmk['datelo']) datehi = DateTime.DateTime(accend.year,*psmk['datehi']) if accend >= datelo and accend <= datehi: smry_dict = self.filldict(psmk,k,tech_choice,smry_dict) break else: # didn't fall within any date ranges; now get dd values and check dd ranges start_date_dt = DateTime.DateTime(accend.year,1,1) daily_data, station_name = self.get_daily (stn, start_date_dt, accend) smry_dict['station_name'] = station_name if len(daily_data) > 0: degday_data = self.degday_calcs (daily_data,start_date_dt,accend,'dd4c','accum') if len(degday_data) > 0 and degday_data[-1][4] != miss: ddaccum = degday_data[-1][4] for k in smry_dict['crop_stages']: psmk = pest_status_management['messages'][k] if psmk.has_key('ddlo'): if ddaccum >= psmk['ddlo'] and ddaccum <= psmk['ddhi']: smry_dict = self.filldict(psmk,k,tech_choice,smry_dict) break else: print "Error determining recommendations:",pest,stn,accend else: return self.nodata(stn, station_name, start_date_dt, accend) else: return self.nodata(stn, station_name, start_date_dt, accend) return newaVegModel_io.crucifer_results(smry_dict) except: print_exception()
def process_help (request,path): try: smry_type = None pest = None tech_choice = 'conventional' # retrieve input if path is None: if request and request.form: # print 'update form:',request.form try: smry_type = request.form['type'].strip() if request.form.has_key('pest'): pest = request.form['pest'] if request.form.has_key('tech_choice'): tech_choice = request.form['tech_choice'] except: print_exception() raise program_exit('Error processing help form') else: return newaCommon_io.errmsg('Error processing help form; check input') elif path[0] in ['crucifer_disease']: try: smry_type = path[0] pest = path[1] except IndexError: raise program_exit('Error processing help form - index error') except: print_exception() raise program_exit('Error processing help form') else: try: smry_type = path[0] pest = path[0] except IndexError: raise program_exit('Error processing help form - index error') except: print_exception() raise program_exit('Error processing help form') # send input to appropriate routine if pest: return Crucifer().run_crucifer_help(pest,tech_choice) else: return newaCommon_io.errmsg('Error processing help input') except program_exit,msg: print msg return newaCommon_io.errmsg('Error processing help input')
def run_ddrange(stn, ddtype, accstr, accend): try: base = newaCommon.Base() cabbage = newaDisease.Cabbage() smry_dict = {"ddtype": ddtype.replace("dd", "")} now = DateTime.now() if not accend: accend = now end_date_dt = accend if not accstr: accstr = DateTime.DateTime(end_date_dt.year, 1, 1, 0) start_date_dt = accstr if start_date_dt > end_date_dt: return newaCommon_io.errmsg("Start date must be before end data.") if end_date_dt.year != now.year: smry_dict["this_year"] = False end_date_dt = end_date_dt + DateTime.RelativeDate(days=+6) else: smry_dict["this_year"] = True hourly_data, daily_data, download_time, station_name, avail_vars = base.get_hddata2( stn, start_date_dt, end_date_dt ) smry_dict["last_time"] = download_time # add forecast data if smry_dict["this_year"]: start_fcst_dt = DateTime.DateTime(*download_time) + DateTime.RelativeDate(hours=+1) end_fcst_dt = end_date_dt + DateTime.RelativeDate(days=+6) hourly_data = newaDisease.add_hrly_fcst(stn, hourly_data, start_fcst_dt, end_fcst_dt) daily_data = newaDisease.hrly_to_dly(hourly_data) else: start_fcst_dt = end_date_dt + DateTime.RelativeDate(hours=+1) end_fcst_dt = end_date_dt end_date_dt = end_date_dt + DateTime.RelativeDate(days=-6) if len(daily_data) > 0: degday_dict = base.degday_calcs(daily_data, start_date_dt, end_fcst_dt, ddtype, "accum") if len(degday_dict) > 0: # get dates for gdd table smry_dict = cabbage.setup_dates(smry_dict, end_date_dt) # get dd for days of interest (including forecast) smry_dict = cabbage.add_ddays(smry_dict, degday_dict, start_date_dt, end_date_dt) return newaLister_io.ddrange_html(station_name, smry_dict, degday_dict) else: return self.nodata(stn, station_name, start_date_dt, end_date_dt) else: return self.nodata(stn, station_name, start_date_dt, end_date_dt) except: print_exception() return
def getForecastUrl(stn): forecastUrl = "" try: from stn_info import stn_info if not stn_info.has_key(stn): from stn_info_ma import stn_info lat = stn_info[stn]['lat'] lon = stn_info[stn]['lon'] forecastUrl = 'http://forecast.weather.gov/MapClick.php?textField1=%s&textField2=%s' % (lat,lon) return forecastUrl except: return newaCommon_io.errmsg('Error processing request') return forecastUrl
def process_input (request,path): try: # retrieve input if path[0] in ['stationList','stateStationList','stateInactiveStationList','diseaseStations','getForecastUrl','stationInfo','stationModels']: try: smry_type = path[0] if len(path) > 1: if path[0] == 'stateStationList' or path[0] == 'stateInactiveStationList': list_options = {} list_options['reqvar'] = path[1] if len(path) > 2: list_options['state'] = path[2].upper() else: list_options['state'] = '' else: list_options = path[1] if list_options == 'robots.txt': return newaUtil_io.robots() else: list_options = None except IndexError: raise program_exit('Error processing request') except: print_exception() raise program_exit('Error processing request') elif path[0] == 'robots.txt': return newaUtil_io.robots() else: return program_exit('Error processing input') # send input to appropriate routine if smry_type == 'stationList': return run_stationList(list_options) if smry_type == 'stateStationList': return run_stateStationList(list_options) if smry_type == 'stateInactiveStationList': return run_stateInactiveStationList(list_options) if smry_type == 'stationInfo': return run_stationInfo(list_options) if smry_type == 'stationModels': return run_stationModels(list_options) elif smry_type == 'diseaseStations': return run_diseaseStations(list_options) elif smry_type == 'getForecastUrl': return getForecastUrl(list_options) else: return program_exit('Error processing request') except program_exit,msg: print msg return newaCommon_io.errmsg('Error processing request')
def run_crucifer_help (self,pest,tech_choice): try: pest_status_management = import_info_dict(pest) if pest_status_management: key_char = pest_status_management['keychar_oc'] if tech_choice == 'organic': key_char += pest_status_management['keychar_o'] else: key_char += pest_status_management['keychar_c'] help_links = [(key_char,"")] for htup in pest_status_management['help_links']: help_links.append(htup) return newaVegModel_io.helppage(help_links) else: return newaCommon_io.errmsg('Help is not available for the disease you selected.') except: print_exception()
def run_crucifer_update (self,pest,altref,tech_choice): try: smry_dict = {} # determine information needed for calculations for particular disease pest_status_management = import_info_dict(pest) if not pest_status_management: return newaCommon_io.errmsg('A model is not available for the disease you selected.') if pest_status_management['messages'].has_key(altref): psmk = pest_status_management['messages'][altref] smry_dict['crop_stages'] = pest_status_management['messages'].keys() smry_dict = self.filldict(psmk,altref,tech_choice,smry_dict) else: smry_dict['stage'] = "Not defined" smry_dict['status'] = "Not defined" smry_dict['manage'] = "Not defined" return newaVegModel_io.crucifer_sm_table(smry_dict) except: print_exception()
def process_input (request,path): try: stn = None year = None greentip = None firstblossom = None orchard_history = None accend = None output = "tab" # retrieve input if path is None: if request and request.form: try: smry_type = request.form['type'].strip() if request.form.has_key('stn'): stn = request.form['stn'].strip() if request.form.has_key('orchard_history'): orchard_history = int(request.form['orchard_history']) if request.form.has_key('year'): year = int(request.form['year']) if request.form.has_key('output'): output = request.form['output'] if request.form.has_key('greentip'): try: mm,dd,yy = request.form['greentip'].split("/") greentip = DateTime.DateTime(int(yy),int(mm),int(dd),23) except: greentip = None if request.form.has_key('firstblossom'): try: mm,dd,yy = request.form['firstblossom'].split("/") firstblossom = DateTime.DateTime(int(yy),int(mm),int(dd),23) except: firstblossom = None if request.form.has_key('accend'): try: mm,dd,yy = request.form['accend'].split("/") accend = DateTime.DateTime(int(yy),int(mm),int(dd),23) except: accend = None except: print_exception() raise program_exit('Error processing request') else: return newaCommon_io.errmsg('Error processing form; check input') elif path[0] in ['apple_scab_grf','fire_blight_grf']: try: smry_type = path[0] stn = path[1] if len(path) > 2: year = int(path[2]) output = "standalone" except IndexError: raise program_exit('Error processing request - index error') except: print_exception() raise program_exit('Error processing request') else: return newaCommon_io.errmsg('Error processing input') if not accend: now = DateTime.now() if year and year != 9999 and year != now.year: accend = DateTime.DateTime(year,6,15,23) # send input to appropriate routine if stn: if smry_type == 'apple_scab_grf': return run_apple_scab_plots (stn,accend,greentip,output) elif smry_type == 'fire_blight_grf': return run_fire_blight_plots (stn,accend,firstblossom,orchard_history,output) else: return newaCommon_io.errmsg('Error processing form; check input') else: return newaCommon_io.errmsg('Error processing form; select station') except program_exit,msg: print msg return newaCommon_io.errmsg('Error processing form; check input')
def process_input(request, path): try: # retrieve input if path is None: if request and request.form: try: stn = request.form["stn"].strip() smry_type = request.form["type"].strip() if request.form.has_key("month"): month = int(request.form["month"]) else: month = None if request.form.has_key("year"): year = int(request.form["year"]) else: year = None if request.form.has_key("accend"): try: mm, dd, yy = request.form["accend"].split("/") accend = DateTime.DateTime(int(yy), int(mm), int(dd), 23) except: accend = None else: accend = None if request.form.has_key("accstr"): try: mm, dd, yy = request.form["accstr"].split("/") accstr = DateTime.DateTime(int(yy), int(mm), int(dd), 0) except: accstr = None else: accstr = None if request.form.has_key("ddtype"): ddtype = request.form["ddtype"].strip() else: ddtype = None except: print_exception() raise program_exit("Error processing request") else: return newaCommon_io.errmsg("Error processing request; check input") elif path[0] in ("dly", "hly") or path[0][0:2] == "dd": try: smry_type = path[0] stn = path[1] year = int(path[2]) month = int(path[3]) except IndexError: raise program_exit("Error processing request - index error") except: print_exception() raise program_exit("Error processing request") elif path[0] == "est_info": try: smry_type = path[0] stn = path[1] if len(path) > 2: year = int(path[2]) month = int(path[3]) else: now = DateTime.now() year = now.year month = now.month except IndexError: raise program_exit("Error processing request - index error") except: print_exception() raise program_exit("Error processing request") else: return newaCommon_io.errmsg("Error processing input") if smry_type == "ddrange": return run_ddrange(stn, ddtype, accstr, accend) if year and year == 9999: now = DateTime.now() year = now.year req_date_dt = DateTime.DateTime(year, month, 1, 0) if smry_type == "hly" or smry_type == "dly": start_date_dt = req_date_dt else: start_date_dt = DateTime.DateTime(year, 1, 1, 0) end_date_dt = req_date_dt + DateTime.RelativeDate(months=+1) if stn[0:1] >= "1" and stn[0:1] <= "9" and stn[1:2] >= "0" and stn[1:2] <= "9": station_type = "njwx" elif len(stn) == 4: station_type = "icao" elif stn[0:3] == "cu_" or stn[0:3] == "um_" or stn[0:3] == "uc_" or stn[0:3] == "un_": station_type = "cu_log" elif len(stn) == 3 or len(stn) == 6: station_type = "newa" else: return newaCommon_io.errmsg("Error processing request; check station input") # get ucanid and station name from metadata ucanid, station_name = newaCommon.get_metadata(stn, station_type) if station_type == "icao": staid = stn.upper() else: staid = ucanid if smry_type == "est_info": var_sister = get_sister_info(stn) return newaLister_io.estimation_info(stn, station_name, var_sister, year, month) # obtain all hourly and daily data for station hourly_data, daily_data, avail_vars = newaCommon.get_newa_data( staid, stn, start_date_dt, end_date_dt, station_type ) if len(avail_vars) > 0: if smry_type == "dly": monthly_data = monthly_summary(daily_data, year, month) numcols = len(avail_vars) if "dwpt" in avail_vars: numcols = numcols - 1 # not used if "temp" in avail_vars: numcols = numcols + 2 # max, min, avg if "st4i" in avail_vars: numcols = numcols + 2 # max, min, avg return newaLister_io.dly_list_html( stn, station_name, year, month, daily_data, monthly_data, avail_vars, numcols, miss ) elif smry_type == "hly": if "dwpt" not in avail_vars and "temp" in avail_vars and "rhum" in avail_vars: avail_vars.append("dwpt") return newaLister_io.hly_list_html( stn, station_name, year, month, hourly_data, avail_vars, miss, station_type ) if smry_type in [ "dd4c", "dd143c", "dd32", "dd39", "dd40", "dd43", "dd45", "dd48", "dd50", "dd8650", "dd55", "dd43be", "dd50be", "dd4714", ]: degday_data, degday_miss = degday_summary(daily_data, year, month, smry_type) if len(degday_data) == 0: # no data - try to provide additional information if newaCommon.sta_por.has_key(stn): bd, ed = newaCommon.sta_por[stn] spor_dt = DateTime.DateTime(int(bd[0:4]), int(bd[4:6]), int(bd[6:8])) if ed == "99991231": epor_dt = DateTime.now() else: epor_dt = DateTime.DateTime(int(ed[0:4]), int(ed[4:6]), int(ed[6:8])) if req_date_dt < spor_dt: addl_line = "Data for %s starts %d/%d" % (station_name, spor_dt.month, spor_dt.year) elif end_date_dt > epor_dt: addl_line = "Data for %s have been collected up to %d/%d" % ( station_name, epor_dt.month, epor_dt.year, ) else: addl_line = None else: addl_line = None return newaCommon_io.nodata(addl_line) return newaLister_io.degday_list_html( stn, station_name, year, month, degday_data, degday_miss, miss, smry_type ) else: return newaCommon_io.errmsg("Error processing request") else: # no data - try to provide additional information if newaCommon.sta_por.has_key(stn): bd, ed = newaCommon.sta_por[stn] spor_dt = DateTime.DateTime(int(bd[0:4]), int(bd[4:6]), int(bd[6:8])) if ed == "99991231": epor_dt = DateTime.now() else: epor_dt = DateTime.DateTime(int(ed[0:4]), int(ed[4:6]), int(ed[6:8])) if req_date_dt < spor_dt: addl_line = "Data for %s starts %d/%d" % (station_name, spor_dt.month, spor_dt.year) elif end_date_dt > epor_dt: addl_line = "Data for %s has been collected up to %d/%d" % ( station_name, epor_dt.month, epor_dt.year, ) else: addl_line = None else: addl_line = None return newaCommon_io.nodata(addl_line) except program_exit, logmsg: print logmsg return newaCommon_io.errmsg("Error processing request; check input")
else: # no data - try to provide additional information if newaCommon.sta_por.has_key(stn): bd, ed = newaCommon.sta_por[stn] spor_dt = DateTime.DateTime(int(bd[0:4]), int(bd[4:6]), int(bd[6:8])) if ed == "99991231": epor_dt = DateTime.now() else: epor_dt = DateTime.DateTime(int(ed[0:4]), int(ed[4:6]), int(ed[6:8])) if req_date_dt < spor_dt: addl_line = "Data for %s starts %d/%d" % (station_name, spor_dt.month, spor_dt.year) elif end_date_dt > epor_dt: addl_line = "Data for %s has been collected up to %d/%d" % ( station_name, epor_dt.month, epor_dt.year, ) else: addl_line = None else: addl_line = None return newaCommon_io.nodata(addl_line) except program_exit, logmsg: print logmsg return newaCommon_io.errmsg("Error processing request; check input") except: if request and request.form: print "Exception - form is", request.form print_exception() return newaCommon_io.errmsg("Unexpected error")
list_options = None except IndexError: raise program_exit('Error processing request') except: print_exception() raise program_exit('Error processing request') elif path[0] == 'robots.txt': return newaUtil_io.robots() else: return program_exit('Error processing input') # send input to appropriate routine if smry_type == 'stationList': return run_stationList(list_options) if smry_type == 'stationInfo': return run_stationInfo(list_options) if smry_type == 'stationModels': return run_stationModels(list_options) elif smry_type == 'diseaseStations': return run_diseaseStations(list_options) elif smry_type == 'getForecastUrl': return getForecastUrl(list_options) else: return program_exit('Error processing request') except program_exit,msg: print msg return newaCommon_io.errmsg('Error processing request') except: print_exception() return newaCommon_io.errmsg('Unexpected error')
def process_input (request,path): try: stn = None accend = None pest = None tech_choice = "conventional" output = "tab" # retrieve input if path is None: if request and request.form: # print 'form',request.form try: smry_type = request.form['type'].strip() if request.form.has_key('stn'): stn = request.form['stn'].strip() if request.form.has_key('pest'): pest = request.form['pest'] if request.form.has_key('tech_choice'): tech_choice = request.form['tech_choice'] if request.form.has_key('output'): output = request.form['output'] if request.form.has_key('accend'): try: mm,dd,yy = request.form['accend'].split("/") accend = DateTime.DateTime(int(yy),int(mm),int(dd),23) except: accend = None except: print_exception() raise program_exit('Error processing request') else: return newaCommon_io.errmsg('Error processing form; check input') elif path[0] in ['crucifer_disease']: # print 'path:',path try: smry_type = path[0] pest = path[1] if len(path) > 2: stn = path[2] output = "standalone" except IndexError: raise program_exit('Error processing request - index error') except: print_exception() raise program_exit('Error processing request') else: # print 'path:',path try: smry_type = path[0] pest = path[0] if len(path) > 1: stn = path[1] output = "standalone" except IndexError: raise program_exit('Error processing request - index error') except: print_exception() raise program_exit('Error processing request') # send input to appropriate routine if pest: return Crucifer().run_crucifer_disease(stn,pest,accend,tech_choice,output) else: return newaCommon_io.errmsg('Error processing form; check disease') except program_exit,msg: print msg return newaCommon_io.errmsg('Error processing form; check input')
else: return newaCommon_io.errmsg('Error processing form; check input') else: return newaCommon_io.errmsg('Error processing input') # send input to appropriate routine if pest and altref: return Crucifer().run_crucifer_update(pest,altref,tech_choice) else: return newaCommon_io.errmsg('Error processing input') except program_exit,msg: print msg return newaCommon_io.errmsg('Error processing input') except: print_exception() return newaCommon_io.errmsg('Unexpected error') #-------------------------------------------------------------------------------------------- def process_help (request,path): try: smry_type = None pest = None tech_choice = 'conventional' # retrieve input if path is None: if request and request.form: # print 'update form:',request.form try: smry_type = request.form['type'].strip() if request.form.has_key('pest'): pest = request.form['pest'] if request.form.has_key('tech_choice'): tech_choice = request.form['tech_choice']