Beispiel #1
0
 def __init__(self):
     LOGGER = Log().color_log()
     self.db = None
     self.client = None
Beispiel #2
0
import base64
import json
import time
import pymongo
from datetime import datetime
from dateutil.parser import parse
from history import conf
from dojot.module import Messenger, Config
from dojot.module.logger import Log

LOGGER = Log().color_log()


class Persister:
    def __init__(self):
        LOGGER = Log().color_log()
        self.db = None
        self.client = None

    def init_mongodb(self, collection_name=None):
        """
        MongoDB initialization

        :type collection_name: str
        :param collection_name: collection to create index
        """
        try:
            self.client = pymongo.MongoClient(conf.db_host,
                                              replicaSet=conf.db_replica_set)
            self.db = self.client['device_history']
            if collection_name: