]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/build/build.py
BaseTools: Refactor python except statements
[mirror_edk2.git] / BaseTools / Source / Python / build / build.py
index c16e810fed714e11b5aad1abc80f8cdb0086d5d7..4600c46be1beca44bb3ab33b55404f24904636df 100644 (file)
@@ -548,7 +548,7 @@ class BuildTask:
                 EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join(Th.getName() for Th in threading.enumerate()))\r
                 # avoid tense loop\r
                 time.sleep(0.1)\r
                 EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join(Th.getName() for Th in threading.enumerate()))\r
                 # avoid tense loop\r
                 time.sleep(0.1)\r
-        except BaseException, X:\r
+        except BaseException as X:\r
             #\r
             # TRICK: hide the output of threads left runing, so that the user can\r
             #        catch the error message easily\r
             #\r
             # TRICK: hide the output of threads left runing, so that the user can\r
             #        catch the error message easily\r
@@ -1324,7 +1324,7 @@ class Build():
             try:\r
                 #os.rmdir(AutoGenObject.BuildDir)\r
                 RemoveDirectory(AutoGenObject.BuildDir, True)\r
             try:\r
                 #os.rmdir(AutoGenObject.BuildDir)\r
                 RemoveDirectory(AutoGenObject.BuildDir, True)\r
-            except WindowsError, X:\r
+            except WindowsError as X:\r
                 EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X))\r
         return True\r
 \r
                 EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X))\r
         return True\r
 \r
@@ -1414,7 +1414,7 @@ class Build():
             try:\r
                 #os.rmdir(AutoGenObject.BuildDir)\r
                 RemoveDirectory(AutoGenObject.BuildDir, True)\r
             try:\r
                 #os.rmdir(AutoGenObject.BuildDir)\r
                 RemoveDirectory(AutoGenObject.BuildDir, True)\r
-            except WindowsError, X:\r
+            except WindowsError as X:\r
                 EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X))\r
         return True\r
 \r
                 EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X))\r
         return True\r
 \r
@@ -2500,14 +2500,14 @@ def Main():
         # All job done, no error found and no exception raised\r
         #\r
         BuildError = False\r
         # All job done, no error found and no exception raised\r
         #\r
         BuildError = False\r
-    except FatalError, X:\r
+    except FatalError as X:\r
         if MyBuild is not None:\r
             # for multi-thread build exits safely\r
             MyBuild.Relinquish()\r
         if Option is not None and Option.debug is not None:\r
             EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())\r
         ReturnCode = X.args[0]\r
         if MyBuild is not None:\r
             # for multi-thread build exits safely\r
             MyBuild.Relinquish()\r
         if Option is not None and Option.debug is not None:\r
             EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())\r
         ReturnCode = X.args[0]\r
-    except Warning, X:\r
+    except Warning as X:\r
         # error from Fdf parser\r
         if MyBuild is not None:\r
             # for multi-thread build exits safely\r
         # error from Fdf parser\r
         if MyBuild is not None:\r
             # for multi-thread build exits safely\r