Beispiel #1
0
    def connect(self, conf):
        if self.redis is None:
            client = connect_redis(conf)
            self.redis = client

            return client

        return self.redis
Beispiel #2
0
        root_path = os.path.dirname(os.path.abspath(__file__))
        config_file = os.path.join(root_path, 'configs', 'topology.ini')

        conf = ConfigLoader(config_file)
        result_redis = conf.redis_configloder()
        result_mysql = conf.mysql_configloder()

        if result_redis is False or result_mysql is False:
            raise ConfigError('Failed configloader...')

        mysql_client = connect_mysql(conf)
        if mysql_client:
            cur = mysql_client.cursor(DictCursor)

            connect_redis = connect_redis(conf)
            if connect_redis:
                while True:
                    try:
                        data = pop_redis(connect_redis, conf)
                        logging.debug('data = %s' % data)

                        if data:
                            succsess_parse_data = parse_data(data, cur)
                            logging.debug('succsess_parse_data = %s'
                                          % succsess_parse_data)

                            if succsess_parse_data is True:
                                mysql_client.commit()
                                logging.info('-----------COMMIT-----------')
                            else: