From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: liming.gao@intel.com) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by groups.io with SMTP; Tue, 02 Jul 2019 06:27:18 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2019 06:27:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,443,1557212400"; d="scan'208";a="247277110" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 02 Jul 2019 06:27:17 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 2 Jul 2019 06:27:16 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.110]) by shsmsx102.ccr.corp.intel.com ([169.254.2.3]) with mapi id 14.03.0439.000; Tue, 2 Jul 2019 21:27:14 +0800 From: "Liming Gao" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Fan, ZhijuX" , "Feng, Bob C" , Ard Biesheuvel , "Leif Lindholm" , "Kinney, Michael D" Subject: Re: [PATCH] Platform/Intel:Change the way of getting the env file content Thread-Topic: [PATCH] Platform/Intel:Change the way of getting the env file content Thread-Index: AQHVMHHScnuZlYGmSE2tw/f0AIBSh6a3Us8Q Date: Tue, 2 Jul 2019 13:27:14 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4A12A8@SHSMSX104.ccr.corp.intel.com> References: <20190702010220.12692-1-shenglei.zhang@intel.com> In-Reply-To: <20190702010220.12692-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOWE1NTQwNWQtNzc5NS00NGZiLTkyZTEtODRhMzA2ZjlmMTY0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieUtWQW92Y0g4eFNQSmJ3d3dqUHlzZ2tNZ1FEdUZaSTk5RVlORUs4R01jT0pCRWJ1T3h4cStCaVk1ZE5MSm1keCJ9 dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Zhang, Shenglei > Sent: Tuesday, July 2, 2019 9:02 AM > To: devel@edk2.groups.io > Cc: Fan, ZhijuX ; Gao, Liming ; Feng, Bob C ; Ard Biesheuvel > ; Leif Lindholm ; Ki= nney, Michael D > Subject: [PATCH] Platform/Intel:Change the way of getting the env file co= ntent >=20 > From: "Fan, Zhiju" >=20 > The env file content can not be retrieved by using the > original method, so we change the way to read the content. > And we change the env file to original format. >=20 > This patch is going to fix the issue. >=20 > Cc: Liming Gao > Cc: Bob Feng > Cc: Ard Biesheuvel > Cc: Leif Lindholm > Cc: Michael D Kinney > Signed-off-by: Zhiju.Fan > --- > Platform/Intel/Tools/GenBiosId/BiosId.env | 1 - > Platform/Intel/Tools/GenBiosId/GenBiosId.py | 33 ++++++++++++--------- > 2 files changed, 19 insertions(+), 15 deletions(-) >=20 > diff --git a/Platform/Intel/Tools/GenBiosId/BiosId.env b/Platform/Intel/T= ools/GenBiosId/BiosId.env > index dfdeeb3107..614a66ddb8 100644 > --- a/Platform/Intel/Tools/GenBiosId/BiosId.env > +++ b/Platform/Intel/Tools/GenBiosId/BiosId.env > @@ -18,7 +18,6 @@ > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > ## > -[config] > BOARD_ID =3D KBLRVP3 > BOARD_REV =3D 1 > BOARD_EXT =3D 000 > diff --git a/Platform/Intel/Tools/GenBiosId/GenBiosId.py b/Platform/Intel= /Tools/GenBiosId/GenBiosId.py > index 7e9d115f05..31abb24d31 100644 > --- a/Platform/Intel/Tools/GenBiosId/GenBiosId.py > +++ b/Platform/Intel/Tools/GenBiosId/GenBiosId.py > @@ -16,7 +16,7 @@ import struct > import datetime > import argparse > import platform > - > +from collections import OrderedDict > try: > from configparser import ConfigParser > except: > @@ -24,8 +24,6 @@ except: >=20 > # Config message > _BIOS_Signature =3D "$IBIOSI$" > -_SectionKeyName =3D '__name__' > -_SectionName =3D 'config' >=20 > _ConfigItem =3D { > "BOARD_ID": {'Value': '', 'Length': 7}, > @@ -121,20 +119,26 @@ def CheckOptions(Options): > EdkLogger("GenBiosId", FILE_NOT_FOUND, ExtraData=3D"Input file n= ot found") > return InputFile, OutputFile, OutputTextFile >=20 > +# Read input file and get config > +def ReadInputFile(InputFile): > + InputDict =3D OrderedDict() > + with open(InputFile) as File: > + FileLines =3D File.readlines() > + for Line in FileLines: > + if Line.strip().startswith('#'): > + continue > + if '=3D' in Line: > + Key, Value =3D Line.split('=3D') > + InputDict[Key.strip()] =3D Value.strip() > + return InputDict > + >=20 > # Parse the input file and extract the information > -def ParserInputFile(InputFile): > - cf =3D ConfigParser() > - cf.optionxform =3D str > - cf.read(InputFile) > - if _SectionName not in cf._sections: > - EdkLogger("GenBiosId", FORMAT_NOT_SUPPORTED, ExtraData=3D_Config= SectionNotDefine) > - for Item in cf._sections[_SectionName]: > - if Item =3D=3D _SectionKeyName: > - continue > +def ParserInputFile(InputDict): > + for Item in InputDict: > if Item not in _ConfigItem: > EdkLogger("GenBiosId", FORMAT_INVALID, ExtraData=3D_ConfigIt= emInvalid % Item) > - _ConfigItem[Item]['Value'] =3D cf._sections[_SectionName][Item] > + _ConfigItem[Item]['Value'] =3D InputDict[Item] > if len(_ConfigItem[Item]['Value']) !=3D _ConfigItem[Item]['Lengt= h']: > EdkLogger("GenBiosId", FORMAT_INVALID, ExtraData=3D_ConfigLe= nInvalid % Item) > for Item in _ConfigItem: > @@ -168,7 +172,8 @@ def PrintOutputFile(OutputFile, OutputTextFile, Id_St= r): > def Main(): > Options =3D MyOptionParser() > InputFile, OutputFile, OutputTextFile =3D CheckOptions(Options) > - Id_Str =3D ParserInputFile(InputFile) > + InputDict =3D ReadInputFile(InputFile) > + Id_Str =3D ParserInputFile(InputDict) > PrintOutputFile(OutputFile, OutputTextFile, Id_Str) > return 0 >=20 > -- > 2.18.0.windows.1