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

improve compatibilty with python 3.12+ #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions qct_parse/makeqctoolsreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import gzip
import shutil
import argparse
from distutils import spawn

#Context manager for changing the current working directory
class cd:
Expand All @@ -26,7 +25,7 @@ def __exit__(self, etype, value, traceback):
def dependencies():
depends = ['ffmpeg','ffprobe']
for d in depends:
if spawn.find_executable(d) is None:
if shutil.which(d) is None:
print("Buddy, you gotta install " + d)
sys.exit()
return
Expand Down Expand Up @@ -134,6 +133,7 @@ def makeReport(startObj, outPath):
os.remove(startObj + '.temp1.nut')

def main():
dependencies()
####init the stuff from the cli########
parser = argparse.ArgumentParser(description="parses QCTools XML files for frames beyond broadcast values")
parser.add_argument('-i','--input',dest='i',help="the path to the input video file")
Expand Down Expand Up @@ -164,6 +164,5 @@ def main():
startObj = startObj + ".temp1.nut"
makeReport(startObj,outPath)

dependencies()
if __name__ == '__main__':
main()
23 changes: 23 additions & 0 deletions tests/test_makeqctoolsreport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest
from qct_parse import makeqctoolsreport

def test_dependencies_found(monkeypatch):
# Simulate finding application by monkeypatching the which() command with a
# valid string
monkeypatch.setattr(
makeqctoolsreport.shutil,
'which',
lambda *path: path
)
assert makeqctoolsreport.dependencies() is None

def test_dependencies_not_found_calls_system_exit(monkeypatch):
# Simulate not finding application
monkeypatch.setattr(
makeqctoolsreport.shutil,
'which',
lambda *path: None
)

with pytest.raises(SystemExit):
makeqctoolsreport.dependencies()
5 changes: 5 additions & 0 deletions tests/test_overcatch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Note: This is currently an empy test suite and contains no actual tests.
# Until tests are written, it still serves the purpose to see if the module can
# be imported.

from qct_parse import overcatch
Loading