From 72443dd25014a8b6209895640af36dec33da51e0 Mon Sep 17 00:00:00 2001 From: Gary Lin Date: Mon, 25 Jun 2018 18:31:26 +0800 Subject: BaseTools: Refactor python print statements Refactor print statements to be compatible with python 3. Based on "futurize -f libfuturize.fixes.fix_print_with_import" Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Gary Lin Reviewed-by: Yonghong Zhu --- BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'BaseTools/Source/Python/Pkcs7Sign') diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py index de85756..4f79d0f 100644 --- a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py +++ b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py @@ -19,6 +19,7 @@ ''' Pkcs7Sign ''' +from __future__ import print_function import os import sys @@ -113,14 +114,14 @@ if __name__ == '__main__': try: Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) except: - print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH' + print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH') sys.exit(1) Version = Process.communicate() if Process.returncode <> 0: - print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH' + print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH') sys.exit(Process.returncode) - print Version[0] + print(Version[0]) # # Read input file into a buffer and save input filename @@ -134,7 +135,7 @@ if __name__ == '__main__': # OutputDir = os.path.dirname(args.OutputFile) if not os.path.exists(OutputDir): - print 'ERROR: The output path does not exist: %s' % OutputDir + print('ERROR: The output path does not exist: %s' % OutputDir) sys.exit(1) args.OutputFileName = args.OutputFile @@ -170,7 +171,7 @@ if __name__ == '__main__': args.SignerPrivateCertFile = open(args.SignerPrivateCertFileName, 'rb') args.SignerPrivateCertFile.close() except: - print 'ERROR: test signer private cert file %s missing' % (args.SignerPrivateCertFileName) + print('ERROR: test signer private cert file %s missing' % (args.SignerPrivateCertFileName)) sys.exit(1) # @@ -196,7 +197,7 @@ if __name__ == '__main__': args.OtherPublicCertFile = open(args.OtherPublicCertFileName, 'rb') args.OtherPublicCertFile.close() except: - print 'ERROR: test other public cert file %s missing' % (args.OtherPublicCertFileName) + print('ERROR: test other public cert file %s missing' % (args.OtherPublicCertFileName)) sys.exit(1) format = "%dsQ" % len(args.InputFileBuffer) @@ -242,11 +243,11 @@ if __name__ == '__main__': args.TrustedPublicCertFile = open(args.TrustedPublicCertFileName, 'rb') args.TrustedPublicCertFile.close() except: - print 'ERROR: test trusted public cert file %s missing' % (args.TrustedPublicCertFileName) + print('ERROR: test trusted public cert file %s missing' % (args.TrustedPublicCertFileName)) sys.exit(1) if not args.SignatureSizeStr: - print "ERROR: please use the option --signature-size to specify the size of the signature data!" + print("ERROR: please use the option --signature-size to specify the size of the signature data!") sys.exit(1) else: if args.SignatureSizeStr.upper().startswith('0X'): @@ -254,10 +255,10 @@ if __name__ == '__main__': else: SignatureSize = (long)(args.SignatureSizeStr) if SignatureSize < 0: - print "ERROR: The value of option --signature-size can't be set to negative value!" + print("ERROR: The value of option --signature-size can't be set to negative value!") sys.exit(1) elif SignatureSize > len(args.InputFileBuffer): - print "ERROR: The value of option --signature-size is exceed the size of the input file !" + print("ERROR: The value of option --signature-size is exceed the size of the input file !") sys.exit(1) args.SignatureBuffer = args.InputFileBuffer[0:SignatureSize] @@ -277,7 +278,7 @@ if __name__ == '__main__': Process = subprocess.Popen('%s smime -verify -inform DER -content %s -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Process.communicate(input=args.SignatureBuffer)[0] if Process.returncode <> 0: - print 'ERROR: Verification failed' + print('ERROR: Verification failed') os.remove (args.OutputFileName) sys.exit(Process.returncode) -- cgit v1.1