Python3 compatibility: compiler requirements
authorBoris Zanin <boris.zanin@mobica.com>
Mon, 20 May 2019 13:00:40 +0000 (15:00 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 23 May 2019 11:42:13 +0000 (07:42 -0400)
Python 3 disallows mix of spaces and tabs in indent and also
needs exceptions in a new layout.

Components: Framework

VK-GL-CTS issue: 1665

Change-Id: I82c596293ea500f7113cb855921f4e75c35beff8

external/openglcts/scripts/mustpass.py
external/openglcts/scripts/verify/verify_es.py
external/openglcts/scripts/verify/verify_gl.py
external/openglcts/scripts/verify_kc_cts_rev.py
scripts/android/install_apk.py
scripts/src_util/check_boms.py

index a75b669..11cabf1 100644 (file)
@@ -49,7 +49,7 @@ class Project:
                self.copyright  = copyright
 
 class Configuration:
-    def __init__ (self, name, filters, glconfig = None, rotation = "unspecified", surfacetype = None, surfacewidth = None, surfaceheight = None, baseseed = None, fboconfig = None, required = False, runtime = None, os = "any"):
+       def __init__ (self, name, filters, glconfig = None, rotation = "unspecified", surfacetype = None, surfacewidth = None, surfaceheight = None, baseseed = None, fboconfig = None, required = False, runtime = None, os = "any"):
                self.name                               = name
                self.glconfig                   = glconfig
                self.rotation                   = rotation
index ee8c4cb..c14b8ab 100644 (file)
@@ -169,7 +169,7 @@ def verifyTestLogs (package):
 
        try:
                execute(['git', 'checkout', '--quiet', package.conformVersion])
-       except Exception, e:
+       except Exception as e:
                print(str(e))
                print("Failed to checkout release tag %s." % package.conformVersion)
                return messages
@@ -251,7 +251,7 @@ def verifyGitLogFile (package):
                for log, path in package.gitLog:
                        try:
                                isEmpty = isGitLogFileEmpty(package, path, log)
-                       except Exception, e:
+                       except Exception as e:
                                print(str(e))
                                isEmpty = False
 
@@ -312,7 +312,7 @@ def verifyESSubmission(argv):
                sys.exit(-1)
        try:
                execute(['git', 'ls-remote', 'origin', '--quiet'])
-       except Exception, e:
+       except Exception as e:
                print(str(e))
                print("This script must be executed inside VK-GL-CTS directory.")
                sys.exit(-1)
index 4fa21fc..ecf08ea 100644 (file)
@@ -59,11 +59,11 @@ def verifyConfigFile (filename, type):
 
        if caseResult == None:
                print("FAIL: %s not found" % caseName)
-                return False
+               return False
 
        if not isStatusCodeOk(caseResult.statusCode):
                print("FAIL: %s" % caseResult)
-                return False
+               return False
 
        return True
 
@@ -102,7 +102,7 @@ def verifyGLSubmission(argv):
                isOk = verifySubmission(argv[1])
                print("Verification %s" % ("PASSED" if isOk else "FAILED!"))
                sys.exit(0 if isOk else 1)
-       except Exception, e:
+       except Exception as e:
                print(str(e))
                print("Error occurred during verification")
                sys.exit(-1)
index 2b8dbf0..0d58e0e 100644 (file)
@@ -69,12 +69,12 @@ class GitRepo (Source):
        def compare_rev(self):
                fullDstPath = os.path.join(EXTERNAL_DIR, self.baseDir, self.extractDir)
                pushWorkingDir(fullDstPath)
-                try:
+               try:
                        out = subprocess.check_output(["git", "rev-parse", "HEAD"])
                        if out.replace('\n', '') != SHA1:
                                raise Exception ("KC CTS checkout revision %s in external/fetch_kc_cts.py doesn't match KC CTS master HEAD revision %s" % (SHA1, out))
-                finally:
-                        popWorkingDir()
+               finally:
+                       popWorkingDir()
 
 PACKAGES = [
        GitRepo(
index 583764b..6f5b14b 100644 (file)
@@ -114,7 +114,7 @@ def parallelApply (f, argsList):
                job.join()
 
        if errorCode.error:
-               raise errorCode.error[0], errorCode.error[1], errorCode.error[2]
+               raise errorCode.error[0](errorCode.error[1]).with_traceback(errorCode.error[2])
 
 def uninstall (adbPath, packageName, extraArgs = [], printPrefix=""):
        print(printPrefix + "Removing existing %s...\n" % packageName,)
index e269e86..7315b06 100644 (file)
@@ -63,16 +63,16 @@ def getFileList (path):
                                yield os.path.join(root, file)
 
 def checkBOMs (files, fix):
-    correct = True
-    for file in files:
-        if hasBOM(file):
+       correct = True
+       for file in files:
+               if hasBOM(file):
                        if fix:
                                removeBOM(file)
                                print("File %s contained BOM and was fixed" % file)
                        else:
                                correct = False
                                print("File %s contains BOM" % file)
-    return correct
+       return correct
 
 if __name__ == "__main__":
        parser = OptionParser()