Ignoring dot directories when importing modules. Raising error when ffprobe is not installed.

This commit is contained in:
Roland 2022-06-29 17:27:43 -06:00
parent f3b61f8c18
commit 862b12019b
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
3 changed files with 8 additions and 12 deletions

View file

@ -244,6 +244,8 @@ def get_video_duration(video_path: Path) -> Optional[int]:
video_path = Path(video_path)
if not video_path.is_file():
raise FileNotFoundError(f'{video_path} does not exist!')
if not FFPROBE_BIN:
raise SystemError('ffprobe is not installed!')
cmd = [FFPROBE_BIN, '-v', 'error', '-show_entries', 'format=duration', '-of',
'default=noprint_wrappers=1:nokey=1', str(video_path)]
@ -265,6 +267,8 @@ def check_for_video_corruption(video_path: Path) -> bool:
video_path = Path(video_path)
if not video_path.is_file():
raise FileNotFoundError(f'{video_path} does not exist!')
if not FFPROBE_BIN:
raise SystemError('ffprobe is not installed!')
cmd = [FFPROBE_BIN, str(video_path)]
try:

View file

@ -601,11 +601,10 @@ def extract_domain(url):
def import_modules():
"""
Import all WROLPi Modules in the modules directory. Raise an ImportError if there are no modules.
"""
"""Import all WROLPi Modules in the modules directory. Raise an ImportError if there are no modules."""
try:
modules = [i.name for i in MODULES_DIR.iterdir() if i.is_dir() and not i.name.startswith('_')]
modules = [i.name for i in MODULES_DIR.iterdir() if
i.is_dir() and not (i.name.startswith('_') or i.name.startswith('.'))]
for module in modules:
module = f'modules.{module}.api'
logger.debug(f'Importing {module}')
@ -617,8 +616,7 @@ def import_modules():
def api_param_limiter(maximum: int, default: int = 20) -> callable:
"""
Create a function which restricts the maximum number that can be returned.
"""Create a function which restricts the maximum number that can be returned.
Useful for restricting API limit params.
>>> limiter = api_param_limiter(100)

View file

@ -21,9 +21,3 @@ def test_which(test_directory):
assert cmd.which('asdf', str(foo)) is None
os.chmod(foo, 0o777)
assert cmd.which('asdf', str(foo)) == foo
@skip_circleci
def test_which_chromium():
# Multiple names can be tried.
assert cmd.which('chromium-browser', 'chromium') == Path('/usr/bin/chromium')