From: Gary Lin Date: Mon, 25 Jun 2018 10:31:27 +0000 (+0800) Subject: BaseTools: Remove the old python "not-equal" X-Git-Tag: edk2-stable201903~1523 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=87d2afd07c822e6d5ab12bc8dc0f0bfa31bea679 BaseTools: Remove the old python "not-equal" Replace "<>" with "!=" to be compatible with python3. Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Gary Lin Reviewed-by: Yonghong Zhu --- diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index e268c4c0a1..d748590941 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -4233,7 +4233,7 @@ class ModuleAutoGen(AutoGen): Dpx = GenDepex.DependencyExpression(self.DepexList[ModuleType], ModuleType, True) DpxFile = gAutoGenDepexFileName % {"module_name" : self.Name} - if len(Dpx.PostfixNotation) <> 0: + if len(Dpx.PostfixNotation) != 0: self.DepexGenerated = True if Dpx.Generate(path.join(self.OutputDir, DpxFile)): diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py index d4daa30937..cab4c993dc 100644 --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py @@ -362,8 +362,8 @@ class BuildRule: self.RuleContent[Index] = Line # find the build_rule_version - if Line and Line[0] == "#" and Line.find(TAB_BUILD_RULE_VERSION) <> -1: - if Line.find("=") <> -1 and Line.find("=") < (len(Line) - 1) and (Line[(Line.find("=") + 1):]).split(): + if Line and Line[0] == "#" and Line.find(TAB_BUILD_RULE_VERSION) != -1: + if Line.find("=") != -1 and Line.find("=") < (len(Line) - 1) and (Line[(Line.find("=") + 1):]).split(): self._FileVersion = (Line[(Line.find("=") + 1):]).split()[0] # skip empty or comment line if Line == "" or Line[0] == "#": diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 48b66c570e..ea73de5fa5 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -561,7 +561,7 @@ cleanlib: # convert source files and binary files to build targets self.ResultFileList = [str(T.Target) for T in self._AutoGenObject.CodaTargetList] - if len(self.ResultFileList) == 0 and len(self._AutoGenObject.SourceFileList) <> 0: + if len(self.ResultFileList) == 0 and len(self._AutoGenObject.SourceFileList) != 0: EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build", ExtraData="[%s]" % str(self._AutoGenObject)) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 5197818d3f..01171adb9b 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1293,7 +1293,7 @@ def ParseDevPathValue (Value): def ParseFieldValue (Value): if type(Value) == type(0): return Value, (Value.bit_length() + 7) / 8 - if type(Value) <> type(''): + if type(Value) != type(''): raise BadExpression('Type %s is %s' %(Value, type(Value))) Value = Value.strip() if Value.startswith(TAB_UINT8) and Value.endswith(')'): diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py index dde7d78410..ea739043e0 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -816,8 +816,8 @@ class Check(object): EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE, OtherMsg="The Library Class [%s] is not used in any platform" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0]) SqlCommand = """ select A.ID, A.Value1, A.BelongsToFile, A.StartLine, B.StartLine from Dsc as A left join Dsc as B - where A.Model = %s and B.Model = %s and A.Scope1 = B.Scope1 and A.Scope2 = B.Scope2 and A.ID <> B.ID - and A.Value1 = B.Value1 and A.Value2 <> B.Value2 and A.BelongsToItem = -1 and B.BelongsToItem = -1 and A.StartLine <> B.StartLine and B.BelongsToFile = A.BelongsToFile""" \ + where A.Model = %s and B.Model = %s and A.Scope1 = B.Scope1 and A.Scope2 = B.Scope2 and A.ID != B.ID + and A.Value1 = B.Value1 and A.Value2 != B.Value2 and A.BelongsToItem = -1 and B.BelongsToItem = -1 and A.StartLine != B.StartLine and B.BelongsToFile = A.BelongsToFile""" \ % (MODEL_EFI_LIBRARY_CLASS, MODEL_EFI_LIBRARY_CLASS) RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand) for Record in RecordSet: @@ -903,7 +903,7 @@ class Check(object): and A.Value1 = B.Value1 and A.Value2 = B.Value2 and A.Scope1 = B.Scope1 - and A.ID <> B.ID + and A.ID != B.ID and A.Model = B.Model and A.Enabled > -1 and B.Enabled > -1 @@ -1055,7 +1055,7 @@ class Check(object): SqlCommand = """ select A.ID, A.Value3, A.BelongsToFile, B.BelongsToFile from %s as A, %s as B where A.Value2 = 'FILE_GUID' and B.Value2 = 'FILE_GUID' and - A.Value3 = B.Value3 and A.ID <> B.ID group by A.ID + A.Value3 = B.Value3 and A.ID != B.ID group by A.ID """ % (Table.Table, Table.Table) RecordSet = Table.Exec(SqlCommand) for Record in RecordSet: @@ -1215,7 +1215,7 @@ class Check(object): SqlCommand = """ select A.ID, A.Value1 from %s as A, %s as B where A.Model = %s and B.Model = %s - and A.Value1 like B.Value1 and A.ID <> B.ID + and A.Value1 like B.Value1 and A.ID != B.ID and A.Scope1 = B.Scope1 and A.Enabled > -1 and B.Enabled > -1 @@ -1239,8 +1239,8 @@ class Check(object): SqlCommand = """ select A.ID, A.Value1, A.Value2 from %s as A, %s as B where A.Model = %s and B.Model = %s - and A.Value2 like B.Value2 and A.ID <> B.ID - and A.Scope1 = B.Scope1 and A.Value1 <> B.Value1 + and A.Value2 like B.Value2 and A.ID != B.ID + and A.Scope1 = B.Scope1 and A.Value1 != B.Value1 group by A.ID """ % (Table.Table, Table.Table, Model, Model) RecordSet = Table.Exec(SqlCommand) diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py index 4f79d0f829..11d11700ed 100644 --- a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py +++ b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py @@ -118,7 +118,7 @@ if __name__ == '__main__': sys.exit(1) Version = Process.communicate() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH') sys.exit(Process.returncode) print(Version[0]) @@ -208,7 +208,7 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s smime -sign -binary -signer "%s" -outform DER -md sha256 -certfile "%s"' % (OpenSslCommand, args.SignerPrivateCertFileName, args.OtherPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Signature = Process.communicate(input=FullInputFileBuffer)[0] - if Process.returncode <> 0: + if Process.returncode != 0: sys.exit(Process.returncode) # @@ -277,7 +277,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: + if Process.returncode != 0: print('ERROR: Verification failed') os.remove (args.OutputFileName) sys.exit(Process.returncode) diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py index 41bcaa0437..ca4f648647 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py @@ -80,7 +80,7 @@ if __name__ == '__main__': sys.exit(1) Version = Process.communicate() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH') sys.exit(Process.returncode) print(Version[0]) @@ -103,7 +103,7 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslCommand, Item.name), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Process.communicate() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: RSA 2048 key generation failed') sys.exit(Process.returncode) @@ -125,7 +125,7 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) PublicKeyHexString = Process.communicate()[0].split('=')[1].strip() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Unable to extract public key from private key') sys.exit(Process.returncode) PublicKey = '' @@ -138,7 +138,7 @@ if __name__ == '__main__': Process = subprocess.Popen('%s dgst -sha256 -binary' % (OpenSslCommand), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Process.stdin.write (PublicKey) PublicKeyHash = PublicKeyHash + Process.communicate()[0] - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Unable to extract SHA 256 hash of public key') sys.exit(Process.returncode) diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py index 2944b634fb..2e164c4a2d 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py @@ -101,7 +101,7 @@ if __name__ == '__main__': sys.exit(1) Version = Process.communicate() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH') sys.exit(Process.returncode) print(Version[0]) @@ -157,7 +157,7 @@ if __name__ == '__main__': while len(PublicKeyHexString) > 0: PublicKey = PublicKey + chr(int(PublicKeyHexString[0:2],16)) PublicKeyHexString=PublicKeyHexString[2:] - if Process.returncode <> 0: + if Process.returncode != 0: sys.exit(Process.returncode) if args.MonotonicCountStr: @@ -179,7 +179,7 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s dgst -sha256 -sign "%s"' % (OpenSslCommand, args.PrivateKeyFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Signature = Process.communicate(input=FullInputFileBuffer)[0] - if Process.returncode <> 0: + if Process.returncode != 0: sys.exit(Process.returncode) # @@ -202,14 +202,14 @@ if __name__ == '__main__': # # Verify that the Hash Type matches the expected SHA256 type # - if uuid.UUID(bytes_le = Header.HashType) <> EFI_HASH_ALGORITHM_SHA256_GUID: + if uuid.UUID(bytes_le = Header.HashType) != EFI_HASH_ALGORITHM_SHA256_GUID: print('ERROR: unsupport hash GUID') sys.exit(1) # # Verify the public key # - if Header.PublicKey <> PublicKey: + if Header.PublicKey != PublicKey: print('ERROR: Public key in input file does not match public key from private key file') sys.exit(1) @@ -228,7 +228,7 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s dgst -sha256 -prverify "%s" -signature %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Process.communicate(input=FullInputFileBuffer) - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Verification failed') os.remove (args.OutputFileName) sys.exit(Process.returncode) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 7f289c103f..a80c07bc1e 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -2153,7 +2153,7 @@ class DscBuildData(PlatformBuildClassObject): if DscBuildData.NeedUpdateOutput(OutputValueFile, PcdValueInitExe ,InputValueFile): Command = PcdValueInitExe + ' -i %s -o %s' % (InputValueFile, OutputValueFile) returncode, StdOut, StdErr = DscBuildData.ExecuteCommand (Command) - if returncode <> 0: + if returncode != 0: EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect output from command: %s' % Command) File = open (OutputValueFile, 'r')