66"""
77
88from threading import Thread
9+ import io
910import operator
1011import os .path
1112
@@ -51,7 +52,7 @@ def get(cls):
5152 cls .key = ''
5253 if not cls .key :
5354 if os .path .isfile (SUBSCRIPTION_KEY_FILENAME ):
54- with file (SUBSCRIPTION_KEY_FILENAME ) as fin :
55+ with io . open (SUBSCRIPTION_KEY_FILENAME , encoding = 'utf-8' ) as fin :
5556 cls .key = fin .read ().strip ()
5657 else :
5758 cls .key = ''
@@ -62,8 +63,8 @@ def get(cls):
6263 def set (cls , key ):
6364 """Set the subscription key."""
6465 cls .key = key
65- with file (SUBSCRIPTION_KEY_FILENAME , 'w' ) as fout :
66- print >> fout , key
66+ with io . open (SUBSCRIPTION_KEY_FILENAME , 'w' , encoding = 'utf-8 ' ) as fout :
67+ fout . write ( key )
6768 CF .Key .set (cls .key )
6869
6970 @classmethod
@@ -85,7 +86,7 @@ def get(cls):
8586 cls .endpoint = ''
8687 if not cls .endpoint :
8788 if os .path .isfile (ENDPOINT_FILENAME ):
88- with file (ENDPOINT_FILENAME ) as fin :
89+ with io . open (ENDPOINT_FILENAME , encoding = 'utf-8' ) as fin :
8990 cls .endpoint = fin .read ().strip ()
9091 else :
9192 cls .endpoint = CF .BaseUrl .get ()
@@ -96,8 +97,8 @@ def get(cls):
9697 def set (cls , endpoint ):
9798 """Set the endpoint."""
9899 cls .endpoint = endpoint
99- with file (ENDPOINT_FILENAME , 'w' ) as fout :
100- print >> fout , endpoint
100+ with io . open (ENDPOINT_FILENAME , 'w' , encoding = 'utf-8 ' ) as fout :
101+ fout . write ( endpoint )
101102 CF .BaseUrl .set (cls .endpoint )
102103
103104 @classmethod
@@ -164,14 +165,14 @@ def draw_bitmap_rectangle(bitmap, faces):
164165
165166def pil_image_to_wx_image (pil_image ):
166167 """Convert from PIL image to wx image."""
167- wx_image = wx .EmptyImage (pil_image .width , pil_image .height )
168+ wx_image = wx .Image (pil_image .width , pil_image .height )
168169 wx_image .SetData (pil_image .convert ("RGB" ).tobytes ())
169170 return wx_image
170171
171172
172173def key_with_max_value (item ):
173174 """Get the key with maximum value in a dict."""
174- return max (item .iteritems (), key = operator .itemgetter (1 ))[0 ]
175+ return max (item .items (), key = operator .itemgetter (1 ))[0 ]
175176
176177
177178def async (func ):
0 commit comments