| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # ========================================================================== |
| 3 | # _ _ _ ____ ____ _____ |
| 4 | # | | | (_) _ \ ___ _ __ / ___|___ _ _|_ _| __ __ _ ___ ___ _ __ |
| 5 | # | |_| | | |_) / _ \ '__| | / _ \| '_ \| || '__/ _` |/ __/ _ \ '__| |
| 6 | # | _ | | __/ __/ | | |__| (_) | | | | || | | (_| | (_| __/ | |
| 7 | # |_| |_|_|_| \___|_| \____\___/|_| |_|_||_| \__,_|\___\___|_| |
| 8 | # |
| 9 | # --- High-Performance Connectivity Tracer (HiPerConTracer) --- |
| 10 | # https://www.nntb.no/~dreibh/hipercontracer/ |
| 11 | # ========================================================================== |
| 12 | # |
| 13 | # High-Performance Connectivity Tracer (HiPerConTracer) |
| 14 | # Copyright (C) 2015-2026 by Thomas Dreibholz |
| 15 | # |
| 16 | # This program is free software: you can redistribute it and/or modify |
| 17 | # it under the terms of the GNU General Public License as published by |
| 18 | # the Free Software Foundation, either version 3 of the License, or |
| 19 | # (at your option) any later version. |
| 20 | # |
| 21 | # This program is distributed in the hope that it will be useful, |
| 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | # GNU General Public License for more details. |
| 25 | # |
| 26 | # You should have received a copy of the GNU General Public License |
| 27 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 28 | # |
| 29 | # Contact: [email protected] |
| 30 | |
| 31 | set -euo pipefail |
| 32 | |
| 33 | SCRIPTS=" |
| 34 | ping-nosql-query-example |
| 35 | ping-sql-query-example |
| 36 | " |
| 37 | |
| 38 | |
| 39 | # ###### Helper function to show failure #################################### |
| 40 | exit-failedscip-shell shell shell-project 0.0.0 exit-failed(). () |
| 41 | { |
| 42 | local columns |
| 43 | columns="$(print-utf8 -t 2>/dev/nullscip-shell filesystem . . `/dev/null`. || echoscip-shell system . . echo. "80")" |
| 44 | columns="${columns/ */}" |
| 45 | columns=$((columns - 2)) |
| 46 | |
| 47 | echoscip-shell system . . echo. |
| 48 | print-utf8 -n -s "\e[1;31;5m█" "▀" "█\e[0m" ; |
| 49 | echoscip-shell system . . echo. "CHECK FAILED!" | figlet -w "${columns}" | print-utf8 -n -C "\e[1;31;5m█\e[25m" "\e[5m█\e[0m" ; |
| 50 | print-utf8 -n -s "\e[1;31;5m█" "▄" "█\e[0m" |
| 51 | exit 1 |
| 52 | } |
| 53 | |
| 54 | |
| 55 | # ###### Helper function to show success #################################### |
| 56 | exit-successscip-shell shell shell-project 0.0.0 exit-success(). () |
| 57 | { |
| 58 | local columns |
| 59 | columns="$(print-utf8 -t 2>/dev/nullscip-shell filesystem . . `/dev/null`. || echoscip-shell system . . echo. "80")" |
| 60 | columns="${columns/ */}" |
| 61 | columns=$((columns - 2)) |
| 62 | |
| 63 | echoscip-shell system . . echo. |
| 64 | print-utf8 -n -s "\e[1;32m█" "▀" "█\e[0m" ; |
| 65 | echoscip-shell system . . echo. "ALL CHECKS SUCCEEDED!" | figlet -w "${columns}" | print-utf8 -n -C "\e[1;32m█\e[25m" "█\e[0m" ; |
| 66 | print-utf8 -n -s "\e[1;32m█" "▄" "█\e[0m" |
| 67 | exit 0 |
| 68 | } |
| 69 | |
| 70 | |
| 71 | # ###### Helper function to show script information ######################### |
| 72 | show-scriptscip-shell shell shell-project 0.0.0 show-script(). () |
| 73 | { |
| 74 | local script="$1" |
| 75 | local columns |
| 76 | columns="$(print-utf8 -t 2>/dev/nullscip-shell filesystem . . `/dev/null`. || echoscip-shell system . . echo. "80")" |
| 77 | columns="${columns/ */}" |
| 78 | columns=$((columns - 2)) |
| 79 | |
| 80 | print-utf8 -n -s "\e[1;36m█" "▀" "█\e[0m" ; |
| 81 | figlet -w "${columns}" "$(basenamescip-shell system . . basename. "${script}")" | print-utf8 -n -C "\e[1;36m█\e[25m" "█\e[0m" ; |
| 82 | print-utf8 -n -s "\e[1;36m█" "▄" "█\e[0m" |
| 83 | } |
| 84 | |
| 85 | |
| 86 | |
| 87 | # ###### Main program ####################################################### |
| 88 | |
| 89 | # ====== Find locations of Python interpreter, MyPy, and tools ============== |
| 90 | PYTHON="$(whichscip-shell system . . which. python 2>/dev/nullscip-shell filesystem . . `/dev/null`. || whichscip-shell system . . which. python3 2>/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.)" |
| 91 | if [scip-shell system . . `[`. ! -x "${PYTHON}" ] ; then |
| 92 | echoscip-shell system . . echo. >&2 "ERROR: Unable to identify Python executable!" |
| 93 | exit 1 |
| 94 | fi |
| 95 | echoscip-shell system . . echo. "Python: ${PYTHON}" |
| 96 | # shellcheck disable=SC2001 |
| 97 | MYPY="$(echoscip-shell system . . echo. "${PYTHON}" | sedscip-shell system . . sed. -e 's#/[^/]*$#/mypy#')" |
| 98 | if [scip-shell system . . `[`. ! -x "${MYPY}" ] ; then |
| 99 | echoscip-shell system . . echo. >&2 "ERROR: Unable to identify MyPy executable!" |
| 100 | echoscip-shell system . . echo. >&2 "Try this (within the correct Python environment):" |
| 101 | echoscip-shell system . . echo. >&2 "pip install mypy" |
| 102 | exit 1 |
| 103 | fi |
| 104 | echoscip-shell system . . echo. "MyPy: ${MYPY}" |
| 105 | PRINT_UTF8="$(whichscip-shell system . . which. print-utf8 2>/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.)" |
| 106 | if [scip-shell system . . `[`. ! -x "${PRINT_UTF8}" ] ; then |
| 107 | echoscip-shell system . . echo. >&2 "ERROR: Print-UTF8 (from System-Tools) is not installed!" |
| 108 | echoscip-shell system . . echo. >&2 "Try this:" |
| 109 | echoscip-shell system . . echo. >&2 "* Ubuntu: sudo apt-add-repository -sy ppa:dreibh/ppa" |
| 110 | echoscip-shell system . . echo. >&2 " sudo apt install -y td-system-tools" |
| 111 | echoscip-shell system . . echo. >&2 "* Fedora: sudo dnf copr enable -y dreibh/ppa" |
| 112 | echoscip-shell system . . echo. >&2 " sudo dnf install -y td-system-tools" |
| 113 | echoscip-shell system . . echo. >&2 "* FreeBSD: sudo pkg install -y td-system-tools" |
| 114 | exit 1 |
| 115 | fi |
| 116 | FIGLET="$(whichscip-shell system . . which. figlet 2>/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.)" |
| 117 | if [scip-shell system . . `[`. ! -x "${FIGLET}" ] ; then |
| 118 | echoscip-shell system . . echo. >&2 "ERROR: Figlet is not installed!" |
| 119 | echoscip-shell system . . echo. >&2 "* Ubuntu: sudo apt install -y figlet" |
| 120 | echoscip-shell system . . echo. >&2 "* Fedora: sudo dnf install -y figlet" |
| 121 | echoscip-shell system . . echo. >&2 "* FreeBSD: sudo pkg install -y figlet" |
| 122 | exit 1 |
| 123 | fi |
| 124 | |
| 125 | |
| 126 | # ====== Run MyPy =========================================================== |
| 127 | for script in $SCRIPTS ; do |
| 128 | echoscip-shell system . . echo. -e "\e[34mChecking ${script} ...\e[0m" |
| 129 | show-scriptscip-shell shell shell-project 0.0.0 show-script(). "${script}" |
| 130 | "${MYPY}" --strict \ |
| 131 | --install-types --non-interactive \ |
| 132 | --ignore-missing-imports \ |
| 133 | --show-traceback \ |
| 134 | --python-executable "${PYTHON}" \ |
| 135 | "${script}" || exit-failedscip-shell shell shell-project 0.0.0 exit-failed(). |
| 136 | done |
| 137 | exit-successscip-shell shell shell-project 0.0.0 exit-success(). |