From d4d3d82be338112e12499ccea6c44e141d7e674a Mon Sep 17 00:00:00 2001 From: j Date: Tue, 23 Feb 2016 11:36:40 +0530 Subject: [PATCH] update update.sh --- Shared/large_pdf.patch | 43 ++++++++++++++++++++++++++++++++++++++++++ Shared/update.sh | 26 ++++++++++++++++--------- 2 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 Shared/large_pdf.patch diff --git a/Shared/large_pdf.patch b/Shared/large_pdf.patch new file mode 100644 index 0000000..81e0a09 --- /dev/null +++ b/Shared/large_pdf.patch @@ -0,0 +1,43 @@ +diff --git a/Shared/lib/python3.4/site-packages/PyPDF2/pdf.py b/Shared/lib/python3.4/site-packages/PyPDF2/pdf.py +index 1987ccd..5522e4b 100644 +--- a/Shared/lib/python3.4/site-packages/PyPDF2/pdf.py ++++ b/Shared/lib/python3.4/site-packages/PyPDF2/pdf.py +@@ -1925,21 +1910,26 @@ class PdfFileReader(object): + if debug: print((" x:", x, "%x"%ord(x))) + if stream.tell() < 2: + raise utils.PdfReadError("EOL marker not found") +- step = min(stream.tell()-2, 8*1024) +- stream.seek(-step, 1) +- x = stream.read(step) +- if b_('\n') in x or b_('\r') in x: +- eol = max(x.rfind(b_('\n')), x.rfind(b_('\r'))) +- while eol+1 < len(x) and x[eol+1] in (b_('\n'), b_('\r')): +- eol += 1 +- line = x[eol+1:] + line +- while x[eol:eol+1] in (b_('\n'), b_('\r')): +- eol -= 1 +- stream.seek(-step+eol, 1) ++ stream.seek(-2, 1) ++ if x == b_('\n') or x == b_('\r'): ## \n = LF; \r = CR ++ crlf = False ++ while x == b_('\n') or x == b_('\r'): ++ if debug: ++ if ord(x) == 0x0D: print(" x is CR 0D") ++ elif ord(x) == 0x0A: print(" x is LF 0A") ++ x = stream.read(1) ++ if x == b_('\n') or x == b_('\r'): # account for CR+LF ++ stream.seek(-1, 1) ++ crlf = True ++ if stream.tell() < 2: ++ raise utils.PdfReadError("EOL marker not found") ++ stream.seek(-2, 1) ++ stream.seek(2 if crlf else 1, 1) #if using CR+LF, go back 2 bytes, else 1 + break + else: ++ if debug: print(" x is neither") + line = x + line +- stream.seek(-step, 1) ++ if debug: print((" RNEL line:", line)) + if debug: print("leaving RNEL") + return line + diff --git a/Shared/update.sh b/Shared/update.sh index 42162d5..001b106 100755 --- a/Shared/update.sh +++ b/Shared/update.sh @@ -1,10 +1,18 @@ -HOME=`pwd`/home -mkdir $HOME -export PIP_DOWNLOAD_CACHE=$HOME/../../pip_cache -pip3 install -r ../../openmedialibrary/requirements-shared.txt -I --user +#!/bin/bash +set -e +cd `dirname $0` +export PIP_DOWNLOAD_CACHE=`pwd`/../../pip_cache mkdir old -mv lib bin old -mv home/.local/lib lib -mv home/.local/bin bin -rm ./lib/python3.4/site-packages/tornado/speedups.cpython-34m.so -rm -r home old +test -e lib && mv lib old/ +test -e bin && mv bin old/ + +rm -rf p34 + +virtualenv -p /usr/bin/python3.4 p34 +p34/bin/pip3 install -r ../../openmedialibrary/requirements-shared.txt + +mkdir -p lib/python3.4 +mv p34/lib/python3.4/site-packages lib/python3.4/site-packages +patch -p2 -R < large_pdf.patch + +rm -r p34 old