Skip to content

Commit

Permalink
Merge pull request #1627 from heinezen/fix/log_multithread
Browse files Browse the repository at this point in the history
Fix logging in multi-threaded conversion
  • Loading branch information
TheJJ committed Feb 23, 2024
2 parents 13df5e7 + 4704ec3 commit 781e731
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions openage/convert/processor/export/media_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,6 @@ def error_callback(exception: Exception):
error_callback=error_callback
)

# Log file information
if get_loglevel() <= logging.DEBUG:
MediaExporter.log_fileinfo(
sourcedir[request.get_type().value, request.source_filename],
exportdir[request.targetdir, request.target_filename]
)

# Show progress
MediaExporter._show_progress(outqueue.qsize(), expected_size)

Expand All @@ -328,6 +321,14 @@ def error_callback(exception: Exception):
if handle_outqueue_func:
handle_outqueue_func(outqueue, requests)

# Log file information
if get_loglevel() <= logging.DEBUG:
for request in requests:
MediaExporter.log_fileinfo(
sourcedir[request.get_type().value, request.source_filename],
exportdir[request.targetdir, request.target_filename]
)

@staticmethod
def _get_blend_data(
request: MediaExportRequest,
Expand Down Expand Up @@ -607,17 +608,8 @@ def log_fileinfo(
source_format = source_file.suffix[1:].upper()
target_format = target_file.suffix[1:].upper()

source_path = source_file.resolve_native_path()
if source_path:
source_size = os.path.getsize(source_path)

else:
with source_file.open('r') as src:
src.seek(0, os.SEEK_END)
source_size = src.tell()

target_path = target_file.resolve_native_path()
target_size = os.path.getsize(target_path)
source_size = source_file.filesize
target_size = target_file.filesize

log = ("Converted: "
f"{source_file.name} "
Expand Down

0 comments on commit 781e731

Please sign in to comment.