Open Source Telephony
 help / color / mirror / Atom feed
From: Philippe Nunes <philippe.nunes@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH] test: According the current locale, replace non-codable character with '?'
Date: Wed, 29 Jun 2011 15:07:09 +0200	[thread overview]
Message-ID: <1309352829-14399-1-git-send-email-philippe.nunes@linux.intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 6810 bytes --]

---
 test/test-stk-menu |   45 +++++++++++++++++++++++++--------------------
 1 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/test/test-stk-menu b/test/test-stk-menu
index a9f92e8..0341385 100755
--- a/test/test-stk-menu
+++ b/test/test-stk-menu
@@ -1,5 +1,4 @@
 #!/usr/bin/python
-
 import gobject
 
 import sys
@@ -7,6 +6,8 @@ import dbus
 import dbus.service
 import dbus.mainloop.glib
 
+locale = sys.stdout.encoding
+
 class GoBack(dbus.DBusException):
 	_dbus_error_name = "org.ofono.Error.GoBack"
 
@@ -32,11 +33,12 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sya(sy)n", out_signature="y")
 	def RequestSelection(self, title, icon, items, default):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		index = 0;
 		for item in items:
-			print "%d. %s (icon: %d)" % (index, item[0], item[1])
+			print "%d. %s (icon: %d)" % (index,
+				item[0].encode(locale, 'replace'), item[1])
 			index += 1
 
 		print "\nDefault: %d" % (default)
@@ -52,7 +54,7 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="syb", out_signature="")
 	def DisplayText(self, title, icon, urgent):
-		print "DisplayText (%s)" % (title)
+		print "DisplayText (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		print "Urgent: (%d)" % (urgent)
 		key = raw_input("Press return to clear ('t' terminates, "
@@ -69,7 +71,7 @@ class StkAgent(dbus.service.Object):
 				in_signature="sysyyb", out_signature="s")
 	def RequestInput(self, title, icon, default, min_chars, max_chars,
 				hide_typing):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		print "Default: (%s)" % (default)
 		print "Hide typing: (%s)" % (hide_typing)
@@ -83,7 +85,7 @@ class StkAgent(dbus.service.Object):
 				in_signature="sysyyb", out_signature="s")
 	def RequestDigits(self, title, icon, default, min_chars, max_chars,
 				hide_typing):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		print "Default: (%s)" % (default)
 		print "Hide typing: (%s)" % (hide_typing)
@@ -101,7 +103,7 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sy", out_signature="s")
 	def RequestKey(self, title, icon):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Enter Key (t, b):")
 
@@ -115,7 +117,7 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sy", out_signature="s")
 	def RequestDigit(self, title, icon):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Enter Digit (t, b):")
 
@@ -129,7 +131,7 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sy", out_signature="b")
 	def RequestConfirmation(self, title, icon):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Enter Confirmation (t, b, y, n):")
 
@@ -145,7 +147,7 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sy", out_signature="b")
 	def ConfirmCallSetup(self, info, icon):
-		print "Information: (%s)" % (info)
+		print "Information: (%s)" % (info.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Enter Confirmation (t, y, n):")
 
@@ -159,9 +161,9 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sys", out_signature="b")
 	def ConfirmLaunchBrowser(self, info, icon, url):
-		print "Information: (%s)" % (info)
+		print "Information: (%s)" % (info.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
-		print "URL (%s)" % (url)
+		print "URL (%s)" % (url.encode(locale, 'replace'))
 		key = raw_input("Enter Confirmation (y, n):")
 
 		if key == 'y':
@@ -177,15 +179,15 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="ssy", out_signature="")
 	def PlayTone(self, tone, text, icon):
-		print "PlayTone: %s" % (tone)
-		print "Text: %s" % (text)
+		print "PlayTone: %s" % (tone.encode(locale, 'replace'))
+		print "Text: %s" % (text.encode(locale, 'replace'))
 		print "Icon: %d" % (icon)
 
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="ssy", out_signature="")
 	def LoopTone(self, tone, text, icon):
 		print "LoopTone: %s" % (tone)
-		print "Text: %s" % (text)
+		print "Text: %s" % (text.encode(locale, 'replace'))
 		print "Icon: %d" % (icon)
 		key = raw_input("Press return to end before timeout (t):")
 
@@ -195,13 +197,13 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="sy", out_signature="")
 	def DisplayActionInformation(self, text, icon):
-		print "Text: %s" % (text)
+		print "Text: %s" % (text.encode(locale, 'replace'))
 		print "Icon: %d" % (icon)
 
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="sy", out_signature="")
 	def DisplayAction(self, text, icon):
-		print "Text: (%s)" % (text)
+		print "Text: (%s)" % (text.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Press 't' to terminate the session ")
 
@@ -211,7 +213,8 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="sy", out_signature="b")
 	def ConfirmOpenChannel(self, info, icon):
-		print "Open channel confirmation: (%s)" % (info)
+		print "Open channel confirmation: (%s)" % (info.encode(locale,
+								'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Enter Confirmation (t, y, n):")
 
@@ -253,14 +256,16 @@ if __name__ == '__main__':
 	if mode == 'menu':
 		if "MainMenuTitle" in properties:
 			print "Main Menu:"
-			print "%s" % (properties["MainMenuTitle"])
+			menu = properties["MainMenuTitle"]
+			print "%s" % (menu.encode(locale, 'replace'))
 			print "\n"
 
 		if "MainMenu" in properties:
 			print "Items:"
 			index = 0
 			for item in properties["MainMenu"]:
-				print "%d. %s" % (index, item[0])
+				print "%d. %s" % (index, item[0].encode(locale,
+							'replace'))
 				index += 1
 
 		path = "/test/agent"
-- 
1.7.1


             reply	other threads:[~2011-06-29 13:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-29 13:07 Philippe Nunes [this message]
2011-06-29  5:05 ` [PATCH] test: According the current locale, replace non-codable character with '?' Denis Kenzior

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-all 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=1309352829-14399-1-git-send-email-philippe.nunes@linux.intel.com \
    --to=philippe.nunes@linux.intel.com \
    --cc=ofono@ofono.org \
    /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