Преглед на файлове

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)
 sys.path.insert(0, pkgdir)
 os.environ['PYTHONPATH'] = pkgdir + os.pathsep + os.environ.get('PYTHONPATH', '')
 os.environ['PYTHONPATH'] = pkgdir + os.pathsep + os.environ.get('PYTHONPATH', '')
 
 
+appdata = os.environ.get('APPDATA', None)
 def excepthook(etype, value, tb):
 def excepthook(etype, value, tb):
     "Write unhandled exceptions to a file rather than exiting silently."
     "Write unhandled exceptions to a file rather than exiting silently."
     import traceback
     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)
         traceback.print_exception(etype, value, tb, file=f)
-sys.excepthook = excepthook
+
+if appdata:
+    sys.excepthook = excepthook
 
 
 from {module} import {func}
 from {module} import {func}
 {func}()
 {func}()