diff --git a/korman/exporter/convert.py b/korman/exporter/convert.py index c534be1..fc24434 100644 --- a/korman/exporter/convert.py +++ b/korman/exporter/convert.py @@ -36,7 +36,7 @@ class Exporter: return os.path.splitext(os.path.split(self._op.filepath)[1])[0] def run(self): - with logger.ExportLogger("{}_export.log".format(self.age_name)) as _log: + with logger.ExportLogger(self._op.filepath) as _log: print("Exporting '{}.age'".format(self.age_name)) start = time.process_time() diff --git a/korman/exporter/logger.py b/korman/exporter/logger.py index 83a45a5..253ebdb 100644 --- a/korman/exporter/logger.py +++ b/korman/exporter/logger.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU General Public License # along with Korman. If not, see . +import os.path import sys class ExportAnalysis: @@ -40,9 +41,12 @@ class ExportAnalysis: class ExportLogger: """Yet Another Logger(TM)""" - def __init__(self, fn): - self._stdout = sys.stdout - self._stderr = sys.stderr + def __init__(self, ageFile): + # Make the log file name from the age file path -- this ensures we're not trying to write + # the log file to the same directory Blender.exe is in, which might be a permission error + path, ageFile = os.path.split(ageFile) + ageName, _crap = os.path.splitext(ageFile) + fn = os.path.join(path, "{}_export.log".format(ageName)) self._file = open(fn, "w") for i in dir(self._file): @@ -50,8 +54,8 @@ class ExportLogger: setattr(self, i, getattr(self._file, i)) def __enter__(self): - sys.stdout = self._file - sys.stderr = self._file + self._stdout, sys.stdout = sys.stdout, self._file + self._stderr, sys.stderr = sys.stderr, self._file def __exit__(self, type, value, traceback): sys.stdout = self._stdout