提交 799aedec 编写于 作者: Y Yiru Wang Mac

change the public method to private and change the method name

上级 14a4da77
...@@ -53,6 +53,7 @@ class ResponseCode(): ...@@ -53,6 +53,7 @@ class ResponseCode():
PACK_NAME_NOT_FOUND: "Sorry! The querying package does not exist in the databases", PACK_NAME_NOT_FOUND: "Sorry! The querying package does not exist in the databases",
CONNECT_DB_ERROR: "Failed to Connect the database! " CONNECT_DB_ERROR: "Failed to Connect the database! "
"Please check the database connection", "Please check the database connection",
INPUT_NONE: "The input is None, please check the input value.",
FILE_NOT_FOUND: "Database import success file does not exist", FILE_NOT_FOUND: "Database import success file does not exist",
DELETE_DB_ERROR: "Failed to delete database", DELETE_DB_ERROR: "Failed to delete database",
CONFIGFILE_PATH_EMPTY: "Initialization profile does not exist or cannot be found", CONFIGFILE_PATH_EMPTY: "Initialization profile does not exist or cannot be found",
......
...@@ -26,7 +26,7 @@ class InstallDepend(): ...@@ -26,7 +26,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)
def install_depend_result(self, binary_list, history_dicts=None): def query_install_depend(self, binary_list, history_dicts=None):
''' '''
Description: init result dict and determint the loop end point Description: init result dict and determint the loop end point
:param binary_list: A list of binary rpm package name :param binary_list: A list of binary rpm package name
...@@ -46,26 +46,24 @@ class InstallDepend(): ...@@ -46,26 +46,24 @@ class InstallDepend():
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
if not binary_list: if not binary_list:
response_code = ResponseCode.INPUT_NONE, return ResponseCode.INPUT_NONE, None
return response_code, None
for binary in binary_list: for binary in binary_list:
if binary: if binary:
self.search_list.append(binary) self.search_list.append(binary)
else: else:
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:
response_code = self.query_install(history_dicts) self.__query_single_install_dep(history_dicts)
return response_code, self.binary_dict.dictionary if response_code != \ return ResponseCode.SUCCESS, self.binary_dict.dictionary
ResponseCode.DIS_CONNECTION_DB else None
def query_install(self, history_dicts): def __query_single_install_dep(self, history_dicts):
""" """
Description: query a package install depend and append to result Description: query a package install depend and append to result
:param history_dicts :param history_dicts
:return response_code :return response_code
changeLog: changeLog:
""" """
response_code, result_list = self.search_db.get_install_depend(self.search_list) result_list = self.search_db.get_install_depend(self.search_list)
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=[])
...@@ -99,7 +97,6 @@ class InstallDepend(): ...@@ -99,7 +97,6 @@ class InstallDepend():
self.binary_dict.init_key(key=result.depend_name, self.binary_dict.init_key(key=result.depend_name,
parent_node=[[result.search_name, 'install']]) parent_node=[[result.search_name, 'install']])
self.search_list.append(result.depend_name) self.search_list.append(result.depend_name)
return response_code
class DictionaryOperations(): class DictionaryOperations():
''' '''
......
...@@ -47,16 +47,18 @@ class SearchDB(): ...@@ -47,16 +47,18 @@ class SearchDB():
:return install depend list :return install depend list
changeLog: changeLog:
""" """
result_list = []
get_list = []
if not self.db_object_dict: if not self.db_object_dict:
return ResponseCode.DIS_CONNECTION_DB, None LOGGER.logger.warning("Unable to connect to the database, \
check the database configuration")
return result_list
if None in binary_list: if None in binary_list:
binary_list.remove(None) binary_list.remove(None)
search_set = set(binary_list) search_set = set(binary_list)
result_list = []
get_list = []
if not search_set: if not search_set:
return ResponseCode.INPUT_NONE, None LOGGER.logger.warning("The input is None, please check the input value.")
return result_list
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('name').in_(search_set) name_in = literal_column('name').in_(search_set)
...@@ -88,7 +90,7 @@ class SearchDB(): ...@@ -88,7 +90,7 @@ class SearchDB():
get_list.clear() get_list.clear()
search_set.symmetric_difference_update(get_set) search_set.symmetric_difference_update(get_set)
if not search_set: if not search_set:
return ResponseCode.SUCCESS, result_list return result_list
else: else:
continue continue
except AttributeError as error_msg: except AttributeError as error_msg:
...@@ -101,7 +103,7 @@ class SearchDB(): ...@@ -101,7 +103,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 ResponseCode.SUCCESS, result_list return result_list
def get_src_name(self, binary_name): def get_src_name(self, binary_name):
""" """
......
...@@ -274,7 +274,7 @@ class InstallDepend(Resource): ...@@ -274,7 +274,7 @@ class InstallDepend(Resource):
) )
response_code, install_dict = \ response_code, install_dict = \
installdepend(db_list).install_depend_result([pkg_name]) installdepend(db_list).query_install_depend([pkg_name])
if not install_dict: if not install_dict:
return jsonify( return jsonify(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册