From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D260821DFA7A8 for ; Fri, 31 Mar 2017 22:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491024789; x=1522560789; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=0lSvYa6pv/t7+V/n5R3sthuLOVDyCOEa9SoKHtvKUOM=; b=A0AUYiSPaT0ZRizwDToLsLmPhq74DRByvuZjQqy8VJGP94lenbXe+hYI j0+Iq2+DEE3Kf1SJg0FJlGlGzAFvFw==; Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Mar 2017 22:33:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,255,1486454400"; d="scan'208";a="1114236485" Received: from tiano01.ccr.corp.intel.com ([10.239.9.111]) by orsmga001.jf.intel.com with ESMTP; 31 Mar 2017 22:33:09 -0700 From: hesschen To: edk2-devel@lists.01.org Date: Sat, 1 Apr 2017 13:33:04 +0800 Message-Id: <1491024785-9388-2-git-send-email-hesheng.chen@intel.com> X-Mailer: git-send-email 2.7.2.windows.1 In-Reply-To: <1491024785-9388-1-git-send-email-hesheng.chen@intel.com> References: <1491024785-9388-1-git-send-email-hesheng.chen@intel.com> Subject: [patch 2/3] BaseTools/UPT: Support Unicode path X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Apr 2017 05:33:10 -0000 Update the IpiDb.py to support Unicode path for localization Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: hesschen --- 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.
+# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
# # 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