From 3e92a0d95f7c87077f235ca33c36499cfe189a21 Mon Sep 17 00:00:00 2001 From: zt <1450026690@qq.com> Date: Wed, 2 Sep 2020 15:15:37 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=92=88=E5=AF=B9issue=E5=81=9A=E5=87=BA?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=8C=E5=96=84,=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E7=9A=84=E5=91=BD=E4=BB=A4=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=A4=84=E7=90=86=E6=96=B9=E5=BC=8F,=E9=80=82?= =?UTF-8?q?=E5=BA=94=E6=96=B0=E5=9B=9E=E6=98=BE=E5=86=85=E5=AE=B9,?= =?UTF-8?q?=E5=B9=B6=E5=90=8C=E6=97=B6=E4=BF=AE=E6=94=B9=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apps/package/function/build_depend.py | 20 +- .../apps/package/function/install_depend.py | 10 +- .../apps/package/function/searchdb.py | 58 +++-- .../apps/package/function/self_depend.py | 18 +- .../application/apps/package/view.py | 36 ++- packageship/packageship/pkgship.py | 31 ++- packageship/test/common_files/conf.yaml | 4 +- .../build_depend.json | 133 +++++------ .../install_depend.json | 215 +++++++++--------- .../correct_test_result_json/self_depend.json | 25 +- .../test_install_depend.py | 6 +- packageship/test/write_test.py | 4 +- 12 files changed, 322 insertions(+), 238 deletions(-) diff --git a/packageship/packageship/application/apps/package/function/build_depend.py b/packageship/packageship/application/apps/package/function/build_depend.py index b65464b9..95cd4633 100644 --- a/packageship/packageship/application/apps/package/function/build_depend.py +++ b/packageship/packageship/application/apps/package/function/build_depend.py @@ -35,6 +35,7 @@ class BuildDepend(): self.source_dict = dict() self.history_dicts = history_dict if history_dict else {} + self.not_found_components = set() def build_depend_main(self): """ @@ -47,13 +48,13 @@ class BuildDepend(): Raises: """ if not self.search_db.db_object_dict: - return ResponseCode.DIS_CONNECTION_DB, None, None + return ResponseCode.DIS_CONNECTION_DB, None, None, set() if self._self_build == 0: code = self.build_depend(self.pkg_name_list) if None in self.result_dict: del self.result_dict[None] - return code, self.result_dict, None + return code, self.result_dict, None, self.not_found_components if self._self_build == 1: self.self_build(self.pkg_name_list) @@ -64,9 +65,9 @@ class BuildDepend(): # Here, a place holder is needed to prevent unpacking errors during call # 2, This function is an auxiliary function of other modules. # The status code is not the final display status code - return ResponseCode.SUCCESS, self.result_dict, self.source_dict + return ResponseCode.SUCCESS, self.result_dict, self.source_dict, self.not_found_components - return ResponseCode.PARAM_ERROR, None, None + return ResponseCode.PARAM_ERROR, None, None,set() def build_depend(self, pkg_list): """ @@ -77,8 +78,8 @@ class BuildDepend(): ResponseCode: response code Raises: """ - res_status, build_list = self.search_db.get_build_depend(pkg_list) - + res_status, build_list, not_fd_build = self.search_db.get_build_depend(pkg_list) + self.not_found_components.update(not_fd_build) if not build_list: return res_status if res_status == ResponseCode.DIS_CONNECTION_DB else \ ResponseCode.PACK_NAME_NOT_FOUND @@ -86,9 +87,10 @@ class BuildDepend(): # create root node and get next search list search_list = self._create_node_and_get_search_list(build_list, pkg_list) - code, res_dict = \ + code, res_dict, not_fd_install = \ InstallDepend(self.db_list).query_install_depend(search_list, self.history_dicts) + self.not_found_components.update(not_fd_install) if not res_dict: return code @@ -185,8 +187,8 @@ class BuildDepend(): return next_src_set = set() - _, bin_info_lis = self.search_db.get_build_depend(pkg_name_li) - + _, bin_info_lis, not_fd_com = self.search_db.get_build_depend(pkg_name_li) + self.not_found_components.update(not_fd_com) if not bin_info_lis: return diff --git a/packageship/packageship/application/apps/package/function/install_depend.py b/packageship/packageship/application/apps/package/function/install_depend.py index 69ea9150..dffa9e65 100644 --- a/packageship/packageship/application/apps/package/function/install_depend.py +++ b/packageship/packageship/application/apps/package/function/install_depend.py @@ -32,6 +32,7 @@ class InstallDepend(): self.db_list = db_list self.__search_db = SearchDB(db_list) + self.not_found_components = set() def query_install_depend(self, binary_list, history_dicts=None): """ @@ -54,9 +55,9 @@ class InstallDepend(): Raises: """ if not self.__search_db.db_object_dict: - return ResponseCode.DIS_CONNECTION_DB, None + return ResponseCode.DIS_CONNECTION_DB, None, set() if not binary_list: - return ResponseCode.INPUT_NONE, None + return ResponseCode.INPUT_NONE, None, set() for binary in binary_list: if binary: self.__search_list.append(binary) @@ -64,7 +65,7 @@ class InstallDepend(): LOGGER.logger.warning("There is a NONE in input value:" + str(binary_list)) while self.__search_list: self.__query_single_install_dep(history_dicts) - return ResponseCode.SUCCESS, self.binary_dict.dictionary + return ResponseCode.SUCCESS, self.binary_dict.dictionary, self.not_found_components def __query_single_install_dep(self, history_dicts): """ @@ -75,7 +76,8 @@ class InstallDepend(): response_code: response code Raises: """ - result_list = set(self.__search_db.get_install_depend(self.__search_list)) + result_list, not_found_components = map(set, self.__search_db.get_install_depend(self.__search_list)) + self.not_found_components.update(not_found_components) for search in self.__search_list: if search not in self.binary_dict.dictionary: self.binary_dict.init_key(key=search, parent_node=[]) diff --git a/packageship/packageship/application/apps/package/function/searchdb.py b/packageship/packageship/application/apps/package/function/searchdb.py index fed2b753..cad4016a 100644 --- a/packageship/packageship/application/apps/package/function/searchdb.py +++ b/packageship/packageship/application/apps/package/function/searchdb.py @@ -128,7 +128,7 @@ class SearchDB(): install_result = self._get_install_pro_in_other_database( provides_not_found) result_list.extend(install_result) - return result_list + return result_list, set(provides_not_found.keys()) else: continue except AttributeError as error_msg: @@ -141,7 +141,7 @@ class SearchDB(): for binary_name in search_set: result_list.append((return_tuple(None, None, None, binary_name, None, None), 'NOT FOUND')) - return result_list + return result_list, set(provides_not_found.keys()) def get_src_name(self, binary_name): """ @@ -196,18 +196,17 @@ class SearchDB(): return ResponseCode.INPUT_NONE, None for db_name, data_base in self.db_object_dict.items(): try: - name_in = literal_column('src_name').in_(search_set) - sql_com = text('''SELECT - NAME AS subpack_name, - src_name AS search_name, - version AS search_version + name_in = literal_column('name').in_(search_set) + sql_com = text(''' + SELECT + bin_pack.name AS subpack_name, + src.name AS search_name, + src.version AS search_version FROM - bin_pack - WHERE - {} - '''.format(name_in)) + (SELECT name,version FROM src_pack WHERE {}) src + LEFT JOIN bin_pack on src.name = bin_pack.src_name'''.format(name_in)) subpack_tuple = data_base.session. \ - execute(sql_com, {'src_name_{}'.format(i): v + execute(sql_com, {'name_{}'.format(i): v for i, v in enumerate(search_set, 1)}).fetchall() if subpack_tuple: for result in subpack_tuple: @@ -310,8 +309,18 @@ class SearchDB(): if not_found_binary: for key, values in not_found_binary.items(): - LOGGER.logger.warning( - "CANNOT FOUND THE component" + key + " in all database") + # LOGGER.logger.warning( + # "CANNOT FOUND THE component" + key + " in all database") + for info in values: + obj = return_tuple( + info[0], + None, + None, + None, + 'NOT FOUND', + info[2] + ) + result_list.append(obj) return result_list def _get_install_pro_in_other_database(self, not_found_binary): @@ -362,9 +371,20 @@ class SearchDB(): del not_found_binary[result.req_name] if not not_found_binary: return result_list - # if not_found_binary: + if not_found_binary: # for key, values in not_found_binary.items(): - # LOGGER.logger.warning("CANNOT FOUND THE component" + key + " in all database") + # LOGGER.logger.warning("CANNOT FOUND THE component" + key + " in all database") + for key, values in not_found_binary.items(): + for info in values: + obj = return_tuple( + None, + None, + None, + info[0], + info[1], + info[2] + ) + result_list.append((obj, info[3])) return result_list def get_build_depend(self, source_name_li): @@ -393,7 +413,7 @@ class SearchDB(): s_name_set = set(source_name_li) if not s_name_set: - return ResponseCode.PARAM_ERROR, None + return ResponseCode.PARAM_ERROR, set() provides_not_found = dict() build_list = [] @@ -465,7 +485,7 @@ class SearchDB(): build_result = self._get_binary_in_other_database( provides_not_found) build_list.extend(build_result) - return ResponseCode.SUCCESS, build_list + return ResponseCode.SUCCESS, build_list, set(provides_not_found.keys()) if s_name_set: build_result = self._get_binary_in_other_database( @@ -474,7 +494,7 @@ class SearchDB(): for source in s_name_set: LOGGER.logger.warning( "CANNOT FOUND THE source " + source + " in all database") - return ResponseCode.SUCCESS, build_list + return ResponseCode.SUCCESS, build_list, set(provides_not_found.keys()) def binary_search_database_for_first_time(self, binary_name): """ diff --git a/packageship/packageship/application/apps/package/function/self_depend.py b/packageship/packageship/application/apps/package/function/self_depend.py index 54def449..538707a5 100644 --- a/packageship/packageship/application/apps/package/function/self_depend.py +++ b/packageship/packageship/application/apps/package/function/self_depend.py @@ -47,6 +47,7 @@ class SelfDepend(): self.withsubpack = 0 self.db_list = db_list self.search_db = SearchDB(db_list) + self.not_found_components = set() def query_depend(self, packname, selfbuild, withsubpack, packtype='binary'): """ @@ -62,14 +63,14 @@ class SelfDepend(): Raises: """ if not self.search_db.db_object_dict: - return ResponseCode.DIS_CONNECTION_DB, None, None + return ResponseCode.DIS_CONNECTION_DB, None, None, set() if not packname: return ResponseCode.INPUT_NONE self.withsubpack = withsubpack response_code = self.init_dict(packname, packtype) if response_code != ResponseCode.SUCCESS: - return response_code, self.binary_dict.dictionary, self.source_dicts.dictionary + return response_code, self.binary_dict.dictionary, self.source_dicts.dictionary, self.not_found_components for key, _ in self.binary_dict.dictionary.items(): self.search_install_list.append(key) @@ -85,7 +86,7 @@ class SelfDepend(): self.with_subpack() if self.search_build_list: self.query_build(selfbuild) - return response_code, self.binary_dict.dictionary, self.source_dicts.dictionary + return response_code, self.binary_dict.dictionary, self.source_dicts.dictionary, self.not_found_components def init_dict(self, packname, packtype): """ @@ -130,9 +131,10 @@ class SelfDepend(): Raises: """ self.result_tmp.clear() - _, self.result_tmp = \ + _, self.result_tmp, not_fd_install = \ install_depend(self.db_list).query_install_depend(self.search_install_list, self.binary_dict.dictionary) + self.not_found_components.update(not_fd_install) self.search_install_list.clear() for key, values in self.result_tmp.items(): if key in self.binary_dict.dictionary: @@ -199,13 +201,13 @@ class SelfDepend(): Returns: Raises: """ - _, self.result_tmp, _ = build_depend( + _, self.result_tmp, _, not_fd_build = build_depend( self.search_build_list, self.db_list, self_build=0, history_dict=self.binary_dict.dictionary ).build_depend_main() - + self.not_found_components.update(not_fd_build) self.search_build_list.clear() for key, values in self.result_tmp.items(): if not key: @@ -231,13 +233,13 @@ class SelfDepend(): Args: Returns: """ - _, self.result_tmp, source_dicts_tmp = build_depend( + _, self.result_tmp, source_dicts_tmp, not_fd_build = build_depend( self.search_build_list, self.db_list, self_build=1, history_dict=self.source_dicts.dictionary ).build_depend_main() - + self.not_found_components.update(not_fd_build) for key, values in self.result_tmp.items(): if not key: LOGGER.logger.warning("key is NONE for value = " + str(values)) diff --git a/packageship/packageship/application/apps/package/view.py b/packageship/packageship/application/apps/package/view.py index 807b4515..1c4b3d3b 100644 --- a/packageship/packageship/application/apps/package/view.py +++ b/packageship/packageship/application/apps/package/view.py @@ -38,7 +38,9 @@ from .serialize import SelfDependSchema from .serialize import have_err_db_name LOGGER = Log(__name__) -#pylint: disable = no-self-use + + +# pylint: disable = no-self-use class Packages(Resource): @@ -215,16 +217,22 @@ class InstallDepend(Resource): ResponseCode.response_json(ResponseCode.DB_NAME_ERROR) ) - response_code, install_dict = \ + response_code, install_dict, not_found_components = \ installdepend(db_list).query_install_depend([pkg_name]) if not install_dict: return jsonify( ResponseCode.response_json(response_code) ) - + elif len(install_dict) == 1 and install_dict.get(pkg_name)[2] == 'NOT FOUND': + return jsonify( + ResponseCode.response_json(ResponseCode.PACK_NAME_NOT_FOUND) + ) return jsonify( - ResponseCode.response_json(ResponseCode.SUCCESS, data=install_dict) + ResponseCode.response_json(ResponseCode.SUCCESS, data={ + "install_dict": install_dict, + 'not_found_components': list(not_found_components) + }) ) @@ -282,12 +290,23 @@ class BuildDepend(Resource): build_ins = builddepend([pkg_name], db_list) - res_code, res_dict, _ = build_ins.build_depend_main() + res_code, res_dict, _, not_found_com = build_ins.build_depend_main() + if res_dict: + res_code = ResponseCode.SUCCESS + else: + return jsonify( + ResponseCode.response_json( + res_code + ) + ) return jsonify( ResponseCode.response_json( res_code, - data=res_dict if res_dict else None + data={ + 'build_dict': res_dict, + 'not_found_components': list(not_found_com) + } ) ) @@ -350,7 +369,7 @@ class SelfDepend(Resource): return jsonify( ResponseCode.response_json(ResponseCode.DB_NAME_ERROR) ) - response_code, binary_dicts, source_dicts = \ + response_code, binary_dicts, source_dicts, not_fd_components = \ self_depend(db_list).query_depend(pkg_name, int(self_build), int(with_sub_pack), pack_type) @@ -362,7 +381,8 @@ class SelfDepend(Resource): return jsonify( ResponseCode.response_json(ResponseCode.SUCCESS, data={ "binary_dicts": binary_dicts, - "source_dicts": source_dicts + "source_dicts": source_dicts, + "not_found_components": list(not_fd_components) }) ) diff --git a/packageship/packageship/pkgship.py b/packageship/packageship/pkgship.py index ea32b527..cbb9310b 100644 --- a/packageship/packageship/pkgship.py +++ b/packageship/packageship/pkgship.py @@ -10,6 +10,7 @@ import os import json import threading from json.decoder import JSONDecodeError + try: import argparse import requests @@ -209,7 +210,7 @@ class PkgshipCommand(BaseCommand): except Error: print('command error') - def parse_depend_package(self, response_data): + def parse_depend_package(self, response_data, params=None): """ Description: Parsing package data with dependencies Args: @@ -224,6 +225,12 @@ class PkgshipCommand(BaseCommand): if response_data.get('code') == ResponseCode.SUCCESS: package_all = response_data.get('data') if isinstance(package_all, dict): + if params: + if package_all.get("not_found_components"): + print("Problem: Not Found Components") + for not_found_com in package_all.get("not_found_components"): + print(" - nothing provides {} needed by {} ".format(not_found_com, params.packagename)) + package_all = package_all.get("build_dict") for bin_package, package_depend in package_all.items(): # distinguish whether the current data is the data of the root node @@ -753,7 +760,7 @@ class BuildDepCommand(PkgshipCommand): if response.status_code == 200: try: statistics_table = self.parse_depend_package( - json.loads(response.text)) + json.loads(response.text), params) except JSONDecodeError as json_error: LOGGER.logger.error(json_error) print(response.text) @@ -813,7 +820,7 @@ class InstallDepCommand(PkgshipCommand): cmd_params[0], nargs='*', default=None, help=cmd_params[1]) self.parse.set_defaults(func=self.do_command) - def __parse_package(self, response_data): + def __parse_package(self, response_data, params): """ Description: Parse the corresponding data of the package Args: @@ -832,7 +839,11 @@ class InstallDepCommand(PkgshipCommand): if response_data.get('code') == ResponseCode.SUCCESS: package_all = response_data.get('data') if isinstance(package_all, dict): - for bin_package, package_depend in package_all.items(): + if package_all.get("not_found_components"): + print("Problem: Not Found Components") + for not_found_com in package_all.get("not_found_components"): + print(" - nothing provides {} needed by {} ".format(not_found_com, params.packagename)) + for bin_package, package_depend in package_all.get("install_dict").items(): # distinguish whether the current data is the data of the root node if isinstance(package_depend, list) and package_depend[-1][0][0] != 'root': @@ -895,13 +906,13 @@ class InstallDepCommand(PkgshipCommand): if response.status_code == 200: try: statistics_table = self.__parse_package( - json.loads(response.text)) + json.loads(response.text), params) except JSONDecodeError as json_error: LOGGER.logger.error(json_error) print(response.text) else: if getattr(self.table, 'rowcount'): - self.print_('query{} InstallDepend result display:'.format( + self.print_('query {} InstallDepend result display:'.format( params.packagename)) print(self.table) self.print_('statistics') @@ -1034,7 +1045,7 @@ class SelfBuildCommand(PkgshipCommand): return src_package_count - def __parse_package(self, response_data): + def __parse_package(self, response_data, params): """ Description: Parse the corresponding data of the package Args: @@ -1053,6 +1064,10 @@ class SelfBuildCommand(PkgshipCommand): package_all = response_data.get('data') if isinstance(package_all, dict): # Parsing binary result data + if package_all.get("not_found_components"): + print("Problem: Not Found Components") + for not_found_com in package_all.get("not_found_components"): + print(" - nothing provides {} needed by {} ".format(not_found_com, params.packagename)) bin_package_count = self._parse_bin_package( package_all.get('binary_dicts')) @@ -1096,7 +1111,7 @@ class SelfBuildCommand(PkgshipCommand): if response.status_code == 200: try: statistics_table = self.__parse_package( - json.loads(response.text)) + json.loads(response.text), params) except JSONDecodeError as json_error: LOGGER.logger.error(json_error) print(response.text) diff --git a/packageship/test/common_files/conf.yaml b/packageship/test/common_files/conf.yaml index 190b6f7f..1a2d9df2 100644 --- a/packageship/test/common_files/conf.yaml +++ b/packageship/test/common_files/conf.yaml @@ -2,9 +2,9 @@ dbname: mainline priority: 1 src_db_file: - status: enable + lifecycle: enable - bin_db_file: dbname: fedora30 priority: 2 src_db_file: - status: enable + lifecycle: enable diff --git a/packageship/test/common_files/correct_test_result_json/build_depend.json b/packageship/test/common_files/correct_test_result_json/build_depend.json index dd8788c8..945d58fa 100644 --- a/packageship/test/common_files/correct_test_result_json/build_depend.json +++ b/packageship/test/common_files/correct_test_result_json/build_depend.json @@ -6,84 +6,87 @@ "output": { "code": "2001", "data": { - "A_src": [ - "source", - "0.0.23b", - "mainline", - [ + "build_dict": { + "A_src": [ + "source", + "0.0.23b", + "mainline", [ - "root", - null + [ + "root", + null + ] ] - ] - ], - "B1": [ - "B", - "0.0.2", - "mainline", - [ + ], + "B1": [ + "B", + "0.0.2", + "mainline", [ - "A", - "build" + [ + "A", + "build" + ] ] - ] - ], - "C1": [ - "C", - "0.1", - "mainline", - [ + ], + "C1": [ + "C", + "0.1", + "mainline", [ - "A", - "build" - ], - [ - "A2", - "install" + [ + "A", + "build" + ], + [ + "A2", + "install" + ] ] - ] - ], - "A1": [ - "A", - "0.0.23b", - "mainline", - [ + ], + "A1": [ + "A", + "0.0.23b", + "mainline", [ - "B1", - "install" - ], - [ - "D1", - "install" + [ + "B1", + "install" + ], + [ + "D1", + "install" + ] ] - ] - ], - "A2": [ - "A", - "0.0.23b", - "mainline", - [ + ], + "A2": [ + "A", + "0.0.23b", + "mainline", [ - "A1", - "install" - ], - [ - "C1", - "install" + [ + "A1", + "install" + ], + [ + "C1", + "install" + ] ] - ] - ], - "D1": [ - "D", - "0.11", - "mainline", - [ + ], + "D1": [ + "D", + "0.11", + "mainline", [ - "A2", - "install" + [ + "A2", + "install" + ] ] ] - ] + }, + "not_found_components": [] }, "msg": "Successful Operation!" } diff --git a/packageship/test/common_files/correct_test_result_json/install_depend.json b/packageship/test/common_files/correct_test_result_json/install_depend.json index b6b5c818..34d09821 100644 --- a/packageship/test/common_files/correct_test_result_json/install_depend.json +++ b/packageship/test/common_files/correct_test_result_json/install_depend.json @@ -6,58 +6,61 @@ "output": { "code": "2001", "data": { - "A1": [ - "A", - "0.0.23b", - "mainline", - [ + "install_dict": { + "A1": [ + "A", + "0.0.23b", + "mainline", [ - "root", - null - ], - [ - "D1", - "install" + [ + "root", + null + ], + [ + "D1", + "install" + ] ] - ] - ], - "A2": [ - "A", - "0.0.23b", - "mainline", - [ - [ - "A1", - "install" - ], + ], + "A2": [ + "A", + "0.0.23b", + "mainline", [ - "C1", - "install" + [ + "A1", + "install" + ], + [ + "C1", + "install" + ] ] - ] - ], - "C1": [ - "C", - "0.1", - "mainline", - [ + ], + "C1": [ + "C", + "0.1", + "mainline", [ - "A2", - "install" + [ + "A2", + "install" + ] ] - ] - ], - "D1": [ - "D", - "0.11", - "mainline", - [ + ], + "D1": [ + "D", + "0.11", + "mainline", [ - "A2", - "install" + [ + "A2", + "install" + ] ] ] - ] + }, + "not_found_components": [] }, "msg": "Successful Operation!" } @@ -69,69 +72,72 @@ "output": { "code": "2001", "data": { - "A1": [ - "A", - "0.0.23b", - "mainline", - [ + "install_dict": { + "A1": [ + "A", + "0.0.23b", + "mainline", [ - "D1", - "install" + [ + "D1", + "install" + ] ] - ] - ], - "A2": [ - "A", - "0.0.23b", - "mainline", - [ + ], + "A2": [ + "A", + "0.0.23b", + "mainline", [ - "A1", - "install" - ], - [ - "C1", - "install" + [ + "A1", + "install" + ], + [ + "C1", + "install" + ] ] - ] - ], - "C1": [ - "C", - "0.1", - "mainline", - [ + ], + "C1": [ + "C", + "0.1", + "mainline", [ - "A2", - "install" + [ + "A2", + "install" + ] ] - ] - ], - "D1": [ - "D", - "0.11", - "mainline", - [ + ], + "D1": [ + "D", + "0.11", + "mainline", [ - "D2", - "install" - ], - [ - "A2", - "install" + [ + "D2", + "install" + ], + [ + "A2", + "install" + ] ] - ] - ], - "D2": [ - "D", - "0.11", - "mainline", - [ + ], + "D2": [ + "D", + "0.11", + "mainline", [ - "root", - null + [ + "root", + null + ] ] ] - ] + }, + "not_found_components": [] }, "msg": "Successful Operation!" } @@ -143,17 +149,20 @@ "output": { "code": "2001", "data": { - "C2": [ - "C", - "0.1", - "mainline", - [ + "install_dict": { + "C2": [ + "C", + "0.1", + "mainline", [ - "root", - null + [ + "root", + null + ] ] ] - ] + }, + "not_found_components": [] }, "msg": "Successful Operation!" } diff --git a/packageship/test/common_files/correct_test_result_json/self_depend.json b/packageship/test/common_files/correct_test_result_json/self_depend.json index cc69ce69..6fee2dc8 100644 --- a/packageship/test/common_files/correct_test_result_json/self_depend.json +++ b/packageship/test/common_files/correct_test_result_json/self_depend.json @@ -123,7 +123,8 @@ "mainline", "0.11" ] - } + }, + "not_found_components": [] }, "msg": "Successful Operation!" } @@ -264,7 +265,8 @@ "mainline", "0.11" ] - } + }, + "not_found_components": [] }, "msg": "Successful Operation!" } @@ -421,7 +423,8 @@ "mainline", "0.11" ] - } + }, + "not_found_components": [] }, "msg": "Successful Operation!" } @@ -583,7 +586,9 @@ "mainline", "0.11" ] - } + }, + + "not_found_components": [] }, "msg": "Successful Operation!" } @@ -753,7 +758,9 @@ "mainline", "0.11" ] - } + }, + + "not_found_components": [] }, "msg": "Successful Operation!" } @@ -892,7 +899,9 @@ "mainline", "0.11" ] - } + }, + + "not_found_components": [] }, "msg": "Successful Operation!" } @@ -1036,7 +1045,9 @@ "mainline", "0.11" ] - } + }, + + "not_found_components": [] }, "msg": "Successful Operation!" } diff --git a/packageship/test/test_module/dependent_query_tests/test_install_depend.py b/packageship/test/test_module/dependent_query_tests/test_install_depend.py index 81ddf98b..9b9280be 100644 --- a/packageship/test/test_module/dependent_query_tests/test_install_depend.py +++ b/packageship/test/test_module/dependent_query_tests/test_install_depend.py @@ -89,17 +89,17 @@ class TestInstallDepend(ReadTestBase): resp_dict = json.loads(resp.data) self.assertIn("code", resp_dict, msg="Error in data format return") - self.assertEqual(ResponseCode.SUCCESS, + self.assertEqual(ResponseCode.PACK_NAME_NOT_FOUND, resp_dict.get("code"), msg="Error in status code return") self.assertIn("msg", resp_dict, msg="Error in data format return") - self.assertEqual(ResponseCode.CODE_MSG_MAP.get(ResponseCode.SUCCESS), + self.assertEqual(ResponseCode.CODE_MSG_MAP.get(ResponseCode.PACK_NAME_NOT_FOUND), resp_dict.get("msg"), msg="Error in status prompt return") self.assertIn("data", resp_dict, msg="Error in data format return") - self.assertIsNotNone(resp_dict.get("data"), msg="Error in data information return") + self.assertIsNone(resp_dict.get("data"), msg="Error in data information return") resp = self.client.post("/packages/findInstallDepend", data=json.dumps({"binaryName": "A1", diff --git a/packageship/test/write_test.py b/packageship/test/write_test.py index dded68e6..7d12f13d 100644 --- a/packageship/test/write_test.py +++ b/packageship/test/write_test.py @@ -19,8 +19,8 @@ def write_data_tests(): suite = unittest.TestSuite() classes = [ - # TestDeleteRepodatas, - # TestBatchUpdatePackage, + TestDeleteRepodatas, + TestBatchUpdatePackage, TestIssueCatch ] for cls in classes: -- Gitee From 5d68f40d0edb45a0e4af11093ad0df26c893aa34 Mon Sep 17 00:00:00 2001 From: zt <1450026690@qq.com> Date: Wed, 2 Sep 2020 19:48:43 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=AA=E6=89=BE?= =?UTF-8?q?=E5=88=B0=E7=BB=84=E4=BB=B6=E7=9A=84=E5=8F=98=E9=87=8F=E5=90=8D?= =?UTF-8?q?=E5=AD=97=E4=B8=BAnot=5Ffd=5Fcom,=E5=A2=9E=E5=BC=BA=E5=8F=AF?= =?UTF-8?q?=E8=AF=BB=E6=80=A7,=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/apps/package/function/searchdb.py | 6 ------ .../application/apps/package/function/self_depend.py | 12 ++++++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packageship/packageship/application/apps/package/function/searchdb.py b/packageship/packageship/application/apps/package/function/searchdb.py index cad4016a..abb04aca 100644 --- a/packageship/packageship/application/apps/package/function/searchdb.py +++ b/packageship/packageship/application/apps/package/function/searchdb.py @@ -225,8 +225,6 @@ class SearchDB(): return_tuple = namedtuple( 'return_tuple', 'subpack_name search_version search_name') for search_name in search_set: - # LOGGER.logger.warning("Can't not find " + - # search_name + " subpack in all database") result_list.append( (return_tuple(None, None, search_name), 'NOT_FOUND')) return ResponseCode.SUCCESS, result_list @@ -309,8 +307,6 @@ class SearchDB(): if not_found_binary: for key, values in not_found_binary.items(): - # LOGGER.logger.warning( - # "CANNOT FOUND THE component" + key + " in all database") for info in values: obj = return_tuple( info[0], @@ -372,8 +368,6 @@ class SearchDB(): if not not_found_binary: return result_list if not_found_binary: - # for key, values in not_found_binary.items(): - # LOGGER.logger.warning("CANNOT FOUND THE component" + key + " in all database") for key, values in not_found_binary.items(): for info in values: obj = return_tuple( diff --git a/packageship/packageship/application/apps/package/function/self_depend.py b/packageship/packageship/application/apps/package/function/self_depend.py index 538707a5..019626cc 100644 --- a/packageship/packageship/application/apps/package/function/self_depend.py +++ b/packageship/packageship/application/apps/package/function/self_depend.py @@ -131,10 +131,10 @@ class SelfDepend(): Raises: """ self.result_tmp.clear() - _, self.result_tmp, not_fd_install = \ + _, self.result_tmp, not_fd_com = \ install_depend(self.db_list).query_install_depend(self.search_install_list, self.binary_dict.dictionary) - self.not_found_components.update(not_fd_install) + self.not_found_components.update(not_fd_com) self.search_install_list.clear() for key, values in self.result_tmp.items(): if key in self.binary_dict.dictionary: @@ -201,13 +201,13 @@ class SelfDepend(): Returns: Raises: """ - _, self.result_tmp, _, not_fd_build = build_depend( + _, self.result_tmp, _, not_fd_com = build_depend( self.search_build_list, self.db_list, self_build=0, history_dict=self.binary_dict.dictionary ).build_depend_main() - self.not_found_components.update(not_fd_build) + self.not_found_components.update(not_fd_com) self.search_build_list.clear() for key, values in self.result_tmp.items(): if not key: @@ -233,13 +233,13 @@ class SelfDepend(): Args: Returns: """ - _, self.result_tmp, source_dicts_tmp, not_fd_build = build_depend( + _, self.result_tmp, source_dicts_tmp, not_fd_com = build_depend( self.search_build_list, self.db_list, self_build=1, history_dict=self.source_dicts.dictionary ).build_depend_main() - self.not_found_components.update(not_fd_build) + self.not_found_components.update(not_fd_com) for key, values in self.result_tmp.items(): if not key: LOGGER.logger.warning("key is NONE for value = " + str(values)) -- Gitee From e857a6a9d3d9c9523139dbffc38ca6bed86abf9b Mon Sep 17 00:00:00 2001 From: zt <1450026690@qq.com> Date: Wed, 2 Sep 2020 19:54:17 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=AA=E6=89=BE?= =?UTF-8?q?=E5=88=B0=E7=BB=84=E4=BB=B6=E7=9A=84=E5=8F=98=E9=87=8F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/apps/package/function/build_depend.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packageship/packageship/application/apps/package/function/build_depend.py b/packageship/packageship/application/apps/package/function/build_depend.py index 95cd4633..81fb4bad 100644 --- a/packageship/packageship/application/apps/package/function/build_depend.py +++ b/packageship/packageship/application/apps/package/function/build_depend.py @@ -78,8 +78,8 @@ class BuildDepend(): ResponseCode: response code Raises: """ - res_status, build_list, not_fd_build = self.search_db.get_build_depend(pkg_list) - self.not_found_components.update(not_fd_build) + res_status, build_list, not_fd_com_build = self.search_db.get_build_depend(pkg_list) + self.not_found_components.update(not_fd_com_build) if not build_list: return res_status if res_status == ResponseCode.DIS_CONNECTION_DB else \ ResponseCode.PACK_NAME_NOT_FOUND @@ -87,10 +87,10 @@ class BuildDepend(): # create root node and get next search list search_list = self._create_node_and_get_search_list(build_list, pkg_list) - code, res_dict, not_fd_install = \ + code, res_dict, not_fd_com_install = \ InstallDepend(self.db_list).query_install_depend(search_list, self.history_dicts) - self.not_found_components.update(not_fd_install) + self.not_found_components.update(not_fd_com_install) if not res_dict: return code -- Gitee From f713e6a03f43d26f2df736588d86da91fe85b6fc Mon Sep 17 00:00:00 2001 From: zt <1450026690@qq.com> Date: Thu, 3 Sep 2020 10:15:56 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0,?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=E5=AF=B9=E5=BA=94=E7=9A=84=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E6=8F=8F=E8=BF=B0,=E4=BF=AE=E6=94=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/apps/package/function/build_depend.py | 4 +++- .../application/apps/package/function/install_depend.py | 2 ++ .../application/apps/package/function/searchdb.py | 6 ++++-- .../application/apps/package/function/self_depend.py | 2 ++ packageship/packageship/pkgship.py | 3 +++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packageship/packageship/application/apps/package/function/build_depend.py b/packageship/packageship/application/apps/package/function/build_depend.py index 81fb4bad..92351e78 100644 --- a/packageship/packageship/application/apps/package/function/build_depend.py +++ b/packageship/packageship/application/apps/package/function/build_depend.py @@ -19,6 +19,7 @@ class BuildDepend(): search_db:Query an instance of a database class result_dict:A dictionary to store the data that needs to be echoed source_dict:A dictionary to store the searched source code package name + not_found_components: Contain the package not found components """ def __init__(self, pkg_name_list, db_list, self_build=0, history_dict=None): @@ -45,6 +46,7 @@ class BuildDepend(): ResponseCode: response code result_dict: Dictionary of query results source_dict: Dictionary of source code package + not_found_components: Set of package not found components Raises: """ if not self.search_db.db_object_dict: @@ -67,7 +69,7 @@ class BuildDepend(): # The status code is not the final display status code return ResponseCode.SUCCESS, self.result_dict, self.source_dict, self.not_found_components - return ResponseCode.PARAM_ERROR, None, None,set() + return ResponseCode.PARAM_ERROR, None, None, set() def build_depend(self, pkg_list): """ diff --git a/packageship/packageship/application/apps/package/function/install_depend.py b/packageship/packageship/application/apps/package/function/install_depend.py index dffa9e65..f3cf05e3 100644 --- a/packageship/packageship/application/apps/package/function/install_depend.py +++ b/packageship/packageship/application/apps/package/function/install_depend.py @@ -20,6 +20,7 @@ class InstallDepend(): __search_list: Contain the binary packages searched in the next loop binary_dict: Contain all the binary packages info and operation __search_db: A object of database which would be connected + not_found_components: Contain the package not found components changeLog: """ #pylint: disable = too-few-public-methods @@ -52,6 +53,7 @@ class InstallDepend(): 'install' ] ]} + not_found_components:Set of package not found components Raises: """ if not self.__search_db.db_object_dict: diff --git a/packageship/packageship/application/apps/package/function/searchdb.py b/packageship/packageship/application/apps/package/function/searchdb.py index abb04aca..e977f7a2 100644 --- a/packageship/packageship/application/apps/package/function/searchdb.py +++ b/packageship/packageship/application/apps/package/function/searchdb.py @@ -58,7 +58,8 @@ class SearchDB(): Args: binary_list: a list of binary package name Returns: - install depend list + list:install depend list + set:package not found components Raises: """ result_list = [] @@ -181,6 +182,7 @@ class SearchDB(): Args: source_name_list: search package's name, database preority list Returns: + response code result_list: subpack tuple Raises: AttributeError: The object does not have this property @@ -390,7 +392,7 @@ class SearchDB(): all source pkg build depend list structure :[(search_name,source_name,bin_name,bin_version,db_name,search_version), (search_name,source_name,bin_name,bin_version,db_name,search_version),] - + set: package not found components name set Raises: AttributeError: The object does not have this property SQLAlchemyError: sqlalchemy error diff --git a/packageship/packageship/application/apps/package/function/self_depend.py b/packageship/packageship/application/apps/package/function/self_depend.py index 019626cc..3f51e2a7 100644 --- a/packageship/packageship/application/apps/package/function/self_depend.py +++ b/packageship/packageship/application/apps/package/function/self_depend.py @@ -33,6 +33,7 @@ class SelfDepend(): search_subpack_list: Contain the source packages searched subpack in the next loop withsubpack: withsubpack search_db: A object of database which would be connected + not_found_components: Contain the package not found components """ def __init__(self, db_list): """ @@ -60,6 +61,7 @@ class SelfDepend(): Returns: binary_dict.dictionary: Contain all the binary packages info after searching source_dicts.dictionary: Contain all the source packages info after searching + not_found_components :Set of package not found components Raises: """ if not self.search_db.db_object_dict: diff --git a/packageship/packageship/pkgship.py b/packageship/packageship/pkgship.py index cbb9310b..be33ae09 100644 --- a/packageship/packageship/pkgship.py +++ b/packageship/packageship/pkgship.py @@ -215,6 +215,7 @@ class PkgshipCommand(BaseCommand): Description: Parsing package data with dependencies Args: response_data: http request response content + params: Parameters passed in on the command line Returns: Summarized data table Raises: @@ -825,6 +826,7 @@ class InstallDepCommand(PkgshipCommand): Description: Parse the corresponding data of the package Args: response_data: http response data + params: Parameters passed in on the command line Returns: Raises: @@ -1050,6 +1052,7 @@ class SelfBuildCommand(PkgshipCommand): Description: Parse the corresponding data of the package Args: response_data: http response data + params: Parameters passed in on the command line Returns: Summarized data table Raises: -- Gitee