Skip to content

Commit

Permalink
Ensure remote branches are known
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Nov 4, 2023
1 parent 7fe68e9 commit ad92916
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
34 changes: 23 additions & 11 deletions addon_meterstoha/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,26 @@ GIT_VERSION_STR=
if bashio::config.has_value "git_version" ; then
GIT_VERSION="$(bashio::config git_version)"
# shellcheck disable=SC2089
GIT_VERSION_STR="\"${GIT_VERSION/\"/\\\"}\""
GIT_VERSION_STR="${GIT_VERSION/\"/\\\"}"
fi

git clone --depth=1 "https://github.com/mdeweerd/MetersToHA.git" --no-checkout MetersToHA
(
cd MetersToHA || exit 255
git sparse-checkout set apps

if [ "$GIT_VERSION_STR" != "" ] ; then
# Make sure we have copy of branches
git remote set-branches origin '*'
git fetch -v --depth=1
fi

# GIT_VERSION_STR is allowed to be empty
echo "git checkout $GIT_VERSION_STR"
# shellcheck disable=SC2086,SC2090
git checkout $GIT_VERSION_STR

echo "MetersToHA Container version: $(bashio::addon.version).008 @$(stat -c '%y' "${MYDIR}run.sh")"
echo "MetersToHA Container version: $(bashio::addon.version).011 @$(stat -c '%y' "${MYDIR}run.sh")"
git show -s --pretty=format:"MetersToHA Python GIT version: %h on %ad%n"
)

Expand Down Expand Up @@ -179,18 +185,24 @@ echo "EVENT CONF:$event_conf"
# ls -lRrt /MetersToHA

EXEC_EVENT_SH="${MYDIR}execEvent.sh"

cat > "$EXEC_EVENT_SH" <<SCRIPT
#!/bin/bash
#!/usr/bin/with-contenv bashio
{
TARGET_OPT=""
$event_matching
[[ "\$TARGET_OPT" == "" ]] && ( echo "Unrecognized event '\$1'" ; exit 1 )
date
echo "python3 $TRACE_OPT MetersToHA/apps/meters_to_ha/meters_to_ha.py $RUN_OPT -c \"$CONFIG_FILE\" \$TARGET_OPT -r"
python3 $TRACE_OPT MetersToHA/apps/meters_to_ha/meters_to_ha.py $RUN_OPT -c "$CONFIG_FILE" \$TARGET_OPT -r
echo "Done \$(date)"
} >> "$LOGS_FOLDER/m2h_exec.log" 2>&1
TARGET_OPT=""
$event_matching
[[ "\$TARGET_OPT" == "" ]] && ( echo "Unrecognized event '\$1'" ; exit 1 )
date
echo "python3 $TRACE_OPT MetersToHA/apps/meters_to_ha/meters_to_ha.py $RUN_OPT -c \"$CONFIG_FILE\" \$TARGET_OPT -r"
python3 $TRACE_OPT MetersToHA/apps/meters_to_ha/meters_to_ha.py $RUN_OPT -c "$CONFIG_FILE" \$TARGET_OPT -r
# Copy chrome logs
for i in ~/.config/*/chrome_debug.log ; do
SUBDIR="${LOGS_FOLDER}/\$(basename "\$(dirname \$i)")"
mkdir -^\${SUBDIR}"
cp -p "\$i" "\${SUBDIR}"
eone
echo "Done \$(date)"
} >> "${LOGS_FOLDER}/m2h_exec.log" 2>&1
SCRIPT
chmod +x "$EXEC_EVENT_SH"

Expand Down
5 changes: 3 additions & 2 deletions apps/meters_to_ha/meters_to_ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ def init_chromium(self):
options.add_experimental_option(
"excludeSwitches", ["enable-automation"]
)
if log_level >= logging.WARNING:
options.add_experimental_option(
"excludeSwitches", ["enable-logging"]
)
Expand All @@ -693,10 +694,10 @@ def init_chromium(self):
self.mylog("Start virtual display (Chromium).", end="")

if log_level < logging.INFO:
options.add_argument("--log-level=1")
options.add_argument("--enable-logging")
options.add_argument("--log-level=1")
options.add_argument("--v=1")
if log_level < logging.WARNING:
elif log_level < logging.WARNING:
options.add_argument("--enable-logging")
options.add_argument("--log-level=0")
options.add_argument("--v=0")
Expand Down

0 comments on commit ad92916

Please sign in to comment.