diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/gwkit.py b/gwkit.py index 7eaad3d..ee6352c 100644 --- a/gwkit.py +++ b/gwkit.py @@ -10,6 +10,7 @@ import sys import getpass import httplib +import io logger = logging.getLogger('gwkit') logger.addHandler(logging.FileHandler('gwkit.log')) @@ -166,6 +167,7 @@ def _print_color_text(self, text, index, y, x, width): text_length = 0 words = text.split(' ') for word in words: + word = word.encode('utf-8') color_index = 0 if index == self.selected_server_idx: color_index += 1 @@ -531,7 +533,7 @@ def init_server_list(): html = get_session_cookies.text actionStartIndex = html.find('action=') + 8 print actionStartIndex - actionEndIndex = html.find('" method', actionStartIndex) + actionEndIndex = html.find('" method', actionStartIndex) loginUrl = html[actionStartIndex:actionEndIndex].replace('&', '&') @@ -591,8 +593,8 @@ def init_server_list(): i += 1 print "" - final_result = str(result).replace("\'", "\"") - f = open(server_list_json_file, 'w') + final_result = str(result).decode('string-escape').decode("utf-8").replace("\'", "\"") + f = io.open(server_list_json_file, 'w', encoding='utf-8') f.write(final_result) f.close()