From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web12.1635.1589218161393611132 for ; Mon, 11 May 2020 10:29:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=iWv3kVHd; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: ashley.e.desimone@intel.com) IronPort-SDR: h7gx6wQr04JZcgKPIq3CnEPe8+GVbxowPT96Lxwo7AMxzPr+gHlaEMQfH8Z0prTUpYQy/QEUs3 8J6bAWFrMLNQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2020 10:29:20 -0700 IronPort-SDR: BTJF8E3X9HW0CmMV7yILGHVCviTVL1o2mL+2smRbx9i/dFyjjURX7hSOXuvXxKV7h2fD84inwT bZ5MSTC52GZA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,380,1583222400"; d="scan'208";a="306240431" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by FMSMGA003.fm.intel.com with ESMTP; 11 May 2020 10:29:20 -0700 Received: from orsmsx111.amr.corp.intel.com (10.22.240.12) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 11 May 2020 10:29:20 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX111.amr.corp.intel.com (10.22.240.12) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 11 May 2020 10:29:19 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.168) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 11 May 2020 10:29:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=becbwphvqWZQRtSi8tkqeI5b2yjMou82jVFmzXL0Kjnvk0dafVOVq7u5EUkcExGHcvF/CNq/jdHX+KwTc7wInrWxT3iV3wLFWl3FTI+70Bk+xw+ZaMnUwyPax3XdM/AU+JkRslckgrTcnl5Xav/i1fRd9cDPPRW2bt3ADSvrNCDOUhG/M5lvb9DZDHN8vTr8H/ySA3ciZ7fm09SmWl3btnwKd2LU6yAqWI7nBxLdJLQCMI/m7563K2DrYlndLlFcwuZ4ShVH1FoS3l5izy7mq8QGNoMAqn4D0bfZoth4+UaZTzjSn0rcqKzvPvnBzhinrJoHAG8Sf4xkNnqaB5UXmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yzGIhMy4i0XUcgjroqgbr+1lF2BlEN1Wq9k4Ii2yvcE=; b=hgaKPbMWkrnh/BLO4LB+y6hXdyRHzeJ/yPvNDaeXtPt95sQIMpSMs5sRmAgNaHiARvRDCXbK9alFDBQdO6NjIfmH2QD8ClfHdRxMxnKLojTK5wVk/sOMBy3Xqd2gt1LHxcLj7huAtx8LS9KNVLu5eBGjXTVVM+Roh1GWCREus8MHuEcBATwMNmSxDUZoDP+hHkPtgp+K2vCj7gPbWbFhqSFIOMpRvCIs1pS24fh0PdwTQ3lC9KVQRYB9Qg/oLItsABJwp0fUgcrxITcaLjhhUulnqqAZ3vVRnjB6u9e4CRvgOO9bQuPcCcvUV2gu8x+QAtfFIooUtcnHlxChInncrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yzGIhMy4i0XUcgjroqgbr+1lF2BlEN1Wq9k4Ii2yvcE=; b=iWv3kVHdIJ2NbDqZtTNynyOBhv2yoSyTFVKpxHXifXvMGFMec+3/2XPsJZpU9EQOYm5Ygk6RWsgGhIPYIcn33Ou4n/dndK+h/qj+qk6BkXcMWbbAdm+qB1cBtkhz9EHcp+2nR6vmyYsXwJfoYKSIVg8xpl9AKPcz+XdHdyMPdS4= Received: from BY5PR11MB3973.namprd11.prod.outlook.com (2603:10b6:a03:185::29) by BY5PR11MB3928.namprd11.prod.outlook.com (2603:10b6:a03:188::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.35; Mon, 11 May 2020 17:29:08 +0000 Received: from BY5PR11MB3973.namprd11.prod.outlook.com ([fe80::296a:eb1c:2b52:2904]) by BY5PR11MB3973.namprd11.prod.outlook.com ([fe80::296a:eb1c:2b52:2904%7]) with mapi id 15.20.2979.033; Mon, 11 May 2020 17:29:08 +0000 From: "Ashley E Desimone" To: "Desimone, Nathaniel L" , "devel@edk2.groups.io" CC: "Pandya, Puja" , "Bjorge, Erik C" , Bret Barkelew , "Agyeman, Prince" Subject: Re: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Add the manifest-repos command Thread-Topic: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Add the manifest-repos command Thread-Index: AQHWJ032Pn0oq1QgREK63Rt3imdEFaiibmAwgAC1GZA= Date: Mon, 11 May 2020 17:29:08 +0000 Message-ID: References: <20200511043731.92716-1-ashley.e.desimone@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.52.213] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2a33afaf-dc9c-4d3e-96b3-08d7f5d0cfb9 x-ms-traffictypediagnostic: BY5PR11MB3928: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 04004D94E2 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Sz10VuUbA/hlPKSe0N3I2tNB3vj+scptepYNsPhx6yqJyYm7Zs0okrBwqwEZoEEXPBPPZmd70JwHpueoyG8TD2OE5btNCiEnnTA4cn5EyXn8o40VwY36qxJXJ4yMU6OIL5Ahc4fqKWekBjIGFRMXvIGGeOjML5ayY1yQw7BwIl6H7yff0XepGqQK2U9CrmldOisZBT2hnW+NtqoFG823aoQclvLru2TJFsEtyqQ9C9JCHVIHBbhsoDQYlgc2nM7KzPtmYwmhuBs9ch3vXsglF87iYLPNhga2lipBDhGQ35IBVUAtYWs3946+ypTutXI7ccK/PIPYYDPMHVI+sqBd5mRpF+W3PcdZhtW9xTZrFEQChlr0X8sVLlEj84AEeH6txtvnnA2MmhB0MTDtDWipQDpMtUBF6VT5dxAzxWLWd5M0zoQWV7xSXB/KC/E4Ddnicg9Coxsy1Z3cskK5tf7TRB0CCs0rliT92ca0RpvDRrT2f0qgokJf7LqI6rNXFG/klhW4/NA/KQz+PDghfMAT8w== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR11MB3973.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(366004)(346002)(136003)(39860400002)(376002)(396003)(33430700001)(76116006)(4326008)(66946007)(9686003)(71200400001)(66476007)(66446008)(66556008)(64756008)(33656002)(2906002)(26005)(7696005)(6506007)(8936002)(53546011)(8676002)(478600001)(54906003)(186003)(86362001)(316002)(107886003)(5660300002)(33440700001)(55016002)(110136005)(52536014);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: ymXeGpXJB+IG/3G16s0HddwxjCsvKc+siAQXveGMxwcQ/ri//V41IbCT2l9jJ0inamN85rmENCdFW5mwuRgNEI7tLzoAeFWOILfMk8FlmIG7MnOeiZ2rY2o2MK8H/z45jmn4BbnLYYBQbWk78/l1WRfzmuSJ7CyD9+UG7LhY3EJ68Byjo4I/TjRwlRbPtnnDJBhIFFMInRypAN7KSUuJag1tD/k+q6yox3S7PGMSdzn6XpYhvyOaBDRjRaxDQ8B5qffO7ZZFQYrYuZZvRcx7TDAVqB1ajC8co3qnKzE8PZfi7wosAr58T83k85tPPjPDlPKrn7G0b6aFg0Hh1WobcYV4Jgc2Vwo78vNTvDRdz8ov42xizALQg/8zkHo9/C43mbakag/rIbcSluS3MUqQ+NnfFSY9uhUwI5sVhLvDhKgBAK+wObqok5Fqt7pGaNLubi7nl6hEUwBRTmhBLyVPnsZTphKxNG+7V3h9Ex1Tlgo= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 2a33afaf-dc9c-4d3e-96b3-08d7f5d0cfb9 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 May 2020 17:29:08.1544 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: JjLKntZq4841T8x9b4cWaYYBJTWi+z3vX1H0EVX7IlyBU4/nKf1hvzIEy+slmMdotS9FumyZXM4btoXzG5YJZhzbaiTtATZKLYYfhlyxM+Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB3928 Return-Path: ashley.e.desimone@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Nate, A V2 patchset has been sent please see an additional comment below regardin= g your feedback. Thanks, Ashley -----Original Message----- From: Desimone, Nathaniel L =20 Sent: Sunday, May 10, 2020 11:45 PM To: Desimone, Ashley E ; devel@edk2.groups.io Cc: Pandya, Puja ; Bjorge, Erik C ; Bret Barkelew ; Agyeman, Prince Subject: RE: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Add the manifest-repos= command Hi Ashley, Please see comments inline below. Thanks, Nate > -----Original Message----- > From: Desimone, Ashley E > Sent: Sunday, May 10, 2020 9:38 PM > To: devel@edk2.groups.io > Cc: Desimone, Nathaniel L ; Pandya,=20 > Puja ; Bjorge, Erik C=20 > ; Bret Barkelew=20 > ; Agyeman, Prince=20 > > Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Add the=20 > manifest-repos command >=20 > Add the manifest_repos_command to list, add, or remove manifest=20 > repositories in the ekdrepo_user.cfg >=20 > Signed-off-by: Ashley E Desimone > Cc: Nate DeSimone > Cc: Puja Pandya > Cc: Erik Bjorge > Cc: Bret Barkelew > Cc: Prince Agyeman > --- > edkrepo/commands/arguments/manifest_repo_args.py | 21 +++++=20 > edkrepo/commands/humble/manifest_repos_humble.py | 21 +++++ > edkrepo/commands/manifest_repos_command.py | 106 > +++++++++++++++++++++++ > 3 files changed, 148 insertions(+) > create mode 100644 > edkrepo/commands/arguments/manifest_repo_args.py > create mode 100644 > edkrepo/commands/humble/manifest_repos_humble.py > create mode 100644 edkrepo/commands/manifest_repos_command.py >=20 > diff --git a/edkrepo/commands/arguments/manifest_repo_args.py > b/edkrepo/commands/arguments/manifest_repo_args.py > new file mode 100644 > index 0000000..b99d9d6 > --- /dev/null > +++ b/edkrepo/commands/arguments/manifest_repo_args.py > @@ -0,0 +1,21 @@ > +#!/usr/bin/env python3 > +# > +## @file > +# manifest_repo_args.py > +# > +# Copyright (c) 2020, Intel Corporation. All rights reserved.
# > +SPDX-License-Identifier: BSD-2-Clause-Patent # > + > +''' Contains the help and description strings for arguments in the=20 > +manifest_repo command meta data. > +''' > + > +COMMAND_DESCRIPTION =3D 'Lists, adds or removes a manifest repository.' > +LIST_HELP =3D 'List all available manifest repositories.' > +ADD_HELP =3D 'Add a manifest repository.' > +REMOVE_HELP =3D 'Remove a manifest repository.' > +NAME_HELP =3D 'The name of a manifest repository to add/remove. > Required with Add or Remove flags.' > +URL_HELP =3D 'The URL of a manifest repository to add. Required with=20 > +Add > flag.' > +LOCAL_PATH_HELP =3D 'The local path that a manifest is stored at in the > edkrepo global data directory. Required with Add flag.' > +BRANCH_HELP =3D 'The branch of a manifest repository to use. Required=20 > +with > Add flag.' > diff --git a/edkrepo/commands/humble/manifest_repos_humble.py > b/edkrepo/commands/humble/manifest_repos_humble.py > new file mode 100644 > index 0000000..bc00796 > --- /dev/null > +++ b/edkrepo/commands/humble/manifest_repos_humble.py > @@ -0,0 +1,21 @@ > +#!/usr/bin/env python3 > +# > +## @file > +# manifest_repos_humble.py > +# > +# Copyright (c) 2019, Intel Corporation. All rights reserved.
# Update copyright year > +SPDX-License-Identifier: BSD-2-Clause-Patent # > + > +''' > +Contains user visible strings printed by the manifest_repos command. > +''' > + > +CFG_LIST_ENTRY =3D 'Config File: edkrepo.cfg Manifest Repository Name: {= }' > +USER_CFG_LIST_ENTRY =3D 'Config File: edkrepo_user.cfg Manifest > Repository Name: {}' > +NAME_REQUIRED =3D 'The "name" argument is required to add/remove a > manifest repository' > +ADD_REQUIRED =3D 'The "name", "url", "branch" and "local-path"=20 > +arguments > are required to add a manifest repository' > +ADD_REMOVE =3D 'The "add" and "remove" flags cannot be used at the same > time.' > +CANNOT_REMOVE_CFG =3D 'Manifest repositories cannot be removed from > the edkrepo.cfg file.' > +REMOVE_NOT_EXIST =3D 'The selected manifest repository does note exist=20 > +in > the edkrepo_user.cfg file.' > +ALREADY_EXISTS =3D 'A manifest repository already exists with name: {}' > diff --git a/edkrepo/commands/manifest_repos_command.py > b/edkrepo/commands/manifest_repos_command.py > new file mode 100644 > index 0000000..c43e9e6 > --- /dev/null > +++ b/edkrepo/commands/manifest_repos_command.py > @@ -0,0 +1,106 @@ > +#!/usr/bin/env python3 > +# > +## @file > +# ,amofest+_repos_command.py Misspelling, should be manifest_repos_command.py > +# > +# Copyright (c) 2020, Intel Corporation. All rights reserved.
# > +SPDX-License-Identifier: BSD-2-Clause-Patent # > + > +import configparser > + > +from edkrepo.commands.edkrepo_command import EdkrepoCommand > import > +edkrepo.commands.arguments.manifest_repo_args as arguments import=20 > +edkrepo.commands.humble.manifest_repos_humble as humble from=20 > +edkrepo.common.edkrepo_exception import=20 > +EdkrepoInvalidParametersException from=20 > +edkrepo.common.workspace_maintenance.manifest_repos_maintenance > import > +list_available_manifest_repos > + > + > + > + > +class ManifestRepos(EdkrepoCommand): > + def __init__(self): > + super().__init__() > + > + def get_metadata(self): > + metadata =3D {} > + metadata['name'] =3D 'manifest-repos' > + metadata['help-text'] =3D arguments.COMMAND_DESCRIPTION > + args =3D [] > + metadata['arguments'] =3D args > + args.append({'name': 'list', > + 'positional': False, > + 'required': False, > + 'help-text': arguments.LIST_HELP}) > + args.append({'name': 'add', > + 'positional': False, > + 'required': False, > + 'help-text': arguments.ADD_HELP}) > + args.append({'name': 'remove', > + 'positional': False, > + 'required': False, > + 'help-text': arguments.REMOVE_HELP}) There is a better way to do this, use the "choice" parameter type. For example: args.append({choice: 'list', 'parent': 'action', 'help-text': arguments.LIST_HELP}) args.append({choice: 'add', 'parent': 'action', 'help-text': arguments.ADD_HELP}) args.append({choice: 'remove', 'parent': 'action', 'help-text': arguments.REMOVE_HELP}) args.append({'name': 'action', 'positional': True, 'position': 0, 'required': True, 'choices': True, 'help-text': arguments.ACTION_HELP}) > + args.append({'name': 'name', > + 'positional': True, > + 'required': False, > + 'position': 0, > + 'nargs' : 1, > + 'help-text': arguments.NAME_HELP}) > + args.append({'name': 'branch', > + 'positional': True, > + 'required': False, > + 'position': 2, > + 'nargs' : 1, > + 'help-text': arguments.BRANCH_HELP}) > + args.append({'name': 'url', > + 'positional': True, > + 'required': False, > + 'position': 1, > + 'nargs' : 1, > + 'help-text': arguments.URL_HELP}) > + args.append({'name': 'path', > + 'positional': True, > + 'required': False, > + 'position': 3, > + 'nargs' : 1, > + 'help-text': arguments.LOCAL_PATH_HELP}) > + return metadata > + > + def run_command(self, args, config): > + cfg_repos, user_cfg_repos, conflicts =3D=20 > + list_available_manifest_repos(config['cfg_file'], > + config['user_cfg_file']) > + > + if args.list: > + for repo in cfg_repos: > + print(humble.CFG_LIST_ENTRY.format(repo)) > + for repo in user_cfg_repos: > + print(humble.USER_CFG_LIST_ENTRY.format(repo)) > + > + if args.add and args.remove: > + raise EdkrepoInvalidParametersException(humble.ADD_REMOVE) > + elif (args.add or args.remove) and not args.name: > + raise EdkrepoInvalidParametersException(humble.NAME_REQUIRED= ) > + elif args.add and not (args.branch or args.url or args.local_pat= h): > + raise=20 > + EdkrepoInvalidParametersException(humble.ADD_REQUIRED) All of the mess above goes away if you use choice. Ashley- Not entirely there is no good built in method in arg parse to handl= e conditional mutual exclusivity of arguments. Even with choices used for l= ist, add and remove the checks for whether name/branch/url/path are include= d with remove or add will need to remain, updated to reflect the change to = using choice.=20 > + elif args.remove and args.name and args.name in cfg_repos: > + raise > EdkrepoInvalidParametersException(humble.CANNOT_REMOVE_CFG) > + elif args.remove and args.name not in > config['user_cfg_file'].manifest_repo_list: > + raise > EdkrepoInvalidParametersException(humble.REMOVE_NOT_EXIST) > + elif args.add and (args.name in cfg_repos or args.name in > user_cfg_repos): > + raise > + > EdkrepoInvalidParametersException(humble.ALREADY_EXISTS.format(args.n > a > + me)) > + > + user_cfg_file_path =3D config['user_cfg_file'].cfg_filename > + > + if args.add or args.remove: > + user_cfg_file =3D configparser.ConfigParser(allow_no_value= =3DTrue) > + user_cfg_file.read(user_cfg_file_path) > + if args.add: > + 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.remove: > + user_cfg_file.remove_option('manifest-repos', args.name) > + user_cfg_file.remove_section(args.name) > + with open(user_cfg_file_path, 'w') as cfg_stream: > + user_cfg_file.write(cfg_stream) > -- > 2.16.2.windows.1