瀏覽代碼

Write crash log to %APPDATA% rather than installation directory

Closes gh-24 (hopefully)
Thomas Kluyver 11 年之前
父節點
當前提交
f9989ca0ab
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      nsist/__init__.py

+ 5 - 2
nsist/__init__.py

@@ -144,12 +144,15 @@ pkgdir = os.path.join(scriptdir, 'pkgs')
 sys.path.insert(0, pkgdir)
 os.environ['PYTHONPATH'] = pkgdir + os.pathsep + os.environ.get('PYTHONPATH', '')
 
+appdata = os.environ.get('APPDATA', None)
 def excepthook(etype, value, tb):
     "Write unhandled exceptions to a file rather than exiting silently."
     import traceback
-    with open(os.path.join(scriptdir, script+'.log'), 'w') as f:
+    with open(os.path.join(appdata, script+'.log'), 'w') as f:
         traceback.print_exception(etype, value, tb, file=f)
-sys.excepthook = excepthook
+
+if appdata:
+    sys.excepthook = excepthook
 
 from {module} import {func}
 {func}()