检查运行环境
()
| 49 | |
| 50 | |
| 51 | def check_environment(): |
| 52 | """检查运行环境""" |
| 53 | print(f"{Colors.CYAN}🔍 Checking environment...{Colors.ENDC}") |
| 54 | |
| 55 | # 检查Python版本 |
| 56 | if sys.version_info < (3, 8): |
| 57 | print( |
| 58 | f"{Colors.FAIL}❌ Python 3.8+ required. Current: {sys.version}{Colors.ENDC}" |
| 59 | ) |
| 60 | return False |
| 61 | |
| 62 | print(f"{Colors.OKGREEN}✅ Python {sys.version.split()[0]} - OK{Colors.ENDC}") |
| 63 | |
| 64 | # 检查必要模块 |
| 65 | required_modules = [ |
| 66 | ("asyncio", "Async IO support"), |
| 67 | ("pathlib", "Path handling"), |
| 68 | ("typing", "Type hints"), |
| 69 | ] |
| 70 | |
| 71 | missing_modules = [] |
| 72 | for module, desc in required_modules: |
| 73 | try: |
| 74 | __import__(module) |
| 75 | print(f"{Colors.OKGREEN}✅ {desc} - OK{Colors.ENDC}") |
| 76 | except ImportError: |
| 77 | missing_modules.append(module) |
| 78 | print(f"{Colors.FAIL}❌ {desc} - Missing{Colors.ENDC}") |
| 79 | |
| 80 | if missing_modules: |
| 81 | print( |
| 82 | f"{Colors.FAIL}❌ Missing required modules: {', '.join(missing_modules)}{Colors.ENDC}" |
| 83 | ) |
| 84 | return False |
| 85 | |
| 86 | print(f"{Colors.OKGREEN}✅ Environment check passed{Colors.ENDC}") |
| 87 | return True |
| 88 | |
| 89 | |
| 90 | def parse_arguments(): |