예제 #1
0
 def GET(self):
     try:
         with open('./data/ca_levels.json', 'r') as f:  # Read the monthly percentages from file
             levels = json.load(f)
     except IOError as e:  # If file does not exist
         print "File error: ", e
         levels = [100] * 12
         with open('./data/ca_levels.json', 'w') as f:  # write default percentages to file
             json.dump(levels, f)
     return template_render.california_monthly(levels)
예제 #2
0
 def GET(self):
     try:
         with open(u"./data/ca_levels.json",
                   u"r") as f:  # Read the monthly percentages from file
             levels = json.load(f)
     except IOError as e:  # If file does not exist
         print(u"File error: ", e)
         levels = [100] * 12
         with open(u"./data/ca_levels.json",
                   u"w") as f:  # write default percentages to file
             json.dump(levels, f)
     return template_render.california_monthly(levels)
예제 #3
0
 def GET(self):
     qdict = web.input()
     if qdict.has_key('etoZone') and qdict['etoZone']:
         z_vals = self.zone_data[int(qdict['etoZone'])-1]
     else:
         raise web.seeother('/cama')
     max_eto = max(z_vals)
     levels = []
     for i in range(12):
         levels.append(int(round((z_vals[i] / max_eto)*100)))
     if qdict.has_key('etoZone') and qdict['etoZone']:
         levels.append(int(qdict['etoZone']))
     else:
         levels.append('')
            
     return template_render.california_monthly(levels)    
예제 #4
0
    def GET(self):
        qdict = web.input()
        if u"etoZone" in qdict and qdict[u"etoZone"]:
            z_vals = self.zone_data[int(qdict[u"etoZone"]) - 1]
        else:
            raise web.seeother(u"/cama")
        max_eto = max(z_vals)
        levels = []
        for i in range(12):
            levels.append(int(round((z_vals[i] / max_eto) * 100)))
        if u"etoZone" in qdict and qdict[u"etoZone"]:
            levels.append(int(qdict[u"etoZone"]))
        else:
            levels.append(u"")

        return template_render.california_monthly(levels)
예제 #5
0
    def GET(self):
        qdict = web.input()
        if qdict.has_key('etoZone') and qdict['etoZone']:
            z_vals = self.zone_data[int(qdict['etoZone']) - 1]
        else:
            raise web.seeother('/cama')
        max_eto = max(z_vals)
        levels = []
        for i in range(12):
            levels.append(int(round((z_vals[i] / max_eto) * 100)))
        if qdict.has_key('etoZone') and qdict['etoZone']:
            levels.append(int(qdict['etoZone']))
        else:
            levels.append('')

        return template_render.california_monthly(levels)