示例#1
0
    def get(self):
        db = dm()
        data = {}
        data["time"] = []

        series = db.getTodayData()
        for t in series["time"]:
            s = '"%s"' % t
            data["time"].append(s)
        loader = tem.Loader("/home/pi/Github/Compteurs/web")

        currentIndexes = db.getLastMeasures(1)
        data["currentGasIndex"] = currentIndexes[0][2]
        data["currentElecIndex"] = currentIndexes[0][3]

        data["todayTime"] = str(series["time"])
        data["todayGas"] = str(series["gas"])
        data["todayElec"] = str(series["elec"])
        now = int(time.time())
        weekly = db.getWeeklyData()  # datetime.datetime.today().year, datetime.datetime.today().strftime("%W")
        data["weeklyTime"] = weekly["time"]
        data["weeklyGas"] = weekly["gas"]
        data["weeklyElec"] = weekly["elec"]
        data["weeklyDd"] = weekly["dd"]

        yearly = db.getYearlyData(datetime.datetime.today().year, datetime.datetime.today().month)
        data["yearlyTime"] = yearly["time"]
        data["yearlyGas"] = yearly["gas"]
        data["yearlyElec"] = yearly["elec"]
        data["yearlyDd"] = yearly["dd"]
        self.write(loader.load("dayStats.html").generate(data=data))
示例#2
0
def dataExtractor(**kwargs):
    db = dm()
    if kwargs["when"] != "":
        if kwargs["when"] == "today":
            return db.exportToJSON(db.getTodayMeasures())
        else:
            date = kwargs["when"].split("-")
            return db.exportToJSON(db.getMeasuresFromDate(date[2], date[1], date[0]))
示例#3
0
 def get(self):
     db = dm()
     mes = db.getLastMeasures(1)[0]
     loader = tem.Loader("/home/pi/Github/Compteurs/web")
     data = {}
     data["elecDailyAverage"] = 100.0
     data["elecWeeklyAverage"] = 500.0
     data["elecMonthlyAverage"] = 800.0
     data["elecDaily"] = mes[3]
     data["elecWeekly"] = 450.0
     data["elecMonthly"] = 1120.0
     data["gazDailyAverage"] = 10.0
     data["gazWeeklyAverage"] = 20.0
     data["gazMonthlyAverage"] = 40.0
     data["gazDaily"] = mes[2]
     data["gazWeekly"] = 25.0
     data["gazMonthly"] = 35.0
     self.write(loader.load("index-2.html").generate(data=data))
示例#4
0
from dataManager import dataManager as dm
db = dm()