Exemplo n.º 1
0
 def get_last_update_run(self):
     """
       Returns the last time the database was updated.
       Ret: datetime.datetime object
       Useful for caching when polling daemons last ran. 
     """
     view = view_database_updated_docs.get_view_class()
     all_docs = view(self.get_database()) 
     if not all_docs or len(all_docs) == 0:
         self.set_last_update_run(datetime.fromtimestamp(0))
         return self.get_last_update_run()
     for id in all_docs:
         doc = UpdateDatabaseDocumentClass.load(self.get_database(), 
                                                str(id.id)) 
         return doc.time_of_last_update
     return 0
Exemplo n.º 2
0
 def set_last_update_run(self, time):
     """
       Sets the time the database was updated.
       time: datetime.datetime object
       Useful for caching when polling daemons last ran. 
     """
     view = view_database_updated_docs.get_view_class()
     all_docs = view(self.get_database()) 
     update_doc = None
     if not all_docs or len(all_docs) == 0:
         update_doc = UpdateDatabaseDocumentClass()
         update_doc._set_id("update_doc")
     else:
         for id in all_docs:
             update_doc = UpdateDatabaseDocumentClass.load(
                          self.get_database(), str(id.id)) 
             break
     update_doc.time_of_last_update = time
     update_doc.store(self.get_database())