Exemplo n.º 1
0
Arquivo: rrd.py Projeto: marcoazza/rrd
  def __init__(self,db_name=None):
    if db_name is None:
      db_name = 'rrd.db'

    self.db = DB(db_name)
    self.last_day = [None]*24
    self.last_hour = [None]*60

    t = time.time()
    self.start_h, self.end_h = wnd_1(t)
    self.start_d, self.end_d = wnd_24(t)
Exemplo n.º 2
0
  def test_save_hour(self):
    epoch = trunc_to_min(time.time())
    expired_data = [ (epoch + HOUR -x*MIN,x-2) for x in xrange(0,10)]
    for e in expired_data:
      self.rrd.save(e[0],e[1])
    retrive_data = self.rrd.db.fetch_all('hours',wnd_1(epoch))
    self.assertEqual([], retrive_data)

    valid_data = [(epoch -x*MIN,float(x+1)) for x in xrange(0,10)]
    valid_data.reverse()

    for e in valid_data:
      self.rrd.save(e[0],e[1])

    min_el = valid_data.pop()
    el = (trunc_to_hour(min_el[0]),min_el[1])
    self.assertEqual([el], self.rrd.db.fetch_all('hours',wnd_24(epoch)))
Exemplo n.º 3
0
Arquivo: rrd.py Projeto: marcoazza/rrd
 def inner(self,*args, **kwargs):
   t = time.time()
   self.start_h, self.end_h = wnd_1(t)
   self.start_d, self.end_d = wnd_24(t)
   return func(self,*args, **kwargs)