Skip to content

Commit

Permalink
Added environment validation and error handling
Browse files Browse the repository at this point in the history
Implemented checks to ensure the script runs on Linux systems and Python 3.
  • Loading branch information
elkaboussi committed Mar 27, 2024
1 parent 9f2d111 commit fa94863
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# pylint: disable=missing-docstring
import platform
import sys

from rich import print as pr

from analyzer.file_processing import process_directory
from analyzer.utils.logger import setup_logging
from analyzer.utils.parser import parse_args
Expand Down Expand Up @@ -37,5 +40,22 @@ def main():
sys.stderr = sys.__stderr__


def is_valid_environment() -> bool:
if platform.system() != "Linux":
pr("[bold red]Error:[/] This tool is designed to run on Linux systems only.")
pr("[bold red]Please run this script on a Linux system to proceed.[/]")
return False

if sys.version_info.major == 2:
pr("[bold red]Error:[/] This tool is designed to run on Python 2.")
pr("[bold red]Please use Python 2 to run this script.[/]")
return False

return True


if __name__ == "__main__":
if not is_valid_environment():
sys.exit(1)

main()

0 comments on commit fa94863

Please sign in to comment.