Exemplo n.º 1
0
def __getPlot(req, plot, filename, title, xSize, ySize):
    filenameWithPath = "/tmp/%s-%sx%s.%s" % (filename.split('.')[0], xSize, ySize, filename.split('.')[1])
    db = dbHandler.dbHandler()
    g = tempPlot.tempPlot()
    if plot == 'day':
        houres = 24
    if plot == 'week':
        houres = 24 * 7
    if plot == 'month':
        houres = 24 * 7 * 30
    if plot == 'year':
        houres = 24 * 365

    # Check for new Data
    if db.hasNewData(filenameWithPath):
        data = db.getData(houres)
        g.plotToFile(data, filenameWithPath, title, int(xSize), int(ySize))
        db.writeRequest(filenameWithPath)

    # Check if file exits:
    if not os.path.exists(filenameWithPath):
        return apache.HTTP_NOT_FOUND

    req.content_type = 'image/png'
    req.sendfile(filenameWithPath)
Exemplo n.º 2
0
 def setUp(self):
     self.plot = tempPlot()
     pass