Commit e8de3700630dffd4b35be7aa9a106096e6091cd6
1 parent
8b278a92
Exists in
master
and in
10 other branches
FIX: Fixed problem with special characters
Showing
1 changed file
with
12 additions
and
7 deletions
Show diff stats
invesalius/session.py
| @@ -27,6 +27,7 @@ import shutil | @@ -27,6 +27,7 @@ import shutil | ||
| 27 | import sys | 27 | import sys |
| 28 | from threading import Thread | 28 | from threading import Thread |
| 29 | import time | 29 | import time |
| 30 | +import codecs | ||
| 30 | 31 | ||
| 31 | #import wx.lib.pubsub as ps | 32 | #import wx.lib.pubsub as ps |
| 32 | from wx.lib.pubsub import pub as Publisher | 33 | from wx.lib.pubsub import pub as Publisher |
| @@ -175,14 +176,16 @@ class Session(object): | @@ -175,14 +176,16 @@ class Session(object): | ||
| 175 | config.add_section('paths') | 176 | config.add_section('paths') |
| 176 | config.set('paths','homedir',self.homedir) | 177 | config.set('paths','homedir',self.homedir) |
| 177 | config.set('paths','tempdir',self.tempdir) | 178 | config.set('paths','tempdir',self.tempdir) |
| 178 | - try: | ||
| 179 | - config.set('paths','last_dicom_folder',self.last_dicom_folder.encode('utf-8')) | ||
| 180 | - except (UnicodeEncodeError, UnicodeDecodeError): | ||
| 181 | - config.set('paths','last_dicom_folder',self.last_dicom_folder) | 179 | + config.set('paths','last_dicom_folder',self.last_dicom_folder) |
| 180 | + | ||
| 182 | path = os.path.join(self.homedir , | 181 | path = os.path.join(self.homedir , |
| 183 | '.invesalius', 'config.cfg') | 182 | '.invesalius', 'config.cfg') |
| 184 | 183 | ||
| 185 | - configfile = open(path, 'wb') | 184 | + if sys.platform == 'win32': |
| 185 | + configfile = codecs.open(path, 'wb', 'utf-8') | ||
| 186 | + else: | ||
| 187 | + configfile = open(path, 'wb') | ||
| 188 | + | ||
| 186 | config.write(configfile) | 189 | config.write(configfile) |
| 187 | configfile.close() | 190 | configfile.close() |
| 188 | 191 | ||
| @@ -263,8 +266,10 @@ class Session(object): | @@ -263,8 +266,10 @@ class Session(object): | ||
| 263 | self.recent_projects = eval(config.get('project','recent_projects')) | 266 | self.recent_projects = eval(config.get('project','recent_projects')) |
| 264 | self.homedir = config.get('paths','homedir') | 267 | self.homedir = config.get('paths','homedir') |
| 265 | self.tempdir = config.get('paths','tempdir') | 268 | self.tempdir = config.get('paths','tempdir') |
| 266 | - self.last_dicom_folder = config.get('paths','last_dicom_folder') | ||
| 267 | - self.last_dicom_folder = self.last_dicom_folder.decode('utf-8') | 269 | + self.last_dicom_folder = config.get('paths','last_dicom_folder') |
| 270 | + | ||
| 271 | + #if not(sys.platform == 'win32'): | ||
| 272 | + # self.last_dicom_folder = self.last_dicom_folder.decode('utf-8') | ||
| 268 | 273 | ||
| 269 | self.surface_interpolation = config.get('session', 'surface_interpolation') | 274 | self.surface_interpolation = config.get('session', 'surface_interpolation') |
| 270 | self.slice_interpolation = config.get('session', 'slice_interpolation') | 275 | self.slice_interpolation = config.get('session', 'slice_interpolation') |