-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
=
committed
Aug 5, 2024
1 parent
c4564a8
commit f9cfdec
Showing
2 changed files
with
15 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters