From 2dab59cf8cdc9f20664468a3deafeab103be60a2 Mon Sep 17 00:00:00 2001 From: gongzt Date: Thu, 3 Sep 2020 09:43:36 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E6=88=96=E5=86=85=E5=AE=B9=E9=94=99=E8=AF=AF=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=91=BD=E4=BB=A4=E8=A1=8C=E4=B8=AD=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BF=A1=E6=81=AF=E5=86=85=E5=AE=B9=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apps/package/function/constants.py | 10 +++++++--- .../application/apps/package/view.py | 5 +++++ .../application/initsystem/data_import.py | 19 ++++++++++--------- .../packageship/libs/exception/__init__.py | 7 ++++++- packageship/packageship/libs/exception/ext.py | 9 +++++++++ 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/packageship/packageship/application/apps/package/function/constants.py b/packageship/packageship/application/apps/package/function/constants.py index a387e1a8..083881ce 100644 --- a/packageship/packageship/application/apps/package/function/constants.py +++ b/packageship/packageship/application/apps/package/function/constants.py @@ -85,16 +85,20 @@ class ResponseCode(): TABLE_NAME_NOT_EXIST_IN_DATABASE: "the table name dose not match the existed database", YAML_FILE_ERROR: "Data error in yaml file", EMPTY_FOLDER: "This is an empty folder, no yaml file" - } + } @classmethod - def response_json(cls, code, data=None): + def response_json(cls, code, data=None, msg=None): """ Description: classmethod """ + try: + _msg = cls.CODE_MSG_MAP[code] + except KeyError: + _msg = msg return { "code": code, - "msg": cls.CODE_MSG_MAP[code], + "msg": _msg, "data": data } diff --git a/packageship/packageship/application/apps/package/view.py b/packageship/packageship/application/apps/package/view.py index 807b4515..f69ffb78 100644 --- a/packageship/packageship/application/apps/package/view.py +++ b/packageship/packageship/application/apps/package/view.py @@ -17,6 +17,7 @@ from packageship.libs.configutils.readconfig import ReadConfig from packageship.libs.exception import Error from packageship.libs.exception import ContentNoneException from packageship.libs.exception import DataMergeException +from packageship.libs.exception import ConfigurationException from packageship.libs.log import Log from packageship.system_config import DATABASE_FILE_INFO from .function.constants import ResponseCode @@ -581,6 +582,10 @@ class InitSystem(Resource): except TypeError as type_error: LOGGER.logger.error(type_error) abnormal = ResponseCode.TYPE_ERROR + except ConfigurationException as error: + LOGGER.logger.error(error) + abnormal = error + return jsonify(ResponseCode.response_json('5000', msg=abnormal.message)) except DataMergeException as data_merge_error: LOGGER.logger.error(data_merge_error) abnormal = ResponseCode.DATA_MERGE_ERROR diff --git a/packageship/packageship/application/initsystem/data_import.py b/packageship/packageship/application/initsystem/data_import.py index 1fda79f0..a797eeb7 100644 --- a/packageship/packageship/application/initsystem/data_import.py +++ b/packageship/packageship/application/initsystem/data_import.py @@ -12,6 +12,7 @@ from packageship.libs.dbutils.sqlalchemy_helper import DBHelper from packageship.libs.exception import ContentNoneException from packageship.libs.exception import DatabaseRepeatException from packageship.libs.exception import Error +from packageship.libs.exception import ConfigurationException from packageship.libs.configutils.readconfig import ReadConfig from packageship.libs.log import Log from packageship.application.models.package import SrcPack @@ -90,21 +91,21 @@ class InitDataBase(): init_database_config = yaml.load( file_context.read(), Loader=yaml.FullLoader) except yaml.YAMLError as yaml_error: - raise Error( - 'The format of the yaml configuration file is wrong, please check and try again\ - :%s' % yaml_error) + + raise ConfigurationException(' '.join("The format of the yaml configuration\ + file is wrong please check and try again:{0}".format(yaml_error).split())) if init_database_config is None: - raise ContentNoneException( + raise ConfigurationException( 'The content of the database initialization configuration file cannot be empty') if not isinstance(init_database_config, list): - raise TypeError( - 'The format of the initial database configuration file is incorrect:%s' - % self.config_file_path) + raise ConfigurationException( + ' '.join('The format of the initial database configuration\ + file is incorrect:{}'.format(self.config_file_path).split())) for config_item in init_database_config: if not isinstance(config_item, dict): - raise TypeError('The format of the initial database configuration file is \ - incorrect:%s' % self.config_file_path) + raise ConfigurationException(' '.join('The format of the initial database \ + configuration file is incorrect:{}'.format(self.config_file_path).split())) return init_database_config def init_data(self): diff --git a/packageship/packageship/libs/exception/__init__.py b/packageship/packageship/libs/exception/__init__.py index 38fdb8dd..ed34e581 100644 --- a/packageship/packageship/libs/exception/__init__.py +++ b/packageship/packageship/libs/exception/__init__.py @@ -7,6 +7,11 @@ from packageship.libs.exception.ext import DatabaseRepeatException from packageship.libs.exception.ext import DataMergeException from packageship.libs.exception.ext import Error from packageship.libs.exception.ext import DbnameNoneException +from .ext import ConfigurationException __all__ = ['ContentNoneException', - 'DatabaseRepeatException', 'DataMergeException', 'Error', 'DbnameNoneException'] + 'DatabaseRepeatException', + 'DataMergeException', + 'Error', + 'DbnameNoneException', + 'ConfigurationException'] diff --git a/packageship/packageship/libs/exception/ext.py b/packageship/packageship/libs/exception/ext.py index 56b6dcf1..dcea9ff7 100644 --- a/packageship/packageship/libs/exception/ext.py +++ b/packageship/packageship/libs/exception/ext.py @@ -62,3 +62,12 @@ class DataMergeException(Error): def __init__(self, message): Error.__init__(self, 'DataMerge exception: %r' % (message,)) + + +class ConfigurationException(Error): + """ + Description: Configuration file exception information + """ + + def __init__(self, message): + Error.__init__(self, 'Configuration exception : %r' % (message,)) -- Gitee From 2e345027114017d39f386030454f99f5c779e66a Mon Sep 17 00:00:00 2001 From: gongzt Date: Thu, 3 Sep 2020 09:49:26 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packageship/packageship/libs/exception/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packageship/packageship/libs/exception/__init__.py b/packageship/packageship/libs/exception/__init__.py index ed34e581..1ad97626 100644 --- a/packageship/packageship/libs/exception/__init__.py +++ b/packageship/packageship/libs/exception/__init__.py @@ -7,7 +7,7 @@ from packageship.libs.exception.ext import DatabaseRepeatException from packageship.libs.exception.ext import DataMergeException from packageship.libs.exception.ext import Error from packageship.libs.exception.ext import DbnameNoneException -from .ext import ConfigurationException +from packageship.libs.exception.ext import ConfigurationException __all__ = ['ContentNoneException', 'DatabaseRepeatException', -- Gitee From c4580c5935bd8daa80eb16082507b0e5a8211689 Mon Sep 17 00:00:00 2001 From: gongzt Date: Fri, 4 Sep 2020 09:01:18 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=85=B7=E4=BD=93=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/initsystem/data_import.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packageship/packageship/application/initsystem/data_import.py b/packageship/packageship/application/initsystem/data_import.py index a797eeb7..605775ef 100644 --- a/packageship/packageship/application/initsystem/data_import.py +++ b/packageship/packageship/application/initsystem/data_import.py @@ -100,12 +100,16 @@ class InitDataBase(): 'The content of the database initialization configuration file cannot be empty') if not isinstance(init_database_config, list): raise ConfigurationException( - ' '.join('The format of the initial database configuration\ - file is incorrect:{}'.format(self.config_file_path).split())) + ' '.join('The format of the initial database configuration file\ + is incorrect.When multiple databases need to be initialized, \ + it needs to be configured in the form of multiple \ + nodes:{}'.format(self.config_file_path).split())) for config_item in init_database_config: if not isinstance(config_item, dict): - raise ConfigurationException(' '.join('The format of the initial database \ - configuration file is incorrect:{}'.format(self.config_file_path).split())) + raise ConfigurationException(' '.join('The format of the initial database\ + configuration file is incorrect, and the value in a single node should\ + be presented in the form of key - val pairs: \ + {}'.format(self.config_file_path).split())) return init_database_config def init_data(self): -- Gitee From 09995a2b228aa9eda8abb4aec970c65de6f4ee26 Mon Sep 17 00:00:00 2001 From: gongzt Date: Fri, 4 Sep 2020 10:49:00 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E5=88=97=E5=90=8D=E7=A7=B0=E5=8F=98=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packageship/packageship/application/apps/lifecycle/view.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packageship/packageship/application/apps/lifecycle/view.py b/packageship/packageship/application/apps/lifecycle/view.py index efce4bb4..91e7aa6c 100644 --- a/packageship/packageship/application/apps/lifecycle/view.py +++ b/packageship/packageship/application/apps/lifecycle/view.py @@ -188,12 +188,12 @@ class TableColView(Resource): ('version', 'Version', True), ('release', 'Release', True), ('url', 'Url', True), - ('linense', 'License', False), + ('rpm_license', 'License', False), ('feature', 'Feature', False), ('maintainer', 'Maintainer', True), ('maintainlevel', 'Maintenance Level', True), ('release_time', 'Release Time', False), - ('end_of_lifecycle', 'End of Life Cycle', True), + ('used_time', 'Used Time', True), ('maintainer_status', 'Maintain Status', True), ('latest_version', 'Latest Version', False), ('latest_version_time', 'Latest Version Release Time', False), -- Gitee