From nobody Tue May 7 02:33:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+43138+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43138+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1562029347; cv=none; d=zoho.com; s=zohoarc; b=TE6PtjTaC0wiz5moHNJkr3d2BSoBuLcRsKGJdAh6g89EszM+x07gdAgXeTiKUBpwzJpLBJfdlHTLFDd6bfxSRFCs43Dsp8WhhCEmhjk86qqZBO/QAyFk2yFf2gmO6Q8rbH8i9T5qBQxFcdoHZPUc3offxwSAOCkVeBV3t1NyuUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562029347; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=R8WhdkW+YL37lHDWhSL4/eNvkZATLJUzAKQUdrtLYy4=; b=XvRs9u3TQtInIZDbmMFtr1QxtLvsFmFflywCpx9wFhiLqFRAhOBq+uGDwAC5qDKzbAziL/VkuflJ1kJEV/lI9KWuxNKGuIU2h4k3pzeel3qm9dCD5WsyhIswhcOEjZM8kk4fLWl+lKq0k5q89ue1lWcrxqoSr23cwp82/EIopLo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43138+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 156202934773068.90139417760179; Mon, 1 Jul 2019 18:02:27 -0700 (PDT) Return-Path: X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by groups.io with SMTP; Mon, 01 Jul 2019 18:02:26 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jul 2019 18:02:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,441,1557212400"; d="scan'208";a="168632566" X-Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 01 Jul 2019 18:02:24 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: "Fan, Zhiju" , Liming Gao , Bob Feng , Ard Biesheuvel , Leif Lindholm , Michael D Kinney Subject: [edk2-devel] [PATCH] Platform/Intel:Change the way of getting the env file content Date: Tue, 2 Jul 2019 09:02:20 +0800 Message-Id: <20190702010220.12692-1-shenglei.zhang@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,shenglei.zhang@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1562029347; bh=Io4Qctp7HWc5a+WvNdo2jalqxbioRvnE59prjEEbfz4=; h=Cc:Date:From:Reply-To:Subject:To; b=mCn9HHKj1Wv2TdblIx4/jDtgd5T78TaW2CYZdFX+sw/qp3geyQ/Amj8WklzH69cyNSh 6hVwxGwyZSx9HjDTJo47rBE/4xYSSi4LM5HBNmOmuRbKGolxWRF2g4j7VQqgYcCLOxB7f uBnXn5yvmwsM/sWanZeJ4aO1Jki0nebM0Ow= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Fan, Zhiju" 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. This patch is going to fix the issue. Cc: Liming Gao Cc: Bob Feng Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Zhiju.Fan Reviewed-by: Liming Gao --- Platform/Intel/Tools/GenBiosId/BiosId.env | 1 - Platform/Intel/Tools/GenBiosId/GenBiosId.py | 33 ++++++++++++--------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Platform/Intel/Tools/GenBiosId/BiosId.env b/Platform/Intel/Too= ls/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/T= ools/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 not= 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_ConfigSe= ctionNotDefine) - 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_ConfigItem= Invalid % Item) - _ConfigItem[Item]['Value'] =3D cf._sections[_SectionName][Item] + _ConfigItem[Item]['Value'] =3D InputDict[Item] if len(_ConfigItem[Item]['Value']) !=3D _ConfigItem[Item]['Length'= ]: EdkLogger("GenBiosId", FORMAT_INVALID, ExtraData=3D_ConfigLenI= nvalid % Item) for Item in _ConfigItem: @@ -168,7 +172,8 @@ def PrintOutputFile(OutputFile, OutputTextFile, Id_Str): 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 --=20 2.18.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#43138): https://edk2.groups.io/g/devel/message/43138 Mute This Topic: https://groups.io/mt/32281635/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-