]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/RmPkg.py
BaseTools: Various typo
[mirror_edk2.git] / BaseTools / Source / Python / UPT / RmPkg.py
index ea842c11859fd7dcc606ea47bc7d023053e375f3..3d97295362e82cf18e1f639cd859937ddc026952 100644 (file)
@@ -1,11 +1,11 @@
 ## @file\r
 # Install distribution package.\r
 #\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
-# This program and the accompanying materials are licensed and made available \r
-# under the terms and conditions of the BSD License which accompanies this \r
-# distribution. The full text of the license may be found at \r
+# This program and the accompanying materials are licensed and made available\r
+# under the terms and conditions of the BSD License which accompanies this\r
+# distribution. The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
 #\r
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
@@ -23,7 +23,7 @@ import os.path
 from stat import S_IWUSR\r
 from traceback import format_exc\r
 from platform import python_version\r
-import md5\r
+from hashlib import md5\r
 from sys import stdin\r
 from sys import platform\r
 \r
@@ -58,7 +58,7 @@ def CheckDpDepex(Dep, Guid, Version, WorkspaceDir):
             return 1\r
         else:\r
             #\r
-            # report list of modules that are not valid due to force \r
+            # report list of modules that are not valid due to force\r
             # remove,\r
             # also generate a log file for reference\r
             #\r
@@ -72,12 +72,12 @@ def CheckDpDepex(Dep, Guid, Version, WorkspaceDir):
                         LogFile.write("%s\n"%ModulePath)\r
                         Logger.Info(ModulePath)\r
                 except IOError:\r
-                    Logger.Warn("\nRmPkg", ST.ERR_FILE_WRITE_FAILURE, \r
+                    Logger.Warn("\nRmPkg", ST.ERR_FILE_WRITE_FAILURE,\r
                                 File=LogFilePath)\r
             except IOError:\r
-                Logger.Warn("\nRmPkg", ST.ERR_FILE_OPEN_FAILURE, \r
+                Logger.Warn("\nRmPkg", ST.ERR_FILE_OPEN_FAILURE,\r
                             File=LogFilePath)\r
-            finally:                    \r
+            finally:\r
                 LogFile.close()\r
 \r
 ## Remove Path\r
@@ -85,7 +85,7 @@ def CheckDpDepex(Dep, Guid, Version, WorkspaceDir):
 # removing readonly file on windows will get "Access is denied"\r
 # error, so before removing, change the mode to be writeable\r
 #\r
-# @param Path: The Path to be removed \r
+# @param Path: The Path to be removed\r
 #\r
 def RemovePath(Path):\r
     Logger.Info(ST.MSG_REMOVE_FILE % Path)\r
@@ -122,43 +122,43 @@ def GetCurrentFileList(DataBase, Guid, Version, WorkspaceDir):
 # If no error found, return zero value so the caller of this tool can know\r
 # if it's executed successfully or not.\r
 #\r
-# @param  Options: command option \r
+# @param  Options: command option\r
 #\r
 def Main(Options = None):\r
 \r
     try:\r
-        DataBase = GlobalData.gDB        \r
+        DataBase = GlobalData.gDB\r
         if not Options.DistributionFile:\r
-            Logger.Error("RmPkg", \r
-                         OPTION_MISSING, \r
+            Logger.Error("RmPkg",\r
+                         OPTION_MISSING,\r
                          ExtraData=ST.ERR_SPECIFY_PACKAGE)\r
         WorkspaceDir = GlobalData.gWORKSPACE\r
         #\r
         # Prepare check dependency\r
         #\r
         Dep = DependencyRules(DataBase)\r
-        \r
+\r
         #\r
         # Get the Dp information\r
         #\r
         StoredDistFile, Guid, Version = GetInstalledDpInfo(Options.DistributionFile, Dep, DataBase, WorkspaceDir)\r
 \r
-        # \r
+        #\r
         # Check Dp depex\r
         #\r
         CheckDpDepex(Dep, Guid, Version, WorkspaceDir)\r
 \r
-        # \r
+        #\r
         # remove distribution\r
         #\r
         RemoveDist(Guid, Version, StoredDistFile, DataBase, WorkspaceDir, Options.Yes)\r
 \r
         Logger.Quiet(ST.MSG_FINISH)\r
-        \r
+\r
         ReturnCode = 0\r
-        \r
-    except FatalError, XExcept:\r
-        ReturnCode = XExcept.args[0]        \r
+\r
+    except FatalError as XExcept:\r
+        ReturnCode = XExcept.args[0]\r
         if Logger.GetLevel() <= Logger.DEBUG_9:\r
             Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + \\r
                          format_exc())\r
@@ -203,7 +203,7 @@ def GetInstalledDpInfo(DistributionFile, Dep, DataBase, WorkspaceDir):
     if not Dep.CheckDpExists(Guid, Version):\r
         Logger.Error("RmPkg", UNKNOWN_ERROR, ST.ERR_DISTRIBUTION_NOT_INSTALLED)\r
     #\r
-    # Check for Distribution files existence in /conf/upt, if not exist, \r
+    # Check for Distribution files existence in /conf/upt, if not exist,\r
     # Warn user and go on.\r
     #\r
     StoredDistFile = os.path.normpath(os.path.join(WorkspaceDir, GlobalData.gUPT_DIR, NewDpFileName))\r
@@ -242,8 +242,8 @@ def RemoveDist(Guid, Version, StoredDistFile, DataBase, WorkspaceDir, ForceRemov
                 #\r
                 # check whether modified by users\r
                 #\r
-                Md5Sigature = md5.new(open(str(Path), 'rb').read())\r
-                if Md5Sum != Md5Sigature.hexdigest():\r
+                Md5Signature = md5(open(str(Path), 'rb').read())\r
+                if Md5Sum != Md5Signature.hexdigest():\r
                     Logger.Info(ST.MSG_CONFIRM_REMOVE2 % Path)\r
                     Input = stdin.readline()\r
                     Input = Input.replace('\r', '').replace('\n', '')\r
@@ -252,7 +252,7 @@ def RemoveDist(Guid, Version, StoredDistFile, DataBase, WorkspaceDir, ForceRemov
             RemovePath(Path)\r
         else:\r
             MissingFileList.append(Path)\r
-    \r
+\r
     for Path in NewFileList:\r
         if os.path.isfile(Path):\r
             if (not ForceRemove) and (not os.path.split(Path)[1].startswith('.')):\r