]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/UPT: Support Unicode path
authorHess Chen <hesheng.chen@intel.com>
Sat, 1 Apr 2017 05:33:04 +0000 (13:33 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 5 Apr 2017 02:45:50 +0000 (10:45 +0800)
Update the IpiDb.py to support Unicode path for localization

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/UPT/Core/IpiDb.py
BaseTools/Source/Python/UPT/UPT.py

index 2c444f903c0f569e3cceeb575d77594dbf37187a..f147963288adcdfc1746cd1d955eb8d5d29ef04d 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is for installed package information database operations\r
 #\r
 ## @file\r
 # This file is for installed package information database operations\r
 #\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2017, 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
 #\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
@@ -44,7 +44,7 @@ class IpiDatabase(object):
         Dir = os.path.dirname(DbPath)\r
         if not os.path.isdir(Dir):\r
             os.mkdir(Dir)\r
         Dir = os.path.dirname(DbPath)\r
         if not os.path.isdir(Dir):\r
             os.mkdir(Dir)\r
-        self.Conn = sqlite3.connect(DbPath, isolation_level='DEFERRED')\r
+        self.Conn = sqlite3.connect(unicode(DbPath), isolation_level='DEFERRED')\r
         self.Conn.execute("PRAGMA page_size=4096")\r
         self.Conn.execute("PRAGMA synchronous=OFF")\r
         self.Cur = self.Conn.cursor()\r
         self.Conn.execute("PRAGMA page_size=4096")\r
         self.Conn.execute("PRAGMA synchronous=OFF")\r
         self.Cur = self.Conn.cursor()\r
@@ -614,8 +614,8 @@ class IpiDatabase(object):
     # @param DistributionFile: Distribution File  \r
     #\r
     def GetDpByName(self, DistributionFile):\r
     # @param DistributionFile: Distribution File  \r
     #\r
     def GetDpByName(self, DistributionFile):\r
-        SqlCommand = """select * from %s where NewPkgFileName like '%s'""" % \\r
-        (self.DpTable, '%' + DistributionFile)\r
+        SqlCommand = """select * from %s where NewPkgFileName = '%s'""" % \\r
+        (self.DpTable, DistributionFile)\r
         self.Cur.execute(SqlCommand)\r
 \r
         for Result in self.Cur:\r
         self.Cur.execute(SqlCommand)\r
 \r
         for Result in self.Cur:\r
index 873492d4f0da723ee8e7597d3a2c92b63c9eda98..d98b469640d85fcfc67c699d92dd1ce080b45be2 100644 (file)
@@ -19,8 +19,13 @@ UPT
 \r
 ## import modules\r
 #\r
 \r
 ## import modules\r
 #\r
-from Core import FileHook\r
+import locale\r
 import sys\r
 import sys\r
+encoding = locale.getdefaultlocale()[1]\r
+if encoding:\r
+    reload(sys)\r
+    sys.setdefaultencoding(encoding)\r
+from Core import FileHook\r
 import os.path\r
 from sys import platform\r
 import platform as pf\r
 import os.path\r
 from sys import platform\r
 import platform as pf\r