-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_bash_common.bash
More file actions
executable file
·87 lines (66 loc) · 1.84 KB
/
Copy path_bash_common.bash
File metadata and controls
executable file
·87 lines (66 loc) · 1.84 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
#!/bin/bash
gcm_repo_python() {
local script_dir="$1"
if [ -x "${script_dir}/.venv/bin/python" ]; then
printf '%s\n' "${script_dir}/.venv/bin/python"
return 0
fi
if [ -x "${script_dir}/.venv/Scripts/python" ]; then
printf '%s\n' "${script_dir}/.venv/Scripts/python"
return 0
fi
if [ -x "${script_dir}/.venv/Scripts/python.exe" ]; then
printf '%s\n' "${script_dir}/.venv/Scripts/python.exe"
return 0
fi
return 1
}
gcm_require_repo_python() {
local script_dir="$1"
local python_bin
python_bin="$(gcm_repo_python "$script_dir")" || {
echo "? Virtual environment .venv not found. Run install.bat first."
return 1
}
printf '%s\n' "$python_bin"
}
gcm_source_provider_secrets() {
local script_dir="$1"
local base_dir="${script_dir}/apis"
local dir
local provider_dir
local secret_file
for dir in "$base_dir"/*/; do
[ -d "$dir" ] || continue
provider_dir="$(basename "$dir")"
case "$provider_dir" in
__pycache__|__*__)
continue
;;
esac
secret_file="${dir}secret.bash"
if [ ! -f "$secret_file" ]; then
continue
fi
source "$secret_file"
done
}
gcm_export_terminal_env() {
export MSYSTEM
export OSTYPE
}
gcm_run_repo_python() {
local script_dir="$1"
local target_script="$2"
shift 2
local python_bin
python_bin="$(gcm_require_repo_python "$script_dir")" || return 1
gcm_export_terminal_env
if [ "$OSTYPE" = "cygwin" ]; then
local win_script_dir
win_script_dir="$(cygpath -w "$script_dir")"
"$win_script_dir/.venv/Scripts/python.exe" "$win_script_dir/$target_script" "$@"
return $?
fi
"$python_bin" "${script_dir}/${target_script}" "$@"
}