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.web10.7525.1589179515435802837 for ; Sun, 10 May 2020 23:45:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=wq/DdKWr; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: nathaniel.l.desimone@intel.com) IronPort-SDR: VBFA66WQh/ZnVe3Qf/lrZq5/0moe9LGGtOe4AC26lBjQtpTd56vGBPzfhWwLw2ge3qnZxozT5C aEB7G3bHfrAQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2020 23:45:15 -0700 IronPort-SDR: zqTL8OnJ7HnGRzXuTercjNpITVVvDd6VL3R6Hv7PMmRh5bdj0L99LSj3nbLDYn5yKi73Qhd4t+ go12k6U52hAA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,378,1583222400"; d="scan'208";a="296848334" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by fmsmga002.fm.intel.com with ESMTP; 10 May 2020 23:45:14 -0700 Received: from orsmsx125.amr.corp.intel.com (10.22.240.125) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 10 May 2020 23:45:13 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX125.amr.corp.intel.com (10.22.240.125) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 10 May 2020 23:45:13 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.173) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 10 May 2020 23:45:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eW0TUNxUy9FPdf5vukXfZm4/sAQ1q7NxQB6PZ08p9Xt/iBl9z8XFZoBSYtS6bH6+EskU4H9U+fyxUWntQXIfLZ+9OztEDLf4boIj+3Vm6+o+ZPsvvzOFTB1tPdbBaBtedxwBAuR19EMMVHCsbkoYVx72tJd0BLloM1+M5G9HP4EZMEbaYaMo8NnPTY48CPIDOGc5MJyjYMITzx/arIJd0v0F1K1/k/KVm5PjaBgmIz9CGQ/yrDB66Nogi+yYvLoObxl6Yq9ClPA5vZOIXOkuZ12LxY7K7zbCoXaLZoIuuPlKha1gnMcr8AH8Pbi9lR9sIBxD46nnSfLhbOgSXTTDog== 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=3UG2rM0YaI3/VsXXQ9kfbDnxtwPlYtpC1c4iVOsIkKM=; b=E96PEXK7Q3JhMvjpZeal1lIVkBR+44EHner0Qor87BZa0IESBOtBLB5SRDKrR494hINnrYtbu1BX7dlS6VyBqdZZacboEmi5JokRSEQ0SkERUfp6RdDTZ/LwV4bcM+BHO7ljBF1496HrPObkREhCh9K5FCzW1t7JHStgxUwflPTHIOlV4c+mqysq3tak4rBdgdrk7ptB7ik9XiOq1/E2by/Xt1me26I8XB6sGe8IJnIDKQl9aU+1/wbwVz/8RiQ5CUYSWwbcXwdPHCI8c9AGi1BN91ovJCHKNd381xdTwtclrz5oQz6QJ92mi55hfqHwAqYVL4GJmFyAJrdcXgBQRg== 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=3UG2rM0YaI3/VsXXQ9kfbDnxtwPlYtpC1c4iVOsIkKM=; b=wq/DdKWrsb++TqVPSWJh8PQWAi6iwI/R6yL416tU2jDZKiuCeXdYPqjGnLBDscjFWlqqUDwQqqq+shdgaem4NS9Ph1U52/dInMtaGEF4c+SBdDGl5pmLBNJW0wA5k0rp//iQhwjJ+V7pROY8SiquY4lVMgBrBqa1Lb/7HTIh/0k= Received: from BL0PR11MB3489.namprd11.prod.outlook.com (2603:10b6:208:75::29) by BL0PR11MB3283.namprd11.prod.outlook.com (2603:10b6:208:69::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.29; Mon, 11 May 2020 06:45:11 +0000 Received: from BL0PR11MB3489.namprd11.prod.outlook.com ([fe80::d0f8:bfd7:bae2:3e42]) by BL0PR11MB3489.namprd11.prod.outlook.com ([fe80::d0f8:bfd7:bae2:3e42%7]) with mapi id 15.20.2979.033; Mon, 11 May 2020 06:45:11 +0000 From: "Nate DeSimone" 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 Thread-Topic: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Add the manifest-repos command Thread-Index: AQHWJ032Pn0oq1QgREK63Rt3imdEFaiibmAw Date: Mon, 11 May 2020 06:45:11 +0000 Message-ID: References: <20200511043731.92716-1-ashley.e.desimone@intel.com> In-Reply-To: <20200511043731.92716-1-ashley.e.desimone@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzc0OTkxZjItYjdlNy00NWRiLTg0ZjUtOWVjY2NhMTg5ZjI0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiWXVIdnZCbnVKaFIrbm50WGdkQjZ5VUdsV1drdE1KTXdjblRPcHpIVFRmMlFVaEkzbGpHR2haQ1lPWjkwZERmWSJ9 dlp-reaction: no-action dlp-version: 11.2.0.6 dlp-product: dlpe-windows x-ctpclassification: CTP_NT 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: [50.53.190.176] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 92912d48-84c3-4004-948b-08d7f576da63 x-ms-traffictypediagnostic: BL0PR11MB3283: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 04004D94E2 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: sRVAf8opfK7xqwAFknK64pyaFcIki+PUAUlkQfnZ7mFHK/oTNu+IBwZBvw6gb+/IY4Pgm712WEwF+w2LTy64tSL68eWIDE7NEXJoLRvZiGLK1+QfuLSosnU3YKiobXVXDB2Oub6Sa/YAHXe6Bf7m029CeaDVajW1x+gbsVnoWjp44OKRvQNMNtpow7Z/sSMSKMIiojpE2PZ0xQX5jt/d0a+wsiw3VRAu5o2OUvkVNkzHO3Fo/Gg6rid0cBpQ+xY2pQLtwJbqjgT62Gq8OCP+UedLNa0v+3RcU/ZoLBvMGv4o302enBnb8dbUAJYP17i0Zc/gYiest2AZmt0IwWp06yDhC68d3luU6p2VxX6kqFDQLsg24p1p8YYZHrsUMkVFsg9gtzxcZpSDjvFEL1e3P7iINhSPmuWomkUdx0gxs1TYfaAuQpGszXkOr0xZHOjBEGNTFbPoRBiocBvYkndWvwruJJW9u4covJ/zO3T9gO306CwXoLZjojejXs2K7vzSFibdfTwVgNiQ7PjB+CbXKw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR11MB3489.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(366004)(136003)(346002)(396003)(376002)(39860400002)(33430700001)(110136005)(316002)(7696005)(478600001)(6506007)(26005)(86362001)(52536014)(8676002)(186003)(53546011)(8936002)(54906003)(66476007)(66556008)(64756008)(66446008)(66946007)(76116006)(71200400001)(4326008)(55016002)(107886003)(9686003)(33656002)(5660300002)(2906002)(33440700001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: TQHGf0jKEj+bDCKcKh2PY3selPaaVfOCWgHxIOCBnmb6ntyG8v2QtKTK+tRmvECM6LPvCp2F9DObAp97VX7P+TYug80X+R4RIU9mCtlkmXs491Pqi41BkVKL6gCD2jIfK+bJrrQIZ0aHeOV3tVSEsrVBZZyVaiG7lXP9w+2AirxS6N1xupM+tMvBYgWkS1/D/81eBNX4xsyaakjDs+CXygAJ5yaqnX77peYZV5xcZTORQZ4w6xA86hQ/Mr8IlCjyUOtWoCH80qM1rLVuG/Q0oQqTu2Sy0MJONstyQTLqhgXN2e0bFMIdWl1Ne2zx0+E8W4jqSIhoMMAiID2JuHop0Xo5D/60TbRCzF7Or2H3M6M5Lszo+HH+8V2mKdN6iWRS9OsFSSaZFfUBZXvmt3eri2FcQtT/TArm8LJrb3afaO9lHDzp2TrRX8ykCfrHB60CU3sYedykXBux5qsX7ZPGSMmvYhDvkzpO7MDF/PHA9vo= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 92912d48-84c3-4004-948b-08d7f576da63 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 May 2020 06:45:11.3420 (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: Mm7qHBnWWY5CVfBLmfWD3BbJfZxcEE/6Roj1veixNCTKtGUVvS/FSTRHMnH5SOTC+8XJq4nzAMomVYUCK/iWNnKJSkpyaI0hXVuPBPBf12U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR11MB3283 Return-Path: nathaniel.l.desimone@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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, Puja > ; Bjorge, Erik C ; Bret > Barkelew ; Agyeman, Prince > > Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Add the manifest-repos > command >=20 > Add the manifest_repos_command to list, add, or remove manifest > 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 +++++ > 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 > +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 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 wi= th > 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" 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 i= n > 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 > +edkrepo.commands.humble.manifest_repos_humble as humble from > +edkrepo.common.edkrepo_exception import > +EdkrepoInvalidParametersException from > +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 > + 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 EdkrepoInvalidParametersException(humble.ADD_REQUIRED) All of the mess above goes away if you use choice. > + 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