-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_subtool.sh
More file actions
executable file
·85 lines (75 loc) · 2.19 KB
/
run_subtool.sh
File metadata and controls
executable file
·85 lines (75 loc) · 2.19 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
#!/bin/bash
# Script to run subtool with proper environment setup
# Change to the directory containing this script
cd "$(dirname "$0")" || exit 1
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if Python is installed
if ! command_exists python && ! command_exists python3; then
echo "Error: Python is not installed. Please install Python 3.6 or higher."
exit 1
fi
# Use either python or python3 command
PYTHON_CMD="python"
if ! command_exists python; then
PYTHON_CMD="python3"
fi
# Check if virtual environment exists, create if it doesn't
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
$PYTHON_CMD -m venv venv
if [ $? -ne 0 ]; then
echo "Error: Failed to create virtual environment. Please install venv module."
echo "Try: $PYTHON_CMD -m pip install --user virtualenv"
exit 1
fi
fi
# Activate virtual environment
if [ -f "venv/bin/activate" ]; then
echo "Activating virtual environment..."
# shellcheck disable=SC1091
source venv/bin/activate
else
echo "Error: Virtual environment activation script not found."
exit 1
fi
# Install dependencies if requirements file exists
if [ -f "requirements.txt" ]; then
echo "Checking dependencies..."
pip install -r requirements.txt
if [ $? -ne 0 ]; then
echo "Error: Failed to install dependencies."
exit 1
fi
else
# If no requirements file, install minimal required packages
echo "Installing minimal required dependencies..."
pip install PyQt6
if [ $? -ne 0 ]; then
echo "Error: Failed to install PyQt6."
exit 1
fi
fi
# Set environment variables for Qt on Linux
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Try to locate Qt plugins directory
for qt_plugin_path in \
/usr/lib/qt/plugins \
/usr/lib/qt6/plugins \
/usr/lib/x86_64-linux-gnu/qt6/plugins \
/usr/local/lib/qt6/plugins \
/usr/lib64/qt6/plugins; do
if [ -d "$qt_plugin_path" ]; then
export QT_PLUGIN_PATH="$qt_plugin_path"
echo "Set QT_PLUGIN_PATH to $qt_plugin_path"
break
fi
done
# Disable high DPI scaling
export QT_AUTO_SCREEN_SCALE_FACTOR=1
fi
# Run the application
echo "Starting Subtitle Merger Tool..."
python subtool.py "$@"