Commit 2595aafa2b46dbfb39cf1c271194c5cd21f20bbf

Authored by tatiana
1 parent 9f428b6f

FIX: Write session fiel problem

Showing 2 changed files with 11 additions and 8 deletions   Show diff stats
invesalius/invesalius.py
@@ -93,8 +93,9 @@ class SplashScreen(wx.SplashScreen): @@ -93,8 +93,9 @@ class SplashScreen(wx.SplashScreen):
93 from control import Controller 93 from control import Controller
94 from project import Project 94 from project import Project
95 95
96 - 96 + print "antes primeiro import session"
97 self.main = Frame(None) 97 self.main = Frame(None)
  98 + print "depois primeiro import session"
98 self.control = Controller(self.main) 99 self.control = Controller(self.main)
99 100
100 self.fc = wx.FutureCall(1, self.ShowMain) 101 self.fc = wx.FutureCall(1, self.ShowMain)
invesalius/session.py
@@ -104,7 +104,6 @@ class Session(object): @@ -104,7 +104,6 @@ class Session(object):
104 self.temp_item = False 104 self.temp_item = False
105 105
106 def CreateSessionFile(self): 106 def CreateSessionFile(self):
107 -  
108 config = ConfigParser.RawConfigParser() 107 config = ConfigParser.RawConfigParser()
109 108
110 config.add_section('session') 109 config.add_section('session')
@@ -122,6 +121,7 @@ class Session(object): @@ -122,6 +121,7 @@ class Session(object):
122 config.set('paths','last_dicom_folder',self.last_dicom_folder) 121 config.set('paths','last_dicom_folder',self.last_dicom_folder)
123 path = os.path.join(self.homedir , 122 path = os.path.join(self.homedir ,
124 '.invesalius', 'config.cfg') 123 '.invesalius', 'config.cfg')
  124 +
125 configfile = open(path, 'wb') 125 configfile = open(path, 'wb')
126 config.write(configfile) 126 config.write(configfile)
127 configfile.close() 127 configfile.close()
@@ -202,10 +202,10 @@ class WriteSession(Thread): @@ -202,10 +202,10 @@ class WriteSession(Thread):
202 def run(self): 202 def run(self):
203 while self.runing: 203 while self.runing:
204 time.sleep(10) 204 time.sleep(10)
205 - try:  
206 - self.Write()  
207 - except AttributeError:  
208 - pass 205 + #try:
  206 + self.Write()
  207 + #except AttributeError:
  208 + # pass
209 209
210 def Stop(self): 210 def Stop(self):
211 self.runing = 0 211 self.runing = 0
@@ -231,13 +231,15 @@ class WriteSession(Thread): @@ -231,13 +231,15 @@ class WriteSession(Thread):
231 231
232 path = os.path.join(self.session.homedir , 232 path = os.path.join(self.session.homedir ,
233 '.invesalius', 'config.cfg') 233 '.invesalius', 'config.cfg')
  234 +
234 try: 235 try:
235 configfile = open(path, 'wb') 236 configfile = open(path, 'wb')
236 except IOError: 237 except IOError:
237 return 238 return
238 utl.debug("Session - IOError") 239 utl.debug("Session - IOError")
239 - else:  
240 - config.write(configfile) 240 + finally:
  241 + self.session.CreateSessionFile()
  242 +
241 configfile.close() 243 configfile.close()
242 244
243 245