change directory for saving Beremiz bug reports from current working directory to TEMP directory.
authorSurkov Sergey <surkovsv93@gmail.com>
Fri, 27 Jan 2017 13:04:25 +0300
changeset 1645 91b7cc4b0d44
parent 1644 976ce8c6195d
child 1646 2d1fb99065e8
change directory for saving Beremiz bug reports from current working directory to TEMP directory.
Beremiz.py
--- a/Beremiz.py	Thu Jan 26 17:16:54 2017 +0300
+++ b/Beremiz.py	Fri Jan 27 13:04:25 2017 +0300
@@ -1229,6 +1229,10 @@
         ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno)
         if ex not in ignored_exceptions:
             date = time.ctime()
+            try:
+                os.mkdir(path)
+            except OSError:
+                pass
             bug_report_path = path+os.sep+"bug_report_"+date.replace(':','-').replace(' ','_')+".txt"
             result = Display_Exception_Dialog(e_type,e_value,e_traceback,bug_report_path)
             if result:
@@ -1261,6 +1265,7 @@
                 lst.sort()
                 for a in lst:
                     output.write(a+":\n"+str(info[a])+"\n\n")
+                output.close()
 
     #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
     sys.excepthook = handle_exception
@@ -1281,7 +1286,8 @@
 
 if __name__ == '__main__':
     # Install a exception handle for bug reports
-    AddExceptHook(os.getcwd(),version.app_version)
+    logpath = tempfile.gettempdir()+os.sep+'Beremiz'
+    AddExceptHook(logpath ,version.app_version)
 
     frame = Beremiz(None, projectOpen, buildpath)
     if splash: