def _search_by_level(self, collection, timestamp, unprocessed_only): """ method iterated thru all documents in all timetable collections and builds tree of known system state""" resp = dict() try: if unprocessed_only: query = { AbstractModel.TIMESTAMP : {'$regex': timestamp }, TimeTableEntry.STATE : {'$ne' : TimeTableEntry.STATE_PROCESSED }} else: query = { AbstractModel.TIMESTAMP : {'$regex': timestamp }} cursor = collection.find(query) if cursor.count() == 0: self.logger.warning('No TimeTable Records in %s.' % str(collection)) else: for document in cursor: obj = TimeTableEntry(document) key = (obj.get_process_name(), obj.get_timestamp()) resp[key] = obj print(key) except Exception as e: self.logger.error('ProcessingStatements error: %s' % str(e)) return resp