forked from goarstne/mp3-matcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_environment.py
More file actions
executable file
·96 lines (78 loc) · 2.82 KB
/
test_environment.py
File metadata and controls
executable file
·96 lines (78 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python3
"""
MP3 Volume Normalizer - Environment Test Script
This script checks if the environment is properly set up to run the MP3 Volume Normalizer.
It verifies that all required dependencies are installed and working correctly.
"""
import sys
import os
import platform
import subprocess
import importlib.util
def check_python_version():
"""Check if the Python version is compatible."""
print(f"Python version: {platform.python_version()}")
if sys.version_info < (3, 6):
print("❌ Python 3.6 or higher is required")
return False
print("✅ Python version is compatible")
return True
def check_module(module_name):
"""Check if a Python module is installed."""
spec = importlib.util.find_spec(module_name)
if spec is None:
print(f"❌ {module_name} is not installed")
return False
print(f"✅ {module_name} is installed")
return True
def check_ffmpeg():
"""Check if ffmpeg is installed and accessible."""
try:
# Run ffmpeg -version and capture output
result = subprocess.run(
["ffmpeg", "-version"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=False
)
if result.returncode == 0:
# Extract version from the output
version_line = result.stdout.split('\n')[0]
print(f"✅ ffmpeg is installed: {version_line}")
return True
else:
print("❌ ffmpeg is installed but returned an error")
return False
except FileNotFoundError:
print("❌ ffmpeg is not installed or not in PATH")
return False
def main():
"""Run all environment checks."""
print("MP3 Volume Normalizer - Environment Test")
print("=======================================")
print(f"Operating System: {platform.system()} {platform.release()}")
print(f"Machine: {platform.machine()}")
print("---------------------------------------")
# Check Python version
python_ok = check_python_version()
# Check required modules
print("\nChecking required Python modules:")
modules_ok = all([
check_module("tkinter"),
check_module("pydub"),
check_module("numpy")
])
# Check ffmpeg
print("\nChecking ffmpeg installation:")
ffmpeg_ok = check_ffmpeg()
# Summary
print("\nTest Summary:")
print("---------------------------------------")
if all([python_ok, modules_ok, ffmpeg_ok]):
print("✅ All checks passed! Your environment is ready to run MP3 Volume Normalizer.")
else:
print("❌ Some checks failed. Please fix the issues before running the application.")
return 0 if all([python_ok, modules_ok, ffmpeg_ok]) else 1
if __name__ == "__main__":
sys.exit(main())