bulk_invite_mailer_clean/start_gui.command

40 lines
1.1 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -u
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
is_python3() {
"$1" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 9) else 1)' >/dev/null 2>&1
}
PYTHON_BIN=""
for candidate in "$SCRIPT_DIR/.venv/bin/python" "$SCRIPT_DIR/venv/bin/python"; do
if [[ -x "$candidate" ]] && is_python3 "$candidate"; then
PYTHON_BIN="$candidate"
break
fi
done
if [[ -z "$PYTHON_BIN" ]]; then
for command_name in python3 python; do
candidate="$(command -v "$command_name" 2>/dev/null || true)"
if [[ -n "$candidate" ]] && is_python3 "$candidate"; then
PYTHON_BIN="$candidate"
break
fi
done
fi
if [[ -z "$PYTHON_BIN" ]]; then
message="未找到 Python 3.9 或更高版本。请先安装 Python 3或在项目目录创建 .venv 虚拟环境。"
printf '%s\n' "$message" >&2
if command -v osascript >/dev/null 2>&1; then
osascript -e "display dialog \"$message\" buttons {\"好\"} default button \"好\" with icon stop"
fi
exit 1
fi
exec "$PYTHON_BIN" "$SCRIPT_DIR/bulk_invite_mailer.py" --gui "$@"