mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Ignoring dot directories when importing modules. Raising error when ffprobe is not installed.
This commit is contained in:
parent
f3b61f8c18
commit
862b12019b
3 changed files with 8 additions and 12 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue