Merge branch 'master' into open-check
[kconfig-hardened-check.git] / kernel_hardening_checker / __init__.py
index 91742c3923d78973a2d865b05adee609851c4568..614084e4e3a7ac7af704e76f4b7b2c6fd01ca4a5 100644 (file)
@@ -26,9 +26,12 @@ __version__ = '0.6.6'
 
 
 def _open(file: str) -> TextIO:
-    if file.endswith('.gz'):
-        return gzip.open(file, 'rt', encoding='utf-8')
-    return open(file, 'rt', encoding='utf-8')
+    try:
+        if file.endswith('.gz'):
+            return gzip.open(file, 'rt', encoding='utf-8')
+        return open(file, 'rt', encoding='utf-8')
+    except FileNotFoundError:
+        sys.exit(f'[!] ERROR: unable to open {file}, are you sure it exists?')
 
 
 def detect_arch(fname: str, archs: List[str]) -> Tuple[StrOrNone, str]: