From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web12.228.1586560960857644551 for ; Fri, 10 Apr 2020 16:22:41 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: nathaniel.l.desimone@intel.com) IronPort-SDR: MuWEvu7ChRN0iyBFaaUZptqPF3UhJJKD584MeIc9QNxW0XTKYlRtFwDo4NKDcm++1qfHFqqM7D /GImDNN+FdFw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2020 16:22:40 -0700 IronPort-SDR: UM4KA1mRPvOzPk43gg7E8e/l8Z2LhLY30IzFM4lOuCylFg0qNj66eidmflGfFZtRxeBtaUGr57 6DcKgASX+fbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,368,1580803200"; d="scan'208";a="241081858" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by orsmga007.jf.intel.com with ESMTP; 10 Apr 2020 16:22:40 -0700 Received: from orsmsx123.amr.corp.intel.com (10.22.240.116) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 10 Apr 2020 16:22:39 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.205]) by ORSMSX123.amr.corp.intel.com ([169.254.1.39]) with mapi id 14.03.0439.000; Fri, 10 Apr 2020 16:22:39 -0700 From: "Nate DeSimone" To: "devel@edk2.groups.io" , "Desimone, Ashley E" CC: "Pandya, Puja" , "Bjorge, Erik C" , Bret Barkelew , "Agyeman, Prince" Subject: Re: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v2] EdkRepo: Config_factory string clean up Thread-Topic: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v2] EdkRepo: Config_factory string clean up Thread-Index: AQHWD23zYE4C2/ppNkSrlEMWIMAjPKhy/ufQ Date: Fri, 10 Apr 2020 23:22:39 +0000 Message-ID: <02A34F284D1DA44BB705E61F7180EF0AB5E7EECC@ORSMSX114.amr.corp.intel.com> References: <20200410192609.23656-1-ashley.e.desimone@intel.com> In-Reply-To: <20200410192609.23656-1-ashley.e.desimone@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDE5NTIzNjQtZmZlMi00MTM5LWIzNDEtYzIwNGM3ZmYzN2RjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMTZOcnZSc3Fkd3VMQ1F3U1wvWEZMaG9xSk5FTmxJbmNId05TTnBRMStQVE5cL1RwS1NQWkJkV1BSQW1BbEFMa0NVIn0= x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Return-Path: nathaniel.l.desimone@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Nate DeSimone -----Original Message----- From: devel@edk2.groups.io On Behalf Of Ashley E De= simone Sent: Friday, April 10, 2020 12:26 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L ; Pandya, Puja <= puja.pandya@intel.com>; Bjorge, Erik C ; Bret Bark= elew ; Agyeman, Prince Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v2] EdkRepo: Config_fa= ctory string clean up Define and store config_config factory informational and error strings in = config/config_humble.py Signed-off-by: Ashley E Desimone Cc: Nate DeSimone Cc: Puja Pandya Cc: Erik Bjorge Cc: Bret Barkelew Cc: Prince Agyeman --- edkrepo/config/config_factory.py | 14 ++++++++------ edkrepo/config/humble/config_factory_humble.py | 14 ++++++++++++++ setup.py | 4 ++-- 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 edk= repo/config/humble/config_factory_humble.py diff --git a/edkrepo/config/config_factory.py b/edkrepo/config/config_fact= ory.py index b86e0b8..c342838 100644 --- a/edkrepo/config/config_factory.py +++ b/edkrepo/config/config_factory.py @@ -11,12 +11,14 @@ import os import sys import configparser import collections +from ctypes import * + +import edkrepo.config.humble.config_factory_humble as humble from edkrepo.common.edkrepo_exception import EdkrepoGlobalConfigNotFoundE= xception, EdkrepoConfigFileInvalidException from edkrepo.common.edkrepo_ex= ception import EdkrepoWorkspaceInvalidException, EdkrepoGlobalDataDirectory= NotFoundException from edkrepo.common.edkrepo_exception import EdkrepoConfigFileReadOnlyExc= eption from edkrepo.common.humble import MIRROR_PRIMARY_REPOS_MISSING, MIRROR_DE= CODE_WARNING, MAX_PATCH_SET_INVALID from edkrepo_manifest_parser import ed= k_manifest -from ctypes import * =20 def get_edkrepo_global_data_directory(): global_data_dir =3D None @@ -34,7 +36,7 @@ def get_edkrepo_global_data_directory(): global_data_dir =3D os.path.expanduser("~/.edkrepo") if not os.path.isdir(global_data_dir): if not os.path.exists(os.path.dirname(global_data_dir)): - raise EdkrepoGlobalDataDirectoryNotFoundException("{} does no= t exist".format(os.path.dirname(global_data_dir))) + raise=20 + EdkrepoGlobalDataDirectoryNotFoundException(humble.GLOBAL_DATA_DIR_NOT + _FOUND.format(os.path.dirname(global_data_dir))) os.mkdir(global_data_dir) return global_data_dir =20 @@ -63,7 +65,7 @@ def cfg_property(filename, cfg, read_only, section, key)= : return cfg[section][key] def _set(self, value): if read_only: - raise EdkrepoConfigFileReadOnlyException('The configuration f= ile is read only: {}'.format(filename)) + raise=20 + EdkrepoConfigFileReadOnlyException(humble.READ_ONLY_CFG.format(filenam + e)) cfg[section][key] =3D value with open(filename, 'w') as cfg_stream: cfg.write(cfg_stream) @@ -90,7 +92,7 @@ class BaseConfig(): if prop.section not in self.cfg or prop.key not in self.cfg[p= rop.section]: if prop.required or self.read_only: # Required property is missing - raise EdkrepoConfigFileInvalidException('{} is not pr= esent in {} section of {}'.format(prop.key, prop.section, os.path.basename(= self.filename))) + raise=20 + EdkrepoConfigFileInvalidException(humble.REQ_PROP_MISSING.format(prop. + key, prop.section, os.path.basename(self.filename))) if not self.read_only: # Create the missing property if prop.section not in self.cfg: @@ -126,7 +128,7 @@ class GlobalConfig(BaseConfig): CfgProp('preferred-command-package', 'preferred-package',= 'pref_pkg', None, True), CfgProp('preferred-entry-point', 'entry-point', 'pref_ent= ry_point', None, True)] if not os.path.isfile(self.filename): - raise EdkrepoGlobalConfigNotFoundException("edkrepo global co= nfig file {} does not exist".format(self.filename)) + raise=20 + EdkrepoGlobalConfigNotFoundException(humble.GLOBAL_CFG_NOT_FOUND.forma + t(self.filename)) super().__init__(self.filename, True) =20 @property @@ -189,7 +191,7 @@ def get_workspace_path(): if os.path.dirname(path) =3D=3D path: break path =3D os.path.dirname(path) - raise EdkrepoWorkspaceInvalidException("The current directory does no= t appear to be a valid workspace") + raise EdkrepoWorkspaceInvalidException(humble.INVALID_WKSPC) =20 def get_workspace_manifest_file(): path =3D get_workspace_path() diff --git a/edkrepo/config/humble/config_factory_humble.py b/edkrepo/conf= ig/humble/config_factory_humble.py new file mode 100644 index 0000000..3b8335f --- /dev/null +++ b/edkrepo/config/humble/config_factory_humble.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# +## @file +# config_humble.py +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
#=20 +SPDX-License-Identifier: BSD-2-Clause-Patent # + +GLOBAL_DATA_DIR_NOT_FOUND =3D '{} does not exist.' +READ_ONLY_CFG =3D 'The configuration file is read only: {}' +REQ_PROP_MISSING =3D '{} is not present in {} section of {}' +GLOBAL_CFG_NOT_FOUND =3D 'The edkrepo global configuration file {} was no= t found.' +INVALID_WKSPC =3D 'The current directory does not appear to be a valid wo= rkspace.' \ No newline at end of file diff --git a/setup.py b/setup.py index e7e6ce8..2d14334 100755 --- a/setup.py +++ b/setup.py @@ -12,8 +12,8 @@ setup(name=3D'edkrepo', version=3D'2.0.0', description=3D'The edkrepo tools', packages=3D['edkrepo', 'edkrepo.commands', 'edkrepo.commands.argume= nts', 'edkrepo.commands.humble', - 'edkrepo.git_automation', 'edkrepo.common', 'edkrepo.conf= ig', 'edkrepo_manifest_parser', - 'project_utils'], + 'edkrepo.git_automation', 'edkrepo.common', 'edkrepo.conf= ig', 'edkrepo.config.humble', + 'edkrepo_manifest_parser', 'project_utils'], package_data=3D{ }, include_package_data=3DTrue, -- 2.16.2.windows.1