public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-staging/EdkRepo] [PATCH] EdkRepo: check for manifest-repos section in edkrepo_user.cfg
@ 2020-06-08 21:52 Nate DeSimone
  2020-06-08 21:55 ` [edk2-devel] " Bjorge, Erik C
  2020-06-09 21:56 ` Ashley E Desimone
  0 siblings, 2 replies; 3+ messages in thread
From: Nate DeSimone @ 2020-06-08 21:52 UTC (permalink / raw)
  To: devel
  Cc: Ashley E Desimone, Puja Pandya, Bret Barkelew, Prince Agyeman,
	Erik Bjorge

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 <nathaniel.l.desimone@intel.com>
Cc: Ashley E Desimone <ashley.e.desimone@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: check for manifest-repos section in edkrepo_user.cfg
  2020-06-08 21:52 [edk2-staging/EdkRepo] [PATCH] EdkRepo: check for manifest-repos section in edkrepo_user.cfg Nate DeSimone
@ 2020-06-08 21:55 ` Bjorge, Erik C
  2020-06-09 21:56 ` Ashley E Desimone
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorge, Erik C @ 2020-06-08 21:55 UTC (permalink / raw)
  To: devel@edk2.groups.io, Desimone, Nathaniel L
  Cc: Desimone, Ashley E, Pandya, Puja, Bret Barkelew, Agyeman, Prince

Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Nate DeSimone
Sent: Monday, June 8, 2020 2:52 PM
To: devel@edk2.groups.io
Cc: Desimone, Ashley E <ashley.e.desimone@intel.com>; Pandya, Puja <puja.pandya@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>; Agyeman, Prince <prince.agyeman@intel.com>; Bjorge, Erik C <erik.c.bjorge@intel.com>
Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: check for manifest-repos section in edkrepo_user.cfg

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 <nathaniel.l.desimone@intel.com>
Cc: Ashley E Desimone <ashley.e.desimone@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
---
 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





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-staging/EdkRepo] [PATCH] EdkRepo: check for manifest-repos section in edkrepo_user.cfg
  2020-06-08 21:52 [edk2-staging/EdkRepo] [PATCH] EdkRepo: check for manifest-repos section in edkrepo_user.cfg Nate DeSimone
  2020-06-08 21:55 ` [edk2-devel] " Bjorge, Erik C
@ 2020-06-09 21:56 ` Ashley E Desimone
  1 sibling, 0 replies; 3+ messages in thread
From: Ashley E Desimone @ 2020-06-09 21:56 UTC (permalink / raw)
  To: Desimone, Nathaniel L, devel@edk2.groups.io
  Cc: Pandya, Puja, Bret Barkelew, Agyeman, Prince, Bjorge, Erik C

Reviewed-by: Ashley DeSimone <ashley.e.desimone@intel.com>

-----Original Message-----
From: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com> 
Sent: Monday, June 8, 2020 2:52 PM
To: devel@edk2.groups.io
Cc: Desimone, Ashley E <ashley.e.desimone@intel.com>; Pandya, Puja <puja.pandya@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>; Agyeman, Prince <prince.agyeman@intel.com>; Bjorge, Erik C <erik.c.bjorge@intel.com>
Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: check for manifest-repos section in edkrepo_user.cfg

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 <nathaniel.l.desimone@intel.com>
Cc: Ashley E Desimone <ashley.e.desimone@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-09 21:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-08 21:52 [edk2-staging/EdkRepo] [PATCH] EdkRepo: check for manifest-repos section in edkrepo_user.cfg Nate DeSimone
2020-06-08 21:55 ` [edk2-devel] " Bjorge, Erik C
2020-06-09 21:56 ` Ashley E Desimone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox