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.93, mailfrom: chasel.chiu@intel.com) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by groups.io with SMTP; Wed, 14 Aug 2019 03:24:11 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Aug 2019 03:24:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,384,1559545200"; d="scan'208";a="179003416" Received: from pgsmsx101.gar.corp.intel.com ([10.221.44.78]) by orsmga003.jf.intel.com with ESMTP; 14 Aug 2019 03:24:08 -0700 Received: from pgsmsx111.gar.corp.intel.com ([169.254.2.22]) by PGSMSX101.gar.corp.intel.com ([169.254.1.232]) with mapi id 14.03.0439.000; Wed, 14 Aug 2019 18:23:23 +0800 From: "Chiu, Chasel" To: "devel@edk2.groups.io" , "Chiu, Chasel" CC: "Feng, Bob C" , "Gao, Liming" , Leif Lindholm Subject: Re: [edk2-devel] [PATCH v2] BaseTools/Scripts: Add GetUtcDateTime script. Thread-Topic: [edk2-devel] [PATCH v2] BaseTools/Scripts: Add GetUtcDateTime script. Thread-Index: AQHVUooJHEocHlyotUqrjfK5TmTCzab6bw6w Date: Wed, 14 Aug 2019 10:23:22 +0000 Message-ID: <3C3EFB470A303B4AB093197B6777CCEC5045E074@PGSMSX111.gar.corp.intel.com> References: <15BAC2DDA02D1FF8.28665@groups.io> In-Reply-To: <15BAC2DDA02D1FF8.28665@groups.io> 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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjk5ZmE3MzktNzJhZS00NTI3LTllY2UtZjJiMTA2NGU3YmQyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiN3dMcUlQM0puaVdOZ1ZyUmR6Q0UxR3B0aE01a0Q4Rmk3SlhcL2pmZ1VoQ1JwenBkR0NRUWpaUGs1cUVNTk9yQVIifQ== x-ctpclassification: CTP_NT x-originating-ip: [172.30.20.206] MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable V2 re-wrote the script to use ArgumentParser and remove sys.exit(). Regards, Chasel > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Chiu, Chasel > Sent: Wednesday, August 14, 2019 6:21 PM > To: devel@edk2.groups.io > Cc: Feng, Bob C ; Gao, Liming ; > Leif Lindholm > Subject: [edk2-devel] [PATCH v2] BaseTools/Scripts: Add GetUtcDateTime > script. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2067 >=20 > A script that can return UTC date and time in ascii format which is conv= enient > for patching build time information in any binary. >=20 > Cc: Bob Feng > Cc: Liming Gao > Cc: Leif Lindholm > Signed-off-by: Chasel Chiu > --- > BaseTools/Scripts/GetUtcDateTime.py | 44 > ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) >=20 > diff --git a/BaseTools/Scripts/GetUtcDateTime.py > b/BaseTools/Scripts/GetUtcDateTime.py > new file mode 100644 > index 0000000000..3cfb6ac2ae > --- /dev/null > +++ b/BaseTools/Scripts/GetUtcDateTime.py > @@ -0,0 +1,44 @@ > +## @file > +# Get current UTC date and time information and output as ascii code. > +# > +# Copyright (c) 2019, Intel Corporation. All rights reserved.
# # > +SPDX-License-Identifier: BSD-2-Clause-Patent # > + > +VersionNumber =3D '0.1' > +import sys > +import datetime > +import argparse > + > +def Main(): > + PARSER =3D argparse.ArgumentParser( > + description=3D'Retrieves UTC date and time information (output = ordering: > year, date, time) - Version ' + VersionNumber) > + PARSER.add_argument('--year', > + action=3D'store_true', > + help=3D'Return UTC year of now. [Example output= (2019): > 39313032]') > + PARSER.add_argument('--date', > + action=3D'store_true', > + help=3D'Return UTC date MMDD of now. [Example o= utput > (7th August): 37303830]') > + PARSER.add_argument('--time', > + action=3D'store_true', > + help=3D'Return 24-hour-format UTC time HHMM of > +now. [Example output (14:25): 35323431]') > + > + ARGS =3D PARSER.parse_args() > + if len(sys.argv) =3D=3D 1: > + print ("ERROR: At least one argument is required!\n") > + PARSER.print_help() > + > + today =3D datetime.datetime.utcnow() > + if ARGS.year: > + ReversedNumber =3D str(today.year)[::-1] > + print (''.join(hex(ord(HexString))[2:] for HexString in Reverse= dNumber)) > + if ARGS.date: > + ReversedNumber =3D str(today.strftime("%m%d"))[::-1] > + print (''.join(hex(ord(HexString))[2:] for HexString in Reverse= dNumber)) > + if ARGS.time: > + ReversedNumber =3D str(today.strftime("%H%M"))[::-1] > + print (''.join(hex(ord(HexString))[2:] for HexString in > + ReversedNumber)) > + > +if __name__ =3D=3D '__main__': > + Main() > -- > 2.13.3.windows.1 >=20 >=20 >=20