From dda292b1addcf41fb2e766e6399811d115c07c53 Mon Sep 17 00:00:00 2001 From: Jerry <57851723+SphenHe@users.noreply.github.com> Date: Sat, 7 Dec 2024 19:07:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20feat(ignore):=20ignore=20venv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eba74f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +venv/ \ No newline at end of file From 4c326bf05bbb1e3601f37694813837e9e8ca5910 Mon Sep 17 00:00:00 2001 From: Jerry <57851723+SphenHe@users.noreply.github.com> Date: Sat, 7 Dec 2024 19:11:34 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9E=20fix(dependency=20update):=20?= =?UTF-8?q?qrencode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use qrcode instead of qrencode to support python3.11 --- paperbackup.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/paperbackup.py b/paperbackup.py index a99fe38..0d3a425 100755 --- a/paperbackup.py +++ b/paperbackup.py @@ -32,7 +32,7 @@ import sys import hashlib import subprocess -import qrencode +import qrcode from tempfile import mkstemp from datetime import datetime from PIL import Image @@ -57,10 +57,16 @@ def create_barcode(chunkdata): - version, size, im = qrencode.encode(chunkdata, - level=qrencode.QR_ECLEVEL_H, - case_sensitive=True) - return im + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_Q, + box_size=10, + border=4, + ) + qr.add_data(chunkdata) + qr.make(fit=True) + img = qr.make_image(fill_color="black", back_color="white") + return img def finish_page(pdf, canv, pageno): From 4cec4b24e58c8a49fb6e11459ef17c2761c9f104 Mon Sep 17 00:00:00 2001 From: Jerry <57851723+SphenHe@users.noreply.github.com> Date: Sat, 7 Dec 2024 19:13:19 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=90=9E=20fix(path):=20commands=20upda?= =?UTF-8?q?te?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use command instead of path/to/command to add more capability --- paperrestore.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/paperrestore.sh b/paperrestore.sh index ab0fa1d..a729afd 100755 --- a/paperrestore.sh +++ b/paperrestore.sh @@ -11,13 +11,13 @@ if [ -z "$SCANNEDFILE" ]; then exit 1 fi -if ! [ -f "$SCANNEDFILE" ]; then +if [ ! -f "$SCANNEDFILE" ]; then echo "$SCANNEDFILE is not a file" exit 1 fi -if [ ! -x "/usr/bin/zbarimg" ]; then - echo "/usr/bin/zbarimg missing" +if [ ! -x "$(command -v zbarimg)" ]; then + echo "zbarimg missing" exit 2 fi @@ -27,7 +27,7 @@ fi # so convert that to \0, so sort can sort on that # then remove all \n\0 so we get the originial without newlines added -/usr/bin/zbarimg --raw -Sdisable -Sqrcode.enable "$SCANNEDFILE" \ +zbarimg --raw -Sdisable -Sqrcode.enable "$SCANNEDFILE" \ | sed -e "s/\^/\x0/g" \ | sort -z -n \ | sed ':a;N;$!ba;s/\n\x0[0-9]* //g;s/\x0[0-9]* //g;s/\n\x0//g'