From: hesschen <hesheng.chen@intel.com>
To: edk2-devel@lists.01.org
Subject: [patch 2/3] BaseTools/UPT: Support Unicode path
Date: Sat, 1 Apr 2017 13:33:04 +0800 [thread overview]
Message-ID: <1491024785-9388-2-git-send-email-hesheng.chen@intel.com> (raw)
In-Reply-To: <1491024785-9388-1-git-send-email-hesheng.chen@intel.com>
Update the IpiDb.py to support Unicode path for localization
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: hesschen <hesheng.chen@intel.com>
---
BaseTools/Source/Python/UPT/Core/IpiDb.py | 8 ++++----
BaseTools/Source/Python/UPT/UPT.py | 7 ++++++-
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/BaseTools/Source/Python/UPT/Core/IpiDb.py b/BaseTools/Source/Python/UPT/Core/IpiDb.py
index 2c444f9..f147963 100644
--- a/BaseTools/Source/Python/UPT/Core/IpiDb.py
+++ b/BaseTools/Source/Python/UPT/Core/IpiDb.py
@@ -1,7 +1,7 @@
## @file
# This file is for installed package information database operations
#
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@@ -44,7 +44,7 @@ class IpiDatabase(object):
Dir = os.path.dirname(DbPath)
if not os.path.isdir(Dir):
os.mkdir(Dir)
- self.Conn = sqlite3.connect(DbPath, isolation_level='DEFERRED')
+ self.Conn = sqlite3.connect(unicode(DbPath), isolation_level='DEFERRED')
self.Conn.execute("PRAGMA page_size=4096")
self.Conn.execute("PRAGMA synchronous=OFF")
self.Cur = self.Conn.cursor()
@@ -614,8 +614,8 @@ class IpiDatabase(object):
# @param DistributionFile: Distribution File
#
def GetDpByName(self, DistributionFile):
- SqlCommand = """select * from %s where NewPkgFileName like '%s'""" % \
- (self.DpTable, '%' + DistributionFile)
+ SqlCommand = """select * from %s where NewPkgFileName = '%s'""" % \
+ (self.DpTable, DistributionFile)
self.Cur.execute(SqlCommand)
for Result in self.Cur:
diff --git a/BaseTools/Source/Python/UPT/UPT.py b/BaseTools/Source/Python/UPT/UPT.py
index 873492d..d98b469 100644
--- a/BaseTools/Source/Python/UPT/UPT.py
+++ b/BaseTools/Source/Python/UPT/UPT.py
@@ -19,8 +19,13 @@ UPT
## import modules
#
-from Core import FileHook
+import locale
import sys
+encoding = locale.getdefaultlocale()[1]
+if encoding:
+ reload(sys)
+ sys.setdefaultencoding(encoding)
+from Core import FileHook
import os.path
from sys import platform
import platform as pf
--
2.7.2.windows.1
next prev parent reply other threads:[~2017-04-01 5:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-01 5:33 [patch 1/3] BaseTools/UPT: Use a simple way to get package path hesschen
2017-04-01 5:33 ` hesschen [this message]
2017-04-05 2:23 ` [patch 2/3] BaseTools/UPT: Support Unicode path Zhu, Yonghong
2017-04-01 5:33 ` [patch 3/3] BaseTools/UPT: Fix a parser issue hesschen
2017-04-05 2:23 ` Zhu, Yonghong
2017-04-05 2:23 ` [patch 1/3] BaseTools/UPT: Use a simple way to get package path Zhu, Yonghong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1491024785-9388-2-git-send-email-hesheng.chen@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox