Skip to content

Commit

Permalink
checkout display too
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jan 11, 2019
1 parent cd013d3 commit 01c5ce2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions pylivestream/utils.py
Expand Up @@ -6,6 +6,7 @@
from typing import Tuple, Union, List

DEVNULL = subprocess.DEVNULL
R = Path(__file__).resolve().parents[1] / 'tests/'


def run(cmd: List[str]):
Expand Down Expand Up @@ -40,6 +41,21 @@ def check_device(cmd: List[str]) -> bool:
return ok


def check_display(fn: Path = None) -> bool:
"""see if it's possible to display something with a test file"""
if isinstance(fn, Path) and not fn.is_file():
raise FileNotFoundError(str(fn))

if fn is None:
fn = R / 'bunny.avi'

cmd = ['ffplay', '-v', 'error', '-t', '1.0', '-autoexit', str(fn)]

ret = subprocess.run(cmd, timeout=10).returncode

return ret == 0


def getexe(exein: Path = None) -> Tuple[str, str]:
"""checks that host streaming program is installed"""

Expand Down
4 changes: 2 additions & 2 deletions tests/test_filein.py
Expand Up @@ -60,11 +60,11 @@ def test_file_simple():
image=LOGO,
yes=True)

ok = S.check_device()
ok = pls.utils.check_display()

if not ok:
skip = True
pytest.skip(f'device not available: {S.streams.popitem()[1].checkcmd}')
pytest.skip(f'device display not available')

try:
S.golive()
Expand Down

0 comments on commit 01c5ce2

Please sign in to comment.