Skip to content

Commit

Permalink
Comprehensive Summary
Browse files Browse the repository at this point in the history
The summary was in yaml which is difficult to read. Just print text.
  • Loading branch information
desjare committed Dec 28, 2020
1 parent 67fa0c7 commit 132be3c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="tabarnak-desjare", # Replace with your own username
version="0.0.6",
version="0.0.7",
author="Eric Desjardins",
author_email="[email protected]",
description="transcoder FFmpeg based wrapper",
Expand Down
33 changes: 32 additions & 1 deletion tabarnak/tabarnak.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ def as_dict(self):
exception=self.exceptions,
fails_on_tolerance=self.fails_on_tolerance)

def get_path(self) -> str:
"""
returns the transcoding input path
"""
return self.path

def set_file_stats(self,transcoder_file_stats: TranscoderFileStats):
"""
set stats for file transcoding
Expand Down Expand Up @@ -269,6 +275,12 @@ def __exit__(self, exc_type, exc_value, _):
# do not propagate exception
return True

def get_elapsed_time(self) -> str:
"""
returns elapsed time as a string
"""
return str(datetime.datetime.now() - self.start_time)

def set_file_result(self, file_result: TrancodeFileResult):
"""
set current file result
Expand Down Expand Up @@ -374,7 +386,26 @@ def print_summary(self, transcoder_args=None):
stdout = sys.stdout
if transcoder_args:
stdout = transcoder_args.stdout
summary = yaml.safe_dump(self)

num_success = 0
num_fails = 0
elapsed = self.get_elapsed_time()

error_input_paths = []
success_input_paths = []

for result in self.file_results:
if result.status() is True:
num_success += 1
success_input_paths.append(result.get_path())
else:
num_fails += 1
error_input_paths.append(result.get_path())

file_summary = "\n\nSuccesses:\n\n{0}\n\nFailures:\n\n{1}".format("\n".join(success_input_paths), "\n".join(error_input_paths))

summary = "\nSummary\n\nSuccesses:{0} Failures:{1}\nElapsed Time {2}\n{3}\n\nCheck logs for details.\n".format(num_success, num_fails, elapsed, file_summary)

print(summary, file=stdout)

yaml.add_representer(TranscoderResults, TranscoderResults.to_yaml, Dumper=yaml.SafeDumper)
Expand Down

0 comments on commit 132be3c

Please sign in to comment.