From 862b12019b27c7c98b3da74cffa3fd5a5ebfd0d1 Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 29 Jun 2022 17:27:43 -0600 Subject: [PATCH] Ignoring dot directories when importing modules. Raising error when ffprobe is not installed. --- modules/videos/common.py | 4 ++++ wrolpi/common.py | 10 ++++------ wrolpi/test/test_cmd.py | 6 ------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/modules/videos/common.py b/modules/videos/common.py index f40167b6..f43c60b5 100644 --- a/modules/videos/common.py +++ b/modules/videos/common.py @@ -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: diff --git a/wrolpi/common.py b/wrolpi/common.py index a8f90c6f..b0e40cd0 100644 --- a/wrolpi/common.py +++ b/wrolpi/common.py @@ -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) diff --git a/wrolpi/test/test_cmd.py b/wrolpi/test/test_cmd.py index 5a47dd0c..88fe4b35 100644 --- a/wrolpi/test/test_cmd.py +++ b/wrolpi/test/test_cmd.py @@ -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')