From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.1618.1591653157102604273 for ; Mon, 08 Jun 2020 14:52:37 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: nathaniel.l.desimone@intel.com) IronPort-SDR: /w/0g8R8YmLXUKe4oW6T5vJjRr3TZEtPia1HCy+Jkkono2v2avDRKNU/lMyFPvMbZW9UgjJ8xp qbMo+YeEWmMA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 14:52:36 -0700 IronPort-SDR: vXrMQZ44FeWzN93sDsLDa/kHnNrZunN9JT58vqaVVUtnJsYfN2O5F7nBwG5PRYIIB6RYjJ8fCO NpmJXHk88Mow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,489,1583222400"; d="scan'208";a="306073078" Received: from ekmann-mobl.amr.corp.intel.com (HELO nldesimo-DESK1.amr.corp.intel.com) ([10.251.138.67]) by orsmga008.jf.intel.com with ESMTP; 08 Jun 2020 14:52:35 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Ashley E Desimone , Puja Pandya , Bret Barkelew , Prince Agyeman , Erik Bjorge Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: check for manifest-repos section in edkrepo_user.cfg Date: Mon, 8 Jun 2020 14:52:14 -0700 Message-Id: <20200608215214.2296-1-nathaniel.l.desimone@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The manifest-repos command currently does not check for the existance of the 'manifest-repos' section in the edkrepo_user.cfg file. This change adds the check. Signed-off-by: Nate DeSimone Cc: Ashley E Desimone Cc: Nate DeSimone Cc: Puja Pandya Cc: Bret Barkelew Cc: Prince Agyeman Cc: Erik Bjorge --- edkrepo/commands/manifest_repos_command.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/edkrepo/commands/manifest_repos_command.py b/edkrepo/commands/manifest_repos_command.py index b817662..3dbe604 100644 --- a/edkrepo/commands/manifest_repos_command.py +++ b/edkrepo/commands/manifest_repos_command.py @@ -95,13 +95,24 @@ class ManifestRepos(EdkrepoCommand): user_cfg_file = configparser.ConfigParser(allow_no_value=True) user_cfg_file.read(user_cfg_file_path) if args.action == 'add': + if not user_cfg_file.has_section('manifest-repos'): + user_cfg_file.add_section('manifest-repos') user_cfg_file.set('manifest-repos', args.name, None) user_cfg_file.add_section(args.name) user_cfg_file.set(args.name, 'URL', args.url) user_cfg_file.set(args.name, 'Branch', args.branch) user_cfg_file.set(args.name, 'LocalPath', args.path) if args.action == 'remove': - user_cfg_file.remove_option('manifest-repos', args.name) - user_cfg_file.remove_section(args.name) + if user_cfg_file.has_section('manifest-repos'): + if user_cfg_file.has_option('manifest-repos', args.name): + user_cfg_file.remove_option('manifest-repos', args.name) + else: + raise EdkrepoInvalidParametersException(humble.REMOVE_NOT_EXIST) + else: + raise EdkrepoInvalidParametersException(humble.REMOVE_NOT_EXIST) + if user_cfg_file.has_section(args.name): + user_cfg_file.remove_section(args.name) + else: + raise EdkrepoInvalidParametersException(humble.REMOVE_NOT_EXIST) with open(user_cfg_file_path, 'w') as cfg_stream: user_cfg_file.write(cfg_stream) -- 2.26.2.windows.1