提交 f48313d2 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!115 针对issue做出接口完善,修改对应的命令行数据处理方式,适应新回显内容,并同时修改对应的单元测试内容

Merge pull request !115 from tomtao/master
...@@ -19,6 +19,7 @@ class BuildDepend(): ...@@ -19,6 +19,7 @@ class BuildDepend():
search_db:Query an instance of a database class search_db:Query an instance of a database class
result_dict:A dictionary to store the data that needs to be echoed 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 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): def __init__(self, pkg_name_list, db_list, self_build=0, history_dict=None):
...@@ -35,6 +36,7 @@ class BuildDepend(): ...@@ -35,6 +36,7 @@ class BuildDepend():
self.source_dict = dict() self.source_dict = dict()
self.history_dicts = history_dict if history_dict else {} self.history_dicts = history_dict if history_dict else {}
self.not_found_components = set()
def build_depend_main(self): def build_depend_main(self):
""" """
...@@ -44,16 +46,17 @@ class BuildDepend(): ...@@ -44,16 +46,17 @@ class BuildDepend():
ResponseCode: response code ResponseCode: response code
result_dict: Dictionary of query results result_dict: Dictionary of query results
source_dict: Dictionary of source code package source_dict: Dictionary of source code package
not_found_components: Set of package not found components
Raises: Raises:
""" """
if not self.search_db.db_object_dict: 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: if self._self_build == 0:
code = self.build_depend(self.pkg_name_list) code = self.build_depend(self.pkg_name_list)
if None in self.result_dict: if None in self.result_dict:
del self.result_dict[None] 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: if self._self_build == 1:
self.self_build(self.pkg_name_list) self.self_build(self.pkg_name_list)
...@@ -64,9 +67,9 @@ class BuildDepend(): ...@@ -64,9 +67,9 @@ class BuildDepend():
# Here, a place holder is needed to prevent unpacking errors during call # Here, a place holder is needed to prevent unpacking errors during call
# 2, This function is an auxiliary function of other modules. # 2, This function is an auxiliary function of other modules.
# The status code is not the final display status code # 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): def build_depend(self, pkg_list):
""" """
...@@ -77,8 +80,8 @@ class BuildDepend(): ...@@ -77,8 +80,8 @@ class BuildDepend():
ResponseCode: response code ResponseCode: response code
Raises: Raises:
""" """
res_status, build_list = self.search_db.get_build_depend(pkg_list) 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: if not build_list:
return res_status if res_status == ResponseCode.DIS_CONNECTION_DB else \ return res_status if res_status == ResponseCode.DIS_CONNECTION_DB else \
ResponseCode.PACK_NAME_NOT_FOUND ResponseCode.PACK_NAME_NOT_FOUND
...@@ -86,9 +89,10 @@ class BuildDepend(): ...@@ -86,9 +89,10 @@ class BuildDepend():
# create root node and get next search list # create root node and get next search list
search_list = self._create_node_and_get_search_list(build_list, pkg_list) search_list = self._create_node_and_get_search_list(build_list, pkg_list)
code, res_dict = \ code, res_dict, not_fd_com_install = \
InstallDepend(self.db_list).query_install_depend(search_list, InstallDepend(self.db_list).query_install_depend(search_list,
self.history_dicts) self.history_dicts)
self.not_found_components.update(not_fd_com_install)
if not res_dict: if not res_dict:
return code return code
...@@ -185,8 +189,8 @@ class BuildDepend(): ...@@ -185,8 +189,8 @@ class BuildDepend():
return return
next_src_set = set() 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: if not bin_info_lis:
return return
......
...@@ -20,6 +20,7 @@ class InstallDepend(): ...@@ -20,6 +20,7 @@ class InstallDepend():
__search_list: Contain the binary packages searched in the next loop __search_list: Contain the binary packages searched in the next loop
binary_dict: Contain all the binary packages info and operation binary_dict: Contain all the binary packages info and operation
__search_db: A object of database which would be connected __search_db: A object of database which would be connected
not_found_components: Contain the package not found components
changeLog: changeLog:
""" """
#pylint: disable = too-few-public-methods #pylint: disable = too-few-public-methods
...@@ -32,6 +33,7 @@ class InstallDepend(): ...@@ -32,6 +33,7 @@ class InstallDepend():
self.db_list = db_list self.db_list = db_list
self.__search_db = SearchDB(db_list) self.__search_db = SearchDB(db_list)
self.not_found_components = set()
def query_install_depend(self, binary_list, history_dicts=None): def query_install_depend(self, binary_list, history_dicts=None):
""" """
...@@ -51,12 +53,13 @@ class InstallDepend(): ...@@ -51,12 +53,13 @@ class InstallDepend():
'install' 'install'
] ]
]} ]}
not_found_components:Set of package not found components
Raises: Raises:
""" """
if not self.__search_db.db_object_dict: 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: if not binary_list:
return ResponseCode.INPUT_NONE, None return ResponseCode.INPUT_NONE, None, set()
for binary in binary_list: for binary in binary_list:
if binary: if binary:
self.__search_list.append(binary) self.__search_list.append(binary)
...@@ -64,7 +67,7 @@ class InstallDepend(): ...@@ -64,7 +67,7 @@ class InstallDepend():
LOGGER.logger.warning("There is a NONE in input value:" + str(binary_list)) LOGGER.logger.warning("There is a NONE in input value:" + str(binary_list))
while self.__search_list: while self.__search_list:
self.__query_single_install_dep(history_dicts) 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): def __query_single_install_dep(self, history_dicts):
""" """
...@@ -75,7 +78,8 @@ class InstallDepend(): ...@@ -75,7 +78,8 @@ class InstallDepend():
response_code: response code response_code: response code
Raises: 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: for search in self.__search_list:
if search not in self.binary_dict.dictionary: if search not in self.binary_dict.dictionary:
self.binary_dict.init_key(key=search, parent_node=[]) self.binary_dict.init_key(key=search, parent_node=[])
......
...@@ -58,7 +58,8 @@ class SearchDB(): ...@@ -58,7 +58,8 @@ class SearchDB():
Args: Args:
binary_list: a list of binary package name binary_list: a list of binary package name
Returns: Returns:
install depend list list:install depend list
set:package not found components
Raises: Raises:
""" """
result_list = [] result_list = []
...@@ -128,7 +129,7 @@ class SearchDB(): ...@@ -128,7 +129,7 @@ class SearchDB():
install_result = self._get_install_pro_in_other_database( install_result = self._get_install_pro_in_other_database(
provides_not_found) provides_not_found)
result_list.extend(install_result) result_list.extend(install_result)
return result_list return result_list, set(provides_not_found.keys())
else: else:
continue continue
except AttributeError as error_msg: except AttributeError as error_msg:
...@@ -141,7 +142,7 @@ class SearchDB(): ...@@ -141,7 +142,7 @@ class SearchDB():
for binary_name in search_set: for binary_name in search_set:
result_list.append((return_tuple(None, None, None, result_list.append((return_tuple(None, None, None,
binary_name, None, None), 'NOT FOUND')) binary_name, None, None), 'NOT FOUND'))
return result_list return result_list, set(provides_not_found.keys())
def get_src_name(self, binary_name): def get_src_name(self, binary_name):
""" """
...@@ -181,6 +182,7 @@ class SearchDB(): ...@@ -181,6 +182,7 @@ class SearchDB():
Args: Args:
source_name_list: search package's name, database preority list source_name_list: search package's name, database preority list
Returns: Returns:
response code
result_list: subpack tuple result_list: subpack tuple
Raises: Raises:
AttributeError: The object does not have this property AttributeError: The object does not have this property
...@@ -196,18 +198,17 @@ class SearchDB(): ...@@ -196,18 +198,17 @@ class SearchDB():
return ResponseCode.INPUT_NONE, None return ResponseCode.INPUT_NONE, None
for db_name, data_base in self.db_object_dict.items(): for db_name, data_base in self.db_object_dict.items():
try: try:
name_in = literal_column('src_name').in_(search_set) name_in = literal_column('name').in_(search_set)
sql_com = text('''SELECT sql_com = text('''
NAME AS subpack_name, SELECT
src_name AS search_name, bin_pack.name AS subpack_name,
version AS search_version src.name AS search_name,
src.version AS search_version
FROM FROM
bin_pack (SELECT name,version FROM src_pack WHERE {}) src
WHERE LEFT JOIN bin_pack on src.name = bin_pack.src_name'''.format(name_in))
{}
'''.format(name_in))
subpack_tuple = data_base.session. \ 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() for i, v in enumerate(search_set, 1)}).fetchall()
if subpack_tuple: if subpack_tuple:
for result in subpack_tuple: for result in subpack_tuple:
...@@ -226,8 +227,6 @@ class SearchDB(): ...@@ -226,8 +227,6 @@ class SearchDB():
return_tuple = namedtuple( return_tuple = namedtuple(
'return_tuple', 'subpack_name search_version search_name') 'return_tuple', 'subpack_name search_version search_name')
for search_name in search_set: for search_name in search_set:
# LOGGER.logger.warning("Can't not find " +
# search_name + " subpack in all database")
result_list.append( result_list.append(
(return_tuple(None, None, search_name), 'NOT_FOUND')) (return_tuple(None, None, search_name), 'NOT_FOUND'))
return ResponseCode.SUCCESS, result_list return ResponseCode.SUCCESS, result_list
...@@ -310,8 +309,16 @@ class SearchDB(): ...@@ -310,8 +309,16 @@ class SearchDB():
if not_found_binary: if not_found_binary:
for key, values in not_found_binary.items(): for key, values in not_found_binary.items():
LOGGER.logger.warning( for info in values:
"CANNOT FOUND THE component" + key + " in all database") obj = return_tuple(
info[0],
None,
None,
None,
'NOT FOUND',
info[2]
)
result_list.append(obj)
return result_list return result_list
def _get_install_pro_in_other_database(self, not_found_binary): def _get_install_pro_in_other_database(self, not_found_binary):
...@@ -362,9 +369,18 @@ class SearchDB(): ...@@ -362,9 +369,18 @@ class SearchDB():
del not_found_binary[result.req_name] del not_found_binary[result.req_name]
if not not_found_binary: if not not_found_binary:
return result_list return result_list
# if not_found_binary: if not_found_binary:
# for key, values in not_found_binary.items(): 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(
None,
None,
None,
info[0],
info[1],
info[2]
)
result_list.append((obj, info[3]))
return result_list return result_list
def get_build_depend(self, source_name_li): def get_build_depend(self, source_name_li):
...@@ -376,7 +392,7 @@ class SearchDB(): ...@@ -376,7 +392,7 @@ class SearchDB():
all source pkg build depend list all source pkg build depend list
structure :[(search_name,source_name,bin_name,bin_version,db_name,search_version), 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),] (search_name,source_name,bin_name,bin_version,db_name,search_version),]
set: package not found components name set
Raises: Raises:
AttributeError: The object does not have this property AttributeError: The object does not have this property
SQLAlchemyError: sqlalchemy error SQLAlchemyError: sqlalchemy error
...@@ -393,7 +409,7 @@ class SearchDB(): ...@@ -393,7 +409,7 @@ class SearchDB():
s_name_set = set(source_name_li) s_name_set = set(source_name_li)
if not s_name_set: if not s_name_set:
return ResponseCode.PARAM_ERROR, None return ResponseCode.PARAM_ERROR, set()
provides_not_found = dict() provides_not_found = dict()
build_list = [] build_list = []
...@@ -465,7 +481,7 @@ class SearchDB(): ...@@ -465,7 +481,7 @@ class SearchDB():
build_result = self._get_binary_in_other_database( build_result = self._get_binary_in_other_database(
provides_not_found) provides_not_found)
build_list.extend(build_result) build_list.extend(build_result)
return ResponseCode.SUCCESS, build_list return ResponseCode.SUCCESS, build_list, set(provides_not_found.keys())
if s_name_set: if s_name_set:
build_result = self._get_binary_in_other_database( build_result = self._get_binary_in_other_database(
...@@ -474,7 +490,7 @@ class SearchDB(): ...@@ -474,7 +490,7 @@ class SearchDB():
for source in s_name_set: for source in s_name_set:
LOGGER.logger.warning( LOGGER.logger.warning(
"CANNOT FOUND THE source " + source + " in all database") "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): def binary_search_database_for_first_time(self, binary_name):
""" """
......
...@@ -33,6 +33,7 @@ class SelfDepend(): ...@@ -33,6 +33,7 @@ class SelfDepend():
search_subpack_list: Contain the source packages searched subpack in the next loop search_subpack_list: Contain the source packages searched subpack in the next loop
withsubpack: withsubpack withsubpack: withsubpack
search_db: A object of database which would be connected search_db: A object of database which would be connected
not_found_components: Contain the package not found components
""" """
def __init__(self, db_list): def __init__(self, db_list):
""" """
...@@ -47,6 +48,7 @@ class SelfDepend(): ...@@ -47,6 +48,7 @@ class SelfDepend():
self.withsubpack = 0 self.withsubpack = 0
self.db_list = db_list self.db_list = db_list
self.search_db = SearchDB(db_list) self.search_db = SearchDB(db_list)
self.not_found_components = set()
def query_depend(self, packname, selfbuild, withsubpack, packtype='binary'): def query_depend(self, packname, selfbuild, withsubpack, packtype='binary'):
""" """
...@@ -59,17 +61,18 @@ class SelfDepend(): ...@@ -59,17 +61,18 @@ class SelfDepend():
Returns: Returns:
binary_dict.dictionary: Contain all the binary packages info after searching binary_dict.dictionary: Contain all the binary packages info after searching
source_dicts.dictionary: Contain all the source 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: Raises:
""" """
if not self.search_db.db_object_dict: 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: if not packname:
return ResponseCode.INPUT_NONE return ResponseCode.INPUT_NONE
self.withsubpack = withsubpack self.withsubpack = withsubpack
response_code = self.init_dict(packname, packtype) response_code = self.init_dict(packname, packtype)
if response_code != ResponseCode.SUCCESS: 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(): for key, _ in self.binary_dict.dictionary.items():
self.search_install_list.append(key) self.search_install_list.append(key)
...@@ -85,7 +88,7 @@ class SelfDepend(): ...@@ -85,7 +88,7 @@ class SelfDepend():
self.with_subpack() self.with_subpack()
if self.search_build_list: if self.search_build_list:
self.query_build(selfbuild) 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): def init_dict(self, packname, packtype):
""" """
...@@ -130,9 +133,10 @@ class SelfDepend(): ...@@ -130,9 +133,10 @@ class SelfDepend():
Raises: Raises:
""" """
self.result_tmp.clear() self.result_tmp.clear()
_, self.result_tmp = \ _, self.result_tmp, not_fd_com = \
install_depend(self.db_list).query_install_depend(self.search_install_list, install_depend(self.db_list).query_install_depend(self.search_install_list,
self.binary_dict.dictionary) self.binary_dict.dictionary)
self.not_found_components.update(not_fd_com)
self.search_install_list.clear() self.search_install_list.clear()
for key, values in self.result_tmp.items(): for key, values in self.result_tmp.items():
if key in self.binary_dict.dictionary: if key in self.binary_dict.dictionary:
...@@ -199,13 +203,13 @@ class SelfDepend(): ...@@ -199,13 +203,13 @@ class SelfDepend():
Returns: Returns:
Raises: Raises:
""" """
_, self.result_tmp, _ = build_depend( _, self.result_tmp, _, not_fd_com = build_depend(
self.search_build_list, self.search_build_list,
self.db_list, self.db_list,
self_build=0, self_build=0,
history_dict=self.binary_dict.dictionary history_dict=self.binary_dict.dictionary
).build_depend_main() ).build_depend_main()
self.not_found_components.update(not_fd_com)
self.search_build_list.clear() self.search_build_list.clear()
for key, values in self.result_tmp.items(): for key, values in self.result_tmp.items():
if not key: if not key:
...@@ -231,13 +235,13 @@ class SelfDepend(): ...@@ -231,13 +235,13 @@ class SelfDepend():
Args: Args:
Returns: Returns:
""" """
_, self.result_tmp, source_dicts_tmp = build_depend( _, self.result_tmp, source_dicts_tmp, not_fd_com = build_depend(
self.search_build_list, self.search_build_list,
self.db_list, self.db_list,
self_build=1, self_build=1,
history_dict=self.source_dicts.dictionary history_dict=self.source_dicts.dictionary
).build_depend_main() ).build_depend_main()
self.not_found_components.update(not_fd_com)
for key, values in self.result_tmp.items(): for key, values in self.result_tmp.items():
if not key: if not key:
LOGGER.logger.warning("key is NONE for value = " + str(values)) LOGGER.logger.warning("key is NONE for value = " + str(values))
......
...@@ -38,7 +38,9 @@ from .serialize import SelfDependSchema ...@@ -38,7 +38,9 @@ from .serialize import SelfDependSchema
from .serialize import have_err_db_name from .serialize import have_err_db_name
LOGGER = Log(__name__) LOGGER = Log(__name__)
#pylint: disable = no-self-use
# pylint: disable = no-self-use
class Packages(Resource): class Packages(Resource):
...@@ -215,16 +217,22 @@ class InstallDepend(Resource): ...@@ -215,16 +217,22 @@ class InstallDepend(Resource):
ResponseCode.response_json(ResponseCode.DB_NAME_ERROR) 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]) installdepend(db_list).query_install_depend([pkg_name])
if not install_dict: if not install_dict:
return jsonify( return jsonify(
ResponseCode.response_json(response_code) 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( 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): ...@@ -282,12 +290,23 @@ class BuildDepend(Resource):
build_ins = builddepend([pkg_name], db_list) 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( return jsonify(
ResponseCode.response_json( ResponseCode.response_json(
res_code, 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): ...@@ -350,7 +369,7 @@ class SelfDepend(Resource):
return jsonify( return jsonify(
ResponseCode.response_json(ResponseCode.DB_NAME_ERROR) 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), self_depend(db_list).query_depend(pkg_name, int(self_build),
int(with_sub_pack), pack_type) int(with_sub_pack), pack_type)
...@@ -362,7 +381,8 @@ class SelfDepend(Resource): ...@@ -362,7 +381,8 @@ class SelfDepend(Resource):
return jsonify( return jsonify(
ResponseCode.response_json(ResponseCode.SUCCESS, data={ ResponseCode.response_json(ResponseCode.SUCCESS, data={
"binary_dicts": binary_dicts, "binary_dicts": binary_dicts,
"source_dicts": source_dicts "source_dicts": source_dicts,
"not_found_components": list(not_fd_components)
}) })
) )
......
...@@ -10,6 +10,7 @@ import os ...@@ -10,6 +10,7 @@ import os
import json import json
import threading import threading
from json.decoder import JSONDecodeError from json.decoder import JSONDecodeError
try: try:
import argparse import argparse
import requests import requests
...@@ -209,11 +210,12 @@ class PkgshipCommand(BaseCommand): ...@@ -209,11 +210,12 @@ class PkgshipCommand(BaseCommand):
except Error: except Error:
print('command 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 Description: Parsing package data with dependencies
Args: Args:
response_data: http request response content response_data: http request response content
params: Parameters passed in on the command line
Returns: Returns:
Summarized data table Summarized data table
Raises: Raises:
...@@ -224,6 +226,12 @@ class PkgshipCommand(BaseCommand): ...@@ -224,6 +226,12 @@ class PkgshipCommand(BaseCommand):
if response_data.get('code') == ResponseCode.SUCCESS: if response_data.get('code') == ResponseCode.SUCCESS:
package_all = response_data.get('data') package_all = response_data.get('data')
if isinstance(package_all, dict): 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(): for bin_package, package_depend in package_all.items():
# distinguish whether the current data is the data of the root node # distinguish whether the current data is the data of the root node
...@@ -753,7 +761,7 @@ class BuildDepCommand(PkgshipCommand): ...@@ -753,7 +761,7 @@ class BuildDepCommand(PkgshipCommand):
if response.status_code == 200: if response.status_code == 200:
try: try:
statistics_table = self.parse_depend_package( statistics_table = self.parse_depend_package(
json.loads(response.text)) json.loads(response.text), params)
except JSONDecodeError as json_error: except JSONDecodeError as json_error:
LOGGER.logger.error(json_error) LOGGER.logger.error(json_error)
print(response.text) print(response.text)
...@@ -813,11 +821,12 @@ class InstallDepCommand(PkgshipCommand): ...@@ -813,11 +821,12 @@ class InstallDepCommand(PkgshipCommand):
cmd_params[0], nargs='*', default=None, help=cmd_params[1]) cmd_params[0], nargs='*', default=None, help=cmd_params[1])
self.parse.set_defaults(func=self.do_command) 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 Description: Parse the corresponding data of the package
Args: Args:
response_data: http response data response_data: http response data
params: Parameters passed in on the command line
Returns: Returns:
Raises: Raises:
...@@ -832,7 +841,11 @@ class InstallDepCommand(PkgshipCommand): ...@@ -832,7 +841,11 @@ class InstallDepCommand(PkgshipCommand):
if response_data.get('code') == ResponseCode.SUCCESS: if response_data.get('code') == ResponseCode.SUCCESS:
package_all = response_data.get('data') package_all = response_data.get('data')
if isinstance(package_all, dict): 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 # distinguish whether the current data is the data of the root node
if isinstance(package_depend, list) and package_depend[-1][0][0] != 'root': if isinstance(package_depend, list) and package_depend[-1][0][0] != 'root':
...@@ -895,13 +908,13 @@ class InstallDepCommand(PkgshipCommand): ...@@ -895,13 +908,13 @@ class InstallDepCommand(PkgshipCommand):
if response.status_code == 200: if response.status_code == 200:
try: try:
statistics_table = self.__parse_package( statistics_table = self.__parse_package(
json.loads(response.text)) json.loads(response.text), params)
except JSONDecodeError as json_error: except JSONDecodeError as json_error:
LOGGER.logger.error(json_error) LOGGER.logger.error(json_error)
print(response.text) print(response.text)
else: else:
if getattr(self.table, 'rowcount'): if getattr(self.table, 'rowcount'):
self.print_('query{} InstallDepend result display:'.format( self.print_('query {} InstallDepend result display:'.format(
params.packagename)) params.packagename))
print(self.table) print(self.table)
self.print_('statistics') self.print_('statistics')
...@@ -1034,11 +1047,12 @@ class SelfBuildCommand(PkgshipCommand): ...@@ -1034,11 +1047,12 @@ class SelfBuildCommand(PkgshipCommand):
return src_package_count 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 Description: Parse the corresponding data of the package
Args: Args:
response_data: http response data response_data: http response data
params: Parameters passed in on the command line
Returns: Returns:
Summarized data table Summarized data table
Raises: Raises:
...@@ -1053,6 +1067,10 @@ class SelfBuildCommand(PkgshipCommand): ...@@ -1053,6 +1067,10 @@ class SelfBuildCommand(PkgshipCommand):
package_all = response_data.get('data') package_all = response_data.get('data')
if isinstance(package_all, dict): if isinstance(package_all, dict):
# Parsing binary result data # 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( bin_package_count = self._parse_bin_package(
package_all.get('binary_dicts')) package_all.get('binary_dicts'))
...@@ -1096,7 +1114,7 @@ class SelfBuildCommand(PkgshipCommand): ...@@ -1096,7 +1114,7 @@ class SelfBuildCommand(PkgshipCommand):
if response.status_code == 200: if response.status_code == 200:
try: try:
statistics_table = self.__parse_package( statistics_table = self.__parse_package(
json.loads(response.text)) json.loads(response.text), params)
except JSONDecodeError as json_error: except JSONDecodeError as json_error:
LOGGER.logger.error(json_error) LOGGER.logger.error(json_error)
print(response.text) print(response.text)
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
dbname: mainline dbname: mainline
priority: 1 priority: 1
src_db_file: src_db_file:
status: enable lifecycle: enable
- bin_db_file: - bin_db_file:
dbname: fedora30 dbname: fedora30
priority: 2 priority: 2
src_db_file: src_db_file:
status: enable lifecycle: enable
...@@ -6,84 +6,87 @@ ...@@ -6,84 +6,87 @@
"output": { "output": {
"code": "2001", "code": "2001",
"data": { "data": {
"A_src": [ "build_dict": {
"source", "A_src": [
"0.0.23b", "source",
"mainline", "0.0.23b",
[ "mainline",
[ [
"root", [
null "root",
null
]
] ]
] ],
], "B1": [
"B1": [ "B",
"B", "0.0.2",
"0.0.2", "mainline",
"mainline",
[
[ [
"A", [
"build" "A",
"build"
]
] ]
] ],
], "C1": [
"C1": [ "C",
"C", "0.1",
"0.1", "mainline",
"mainline",
[
[ [
"A", [
"build" "A",
], "build"
[ ],
"A2", [
"install" "A2",
"install"
]
] ]
] ],
], "A1": [
"A1": [ "A",
"A", "0.0.23b",
"0.0.23b", "mainline",
"mainline",
[
[ [
"B1", [
"install" "B1",
], "install"
[ ],
"D1", [
"install" "D1",
"install"
]
] ]
] ],
], "A2": [
"A2": [ "A",
"A", "0.0.23b",
"0.0.23b", "mainline",
"mainline",
[
[ [
"A1", [
"install" "A1",
], "install"
[ ],
"C1", [
"install" "C1",
"install"
]
] ]
] ],
], "D1": [
"D1": [ "D",
"D", "0.11",
"0.11", "mainline",
"mainline",
[
[ [
"A2", [
"install" "A2",
"install"
]
] ]
] ]
] },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
......
...@@ -6,58 +6,61 @@ ...@@ -6,58 +6,61 @@
"output": { "output": {
"code": "2001", "code": "2001",
"data": { "data": {
"A1": [ "install_dict": {
"A", "A1": [
"0.0.23b", "A",
"mainline", "0.0.23b",
[ "mainline",
[ [
"root", [
null "root",
], null
[ ],
"D1", [
"install" "D1",
"install"
]
] ]
] ],
], "A2": [
"A2": [ "A",
"A", "0.0.23b",
"0.0.23b", "mainline",
"mainline",
[
[
"A1",
"install"
],
[ [
"C1", [
"install" "A1",
"install"
],
[
"C1",
"install"
]
] ]
] ],
], "C1": [
"C1": [ "C",
"C", "0.1",
"0.1", "mainline",
"mainline",
[
[ [
"A2", [
"install" "A2",
"install"
]
] ]
] ],
], "D1": [
"D1": [ "D",
"D", "0.11",
"0.11", "mainline",
"mainline",
[
[ [
"A2", [
"install" "A2",
"install"
]
] ]
] ]
] },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
...@@ -69,69 +72,72 @@ ...@@ -69,69 +72,72 @@
"output": { "output": {
"code": "2001", "code": "2001",
"data": { "data": {
"A1": [ "install_dict": {
"A", "A1": [
"0.0.23b", "A",
"mainline", "0.0.23b",
[ "mainline",
[ [
"D1", [
"install" "D1",
"install"
]
] ]
] ],
], "A2": [
"A2": [ "A",
"A", "0.0.23b",
"0.0.23b", "mainline",
"mainline",
[
[ [
"A1", [
"install" "A1",
], "install"
[ ],
"C1", [
"install" "C1",
"install"
]
] ]
] ],
], "C1": [
"C1": [ "C",
"C", "0.1",
"0.1", "mainline",
"mainline",
[
[ [
"A2", [
"install" "A2",
"install"
]
] ]
] ],
], "D1": [
"D1": [ "D",
"D", "0.11",
"0.11", "mainline",
"mainline",
[
[ [
"D2", [
"install" "D2",
], "install"
[ ],
"A2", [
"install" "A2",
"install"
]
] ]
] ],
], "D2": [
"D2": [ "D",
"D", "0.11",
"0.11", "mainline",
"mainline",
[
[ [
"root", [
null "root",
null
]
] ]
] ]
] },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
...@@ -143,17 +149,20 @@ ...@@ -143,17 +149,20 @@
"output": { "output": {
"code": "2001", "code": "2001",
"data": { "data": {
"C2": [ "install_dict": {
"C", "C2": [
"0.1", "C",
"mainline", "0.1",
[ "mainline",
[ [
"root", [
null "root",
null
]
] ]
] ]
] },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
......
...@@ -123,7 +123,8 @@ ...@@ -123,7 +123,8 @@
"mainline", "mainline",
"0.11" "0.11"
] ]
} },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
...@@ -264,7 +265,8 @@ ...@@ -264,7 +265,8 @@
"mainline", "mainline",
"0.11" "0.11"
] ]
} },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
...@@ -421,7 +423,8 @@ ...@@ -421,7 +423,8 @@
"mainline", "mainline",
"0.11" "0.11"
] ]
} },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
...@@ -583,7 +586,9 @@ ...@@ -583,7 +586,9 @@
"mainline", "mainline",
"0.11" "0.11"
] ]
} },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
...@@ -753,7 +758,9 @@ ...@@ -753,7 +758,9 @@
"mainline", "mainline",
"0.11" "0.11"
] ]
} },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
...@@ -892,7 +899,9 @@ ...@@ -892,7 +899,9 @@
"mainline", "mainline",
"0.11" "0.11"
] ]
} },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
...@@ -1036,7 +1045,9 @@ ...@@ -1036,7 +1045,9 @@
"mainline", "mainline",
"0.11" "0.11"
] ]
} },
"not_found_components": []
}, },
"msg": "Successful Operation!" "msg": "Successful Operation!"
} }
......
...@@ -89,17 +89,17 @@ class TestInstallDepend(ReadTestBase): ...@@ -89,17 +89,17 @@ class TestInstallDepend(ReadTestBase):
resp_dict = json.loads(resp.data) resp_dict = json.loads(resp.data)
self.assertIn("code", resp_dict, msg="Error in data format return") 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"), resp_dict.get("code"),
msg="Error in status code return") msg="Error in status code return")
self.assertIn("msg", resp_dict, msg="Error in data format 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"), resp_dict.get("msg"),
msg="Error in status prompt return") msg="Error in status prompt return")
self.assertIn("data", resp_dict, msg="Error in data format 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", resp = self.client.post("/packages/findInstallDepend",
data=json.dumps({"binaryName": "A1", data=json.dumps({"binaryName": "A1",
......
...@@ -19,8 +19,8 @@ def write_data_tests(): ...@@ -19,8 +19,8 @@ def write_data_tests():
suite = unittest.TestSuite() suite = unittest.TestSuite()
classes = [ classes = [
# TestDeleteRepodatas, TestDeleteRepodatas,
# TestBatchUpdatePackage, TestBatchUpdatePackage,
TestIssueCatch TestIssueCatch
] ]
for cls in classes: for cls in classes:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册