mirror of
https://github.com/H-uru/korman.git
synced 2025-07-14 22:36:52 +00:00
Fix potential issue with export log creation
This commit is contained in:
@ -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()
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user