Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup prints #19

Closed
wants to merge 7 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions examples/test_extract.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
import krec
import argparse
from pathlib import Path


"""
"""Usage:
# Just extract and view
python examples/test_extract.py input.mkv -v

# Extract and save
python examples/test_extract.py input.mkv -o output.krec -v
"""

import argparse
import logging
from pathlib import Path

import krec


def main(args):
print(f"Extracting from: {args.input_file}")
logging.info(f"Extracting from: {args.input_file}")

try:
extracted_krec = krec.extract_from_video(args.input_file, verbose=args.verbose)
print("Extraction successful")
print(f"Extracted KRec has {len(extracted_krec)} frames")
logging.info("Extraction successful")
logging.info(f"Extracted KRec has {len(extracted_krec)} frames")

if args.output_file:
output_path = Path(args.output_file)
extracted_krec.save(str(output_path))
print(f"Saved to: {output_path}")
logging.info(f"Saved to: {output_path}")

except Exception as e:
print(f"Error: {e}")
return 1

return 0
logging.error(f"Error: {e}")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, i thought i disabled f-strings in logging in pylint... this is not ideal, see here: https://pylint.readthedocs.io/en/stable/user_guide/messages/warning/logging-fstring-interpolation.html


if __name__ == "__main__":
Expand All @@ -38,5 +36,7 @@ def main(args):
parser.add_argument("-o", "--output-file", type=str, help="Output KRec file path (optional)")
parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose output")

logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, you can add colorlogging as a dependency, it is a small package i wrote to make it easy to configure nice logging: https://pypi.org/project/colorlogging/

args = parser.parse_args()
exit(main(args))
main(args)
Loading