From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AE8BA21CAD998 for ; Sun, 5 Aug 2018 19:29:40 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Aug 2018 19:29:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,450,1526367600"; d="scan'208";a="222163101" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2018 19:29:39 -0700 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 5 Aug 2018 19:29:38 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 5 Aug 2018 19:29:38 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.100]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.57]) with mapi id 14.03.0319.002; Mon, 6 Aug 2018 10:29:36 +0800 From: "Zhu, Yonghong" To: "Sun, Yanyan" , "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [Patch] BaseTools/BinToPcd: Open output file as text file Thread-Index: AQHUK2s73n1IpD9lqEyEerBUBEBkz6SxehiAgACJUfA= Date: Mon, 6 Aug 2018 02:29:35 +0000 Message-ID: References: <20180803204733.6836-1-michael.d.kinney@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzFiNTk2YzUtZDU2My00NjJlLWEwOGItYjYzZGRiYzVlZjZkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiUDBocG00OVNNNzc2UGJITmZ6MlA4V0RNMGdNY29WMUk0MXI2dlRkUmlTWVNPRXdudTdKQkswZWtQK3FvYU9mdyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools/BinToPcd: Open output file as text file X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Aug 2018 02:29:40 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Sun, Yanyan=20 Sent: Monday, August 6, 2018 10:17 AM To: Kinney, Michael D ; edk2-devel@lists.01.org Cc: Zhu, Yonghong ; Gao, Liming ; Sun, Yanyan Subject: RE: [Patch] BaseTools/BinToPcd: Open output file as text file Mike: Tried this patch, seems that the issue is fixed. -----Original Message----- From: Kinney, Michael D Sent: Saturday, August 04, 2018 4:48 AM To: edk2-devel@lists.01.org Cc: Sun, Yanyan ; Zhu, Yonghong ; Gao, Liming ; Kinney, Michael D Subject: [Patch] BaseTools/BinToPcd: Open output file as text file https://bugzilla.tianocore.org/show_bug.cgi?id=3D1069 Undo changes from following commit: https://github.com/tianocore/edk2/commit/83964ebc5e74549d6efc7134af19150a0b= 2079aa Change the open mode for the output file from 'wb' to 'w' so the output fil= e is written as a text file and not a binary file. This resolves the issue where the text file was not writable from Python 3.= x and also removes b'' from output file when the string was encoded as a by= tearray. Cc: YanYan Sun Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney --- BaseTools/Scripts/BinToPcd.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py = index 1495a36933..316cc6117f 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -70,8 +70,7 @@ if __name__ =3D=3D '__main__': # # Return a PCD value of the form '{0x01, 0x02, ...}' along with th= e PCD length in bytes # - PcdValue =3D '{' + ', '.join (['0x{Byte:02X}'.format (Byte =3D Ite= m) for Item in Buffer]) + '}' - return PcdValue.encode (), len (Buffer) + return '{' + (', '.join (['0x{Byte:02X}'.format (Byte =3D Item)=20 + for Item in Buffer])) + '}', len (Buffer) =20 # # Create command line argument parser object @@ -81,7 +80,7 @@ if __na= me__ =3D=3D '__main__': conflict_handler =3D 'resolve') parser.add_argument ("-i", "--input", dest =3D 'InputFile', type =3D a= rgparse.FileType ('rb'), action=3D'append', required =3D True, help =3D "Input binary filename. Multiple input = files are combined into a single PCD.") - parser.add_argument ("-o", "--output", dest =3D 'OutputFile', type =3D= argparse.FileType ('wb'), + parser.add_argument ("-o", "--output", dest =3D 'OutputFile', type =3D= =20 + argparse.FileType ('w'), help =3D "Output filename for PCD value or PCD st= atement") parser.add_argument ("-p", "--pcd", dest =3D 'PcdName', type =3D Valid= atePcdName, help =3D "Name of the PCD in the form .") -- 2.14.2.windows.3