Skip to content

Commit

Permalink
improved update script
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Aug 5, 2024
1 parent c4564a8 commit f9cfdec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
31 changes: 14 additions & 17 deletions python_file_hack.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
#!/bin/bash

set -e

update_file() {
local file="$1"
local search="$2"
local replace="$3"
local additional="$4"

if grep -qF "$search" "$file"; then
sed -ri "/$search/,+$additional c $replace" "$file"
else
echo "Unable to find the text $search in $file, update python_file_hack.sh"
exit 1
fi
}

# this is a hack to overwrite Django's broken TZ stuff that causes errors (500 page) to fail. See https://code.djangoproject.com/ticket/33674

FILE="/usr/local/lib/python3.11/site-packages/django/templatetags/tz.py"
SEARCH=" with timezone.override(self.tz.resolve(context)):"
REPLACE="\ try:\n with timezone.override(self.tz.resolve(context)):\n output = self.nodelist.render(context)\n return output\n except:\n return self.nodelist.render(context)"
update_file "$FILE" "$SEARCH" "$REPLACE" "2"

if grep -qF "$SEARCH" "$FILE"; then
sed -i "/$SEARCH/,+2 c $REPLACE" "$FILE"
else
echo "Unable to find the text $SEARCH in $FILE, update or remove fix_tz_hack.sh"
exit 1
fi

# Reportlab causes certain label settings to throw an error
# https://github.com/virantha/pypdfocr/issues/80
FILE="/usr/local/lib/python3.11/site-packages/reportlab/platypus/paragraph.py"
SEARCH=" if availWidth<_FUZZ:"
REPLACE="\ # removed\n"
update_file "$FILE" "$SEARCH" "$REPLACE" "2"

if grep -qF "$SEARCH" "$FILE"; then
sed -i "/$SEARCH/,+2 c $REPLACE" "$FILE"
else
echo "Unable to find the text $SEARCH in $FILE, update or remove fix_tz_hack.sh"
exit 1
fi

2 changes: 1 addition & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ fi
sed -i "s/server_name _;/server_name $SITE_DOMAIN;/" "./nginx.prod.conf"

docker compose build
docker compose up -d
docker compose restart -d

0 comments on commit f9cfdec

Please sign in to comment.