Пример #1
0
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import asyncio
import sys

from motor import motor_asyncio
from pymongo import MongoClient
from pymongo.errors import ServerSelectionTimeoutError

from hitsuki import log
from hitsuki.config import CONFIG

# Init MongoDB
mongodb = MongoClient(CONFIG.mongo_host, CONFIG.mongo_port)[CONFIG.mongo_db]
motor = motor_asyncio.AsyncIOMotorClient(CONFIG.mongo_host, CONFIG.mongo_port)
db = motor[CONFIG.mongo_db]

try:
    asyncio.get_event_loop().run_until_complete(motor.server_info())
except ServerSelectionTimeoutError:
    sys.exit(log.critical("Can't connect to mongodb! Exiting..."))
Пример #2
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

import redis as redis_lib

from hitsuki import log
from hitsuki.config import get_str_key, get_int_key

# Init Redis
redis = redis_lib.StrictRedis(host=get_str_key("REDIS_URI"),
                              port=get_str_key("REDIS_PORT"),
                              db=get_int_key("REDIS_DB_FSM"),
                              decode_responses=True)

bredis = redis_lib.StrictRedis(host=get_str_key("REDIS_URI"),
                               port=get_str_key("REDIS_PORT"),
                               db=get_int_key("REDIS_DB_FSM"))

try:
    redis.ping()
except redis_lib.ConnectionError:
    sys.exit(log.critical("Can't connect to RedisDB! Exiting..."))
Пример #3
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

import redis as redis_lib

from hitsuki import log
from hitsuki.config import CONFIG

# Init Redis
redis = redis_lib.StrictRedis(host=CONFIG.redis_host,
                              port=CONFIG.redis_port,
                              db=CONFIG.redis_db_fsm,
                              decode_responses=True)

bredis = redis_lib.StrictRedis(host=CONFIG.redis_host,
                               port=CONFIG.redis_port,
                               db=CONFIG.redis_db_fsm)

try:
    redis.ping()
except redis_lib.ConnectionError as err:
    sys.exit(
        log.critical("Can't connect to RedisDB! Exiting... Exception: " +
                     str(err)))