Commit 0bd55a27 authored by mathieui's avatar mathieui

Fix TBs when the system is not in utf-8 by default

(force every file opening to be with the utf-8 encoding)
parent c2828cdd
......@@ -123,7 +123,7 @@ def get_os_info():
# yes, then run it and get the first line of output.
text = get_output_of_command(path_to_file)[0]
else:
fdes = open(path_to_file)
fdes = open(path_to_file, encoding='utf-8')
text = fdes.readline().strip() # get only first line
fdes.close()
if path_to_file.endswith('version'):
......
......@@ -24,7 +24,7 @@ class Config(RawConfigParser):
def __init__(self, file_name):
self.file_name = file_name
RawConfigParser.__init__(self, None)
RawConfigParser.read(self, file_name)
RawConfigParser.read(self, file_name, encoding='utf-8')
# Check config integrity and fix it if it’s wrong
for section in ('bindings', 'var'):
if not self.has_section(section):
......@@ -115,7 +115,7 @@ class Config(RawConfigParser):
exist
"""
if path.exists(self.file_name):
df = open(self.file_name, 'r')
df = open(self.file_name, 'r', encoding='utf-8')
lines_before = (line.strip() for line in df.readlines())
df.close()
else:
......@@ -148,7 +148,7 @@ class Config(RawConfigParser):
result_lines.append('%s = %s' % (option, value))
df = open(self.file_name, 'w')
df = open(self.file_name, 'w', encoding='utf-8')
for line in result_lines:
df.write('%s\n' % line)
df.close()
......
......@@ -32,7 +32,7 @@ class OpenTrick(threading.Thread):
self.path = path
def run(self):
open(self.path, 'r').close()
open(self.path, 'r', encoding='utf-8').close()
class Fifo(object):
......@@ -49,7 +49,7 @@ class Fifo(object):
self.trick = OpenTrick(path)
# that thread will wait until we open it for writing
self.trick.start()
self.fd = open(path, mode)
self.fd = open(path, mode, encoding='utf-8')
def write(self, data):
"""
......
......@@ -207,7 +207,7 @@ class Roster(object):
if p.isfile(path):
return
try:
f = open(path, 'w+')
f = open(path, 'w+', encoding='utf-8')
f.writelines([i + "\n" for i in self.contacts])
f.close()
return True
......
......@@ -2239,7 +2239,7 @@ class RosterInfoTab(Tab):
self.core.information('The file %s does not exist' % filepath, 'Error')
return
try:
handle = open(filepath, 'r')
handle = open(filepath, 'r', encoding='utf-8')
lines = handle.readlines()
handle.close()
except IOError:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment