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>
## @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
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
# @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
\r
## import modules\r
#\r
\r
## import modules\r
#\r
-from Core import FileHook\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