From 4f9c2f3a7ad1e4d58f1604b6580cc5958f08cebd Mon Sep 17 00:00:00 2001 From: Shuang Zheng Date: Fri, 27 Sep 2019 10:29:35 +0800 Subject: [PATCH] acrn-config: fix the issue config app failed to generate patch for a new board MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix the issue: WebUI could not generate configuration patch for a new imported board Tracked-On: #3760 Signed-off-by: Shuang Zheng Reviewed-by: Victor Sun --- misc/acrn-config/config_app/controller.py | 7 +++++-- misc/acrn-config/config_app/views.py | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/misc/acrn-config/config_app/controller.py b/misc/acrn-config/config_app/controller.py index eaea8fa67..e764ee92e 100644 --- a/misc/acrn-config/config_app/controller.py +++ b/misc/acrn-config/config_app/controller.py @@ -253,10 +253,11 @@ class XmlConfig: raise Exception('can not find node by {} from xml'.format(args)) - def save(self, xml=None): + def save(self, xml=None, user_defined=True): """ save current xml to file. :param xml: the file name to save; if not specified, save current xml to default names. + :param user_defined: save to user defined folder or default folder. :return: None. """ if self._curr_xml_tree is None: @@ -264,7 +265,9 @@ class XmlConfig: if xml is None: xml = self._curr_xml - xml_path = os.path.join(self._xml_path, 'user_defined') + xml_path = self._xml_path + if user_defined: + xml_path = os.path.join(self._xml_path, 'user_defined') if not os.path.isdir(xml_path): os.makedirs(xml_path) diff --git a/misc/acrn-config/config_app/views.py b/misc/acrn-config/config_app/views.py index ed18400c0..9ddbdd923 100644 --- a/misc/acrn-config/config_app/views.py +++ b/misc/acrn-config/config_app/views.py @@ -452,7 +452,13 @@ def upload_board_info(): for generic_name in os.listdir(os.path.join(config_path, 'generic')): generic_file = os.path.join(config_path, 'generic', generic_name) if os.path.isfile(generic_file): - copyfile(generic_file, os.path.join(config_path, board_type, generic_name)) + new_file = os.path.join(config_path, board_type, generic_name) + copyfile(generic_file, new_file) + xml_config = XmlConfig(os.path.join(current_app.config.get('CONFIG_PATH'), + board_type)) + xml_config.set_curr(generic_name[:-4]) + xml_config.set_curr_attr('board', board_type) + xml_config.save(generic_name[:-4], user_defined=False) board_info = os.path.splitext(file.filename)[0] current_app.config.update(BOARD_INFO=board_info)