Пример #1
0
 def __init__(self, db=None):
     # 初始化redis
     path = Path.getInstance().confDirPath + "redisConf.json"
     redisConfObject = JsonFileFunc.getInstance().readFile(path)
     self.password = redisConfObject["password"]
     # self.socket_timeout = redisConfObject['socket_timeout']
     self.port = redisConfObject['port']
     self.host = redisConfObject['host']
     if db is not None:
         self.db = db
     else:
         self.db = 0
     self.pool = redis.ConnectionPool(host=self.host,
                                      port=self.port,
                                      db=self.db,
                                      password=self.password)
     pass
# print("开始队列")
# #缓冲区已经flush而且消息已经确认发送到了RabbitMQ中,关闭链接
# connection.close()

from bin.until import JsonFileFunc
from bin.until import Path
import time
import os
from bin.until import Mongo
from bin.until import Logger
from bin.logic import Statistics_BO
import json

L = Logger.getInstance()
P = Path.getInstance()
J = JsonFileFunc.getInstance()

path = P.confDirPath + os.sep + "rabbitMQ.json"
MQ_conf_info = J.readFile(path)


class RabbitMQ(object):
    def __init__(self):
        ip = MQ_conf_info['ip']
        port = None
        user = MQ_conf_info['user']
        password = MQ_conf_info['password']
        credentials = pika.PlainCredentials(user, password)
        self.connection = pika.BlockingConnection(
            pika.ConnectionParameters(ip, port, '/', credentials))
        pass
Пример #3
0
#!/usr/bin/env python
# !-*- coding:utf-8 -*-

import pymongo
from bin.until import Path
from bin.until import JsonFileFunc
import os

path = Path.getInstance().confDirPath + os.sep + "DB.json"
_db_info = JsonFileFunc.getInstance().readFile(path)


class Mongo(object):
    def __init__(self, table, db=None, ds=None, ip=None, port=None):
        self.db = None
        self.table = None
        if ds is None:
            ds = "base"
        if ip is None:
            ip = _db_info[ds]["ip"]
        if port is None:
            port = _db_info[ds]["port"]
        if db is None:
            self.db = _db_info[ds]["dbname"]
        else:
            self.db = db
        if table is None:
            self.table = "default"
        else:
            self.table = table
        user = _db_info[ds]["user"]
Пример #4
0
# print("开始队列")
# #缓冲区已经flush而且消息已经确认发送到了RabbitMQ中,关闭链接
# connection.close()

from bin.until import JsonFileFunc
from bin.until import Path
import time
import os
from bin.until import Mongo
from bin.until import Logger
from bin.logic import Statistics_BO
import json

L = Logger.getInstance()
P = Path.getInstance()
J = JsonFileFunc.getInstance()

path = P.confDirPath + os.sep + "rabbitMQ.json"
MQ_conf_info = J.readFile(path)


class RabbitMQ(object):
    def __init__(self):
        ip = MQ_conf_info['ip']
        port = None
        user = MQ_conf_info['user']
        password = MQ_conf_info['password']
        credentials = pika.PlainCredentials(user, password)
        self.connection = pika.BlockingConnection(pika.ConnectionParameters(ip, port, '/', credentials))
        pass