From 82ded450759f47e8d97192098b30e755ebba9b97 Mon Sep 17 00:00:00 2001 From: Umi <982341777@qq.com> Date: Sun, 13 Aug 2017 00:24:46 -0400 Subject: [PATCH] Fix import issues when asyncpg is not installed --- .version | 2 +- minoshiro/data_controller/postgres_controller.py | 10 ++++++++-- minoshiro/data_controller/postgres_utils.py | 9 +++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.version b/.version index 6c6aa7c..6da28dd 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.1.1 \ No newline at end of file diff --git a/minoshiro/data_controller/postgres_controller.py b/minoshiro/data_controller/postgres_controller.py index 597ada1..e28e682 100644 --- a/minoshiro/data_controller/postgres_controller.py +++ b/minoshiro/data_controller/postgres_controller.py @@ -2,8 +2,14 @@ from json import dumps, loads from typing import Dict, Optional -from asyncpg import InterfaceError, create_pool -from asyncpg.pool import Pool +try: + from asyncpg import InterfaceError, create_pool + from asyncpg.pool import Pool +except ImportError: + print('asyncpg not installed, PostgresSQL function not available.') + Pool = None + InterfaceError = None + create_pool = None from minoshiro.enums import Medium, Site from minoshiro.logger import get_default_logger diff --git a/minoshiro/data_controller/postgres_utils.py b/minoshiro/data_controller/postgres_utils.py index 0b62e7e..7bc505b 100644 --- a/minoshiro/data_controller/postgres_utils.py +++ b/minoshiro/data_controller/postgres_utils.py @@ -4,8 +4,13 @@ from typing import Optional -from asyncpg import Record -from asyncpg.pool import Pool +try: + from asyncpg import Record + from asyncpg.pool import Pool +except ImportError: + Record = None + Pool = None + print('asyncpg not installed, PostgresSQL function not available.') def parse_record(record: Record) -> Optional[tuple]: