Skip to content

Commit

Permalink
dump BBQr to stdout; Makefile release
Browse files Browse the repository at this point in the history
  • Loading branch information
scgbckbone committed Oct 6, 2024
1 parent 0427523 commit 1c89a4b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ __pycache__
foo.png
foo*.svg
.DS_Store
.idea
build
dist
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ cHNidP....
```

Dumping BBQr to console:
```
# needs a very low version or cinema screen
bbqr make UNLICENSE.md -o stdout -v 5
```

## Signing Transaction with COLDCARD Q

1) Using **COLDCARD Q** choose `Scan Any QR Code` from main menu and scan this Seed QR
Expand Down
14 changes: 13 additions & 1 deletion python/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
wheel:
python3 setup.py sdist bdist_wheel

CUR_VERSION = $(shell python -c "from bbqr.version import __version__; print(__version__)")

TARGETS = dist/bbqr-$(CUR_VERSION).tar.gz \
dist/bbqr-$(CUR_VERSION)-py3-none-any.whl

$(TARGETS) release: wheel
git add $(TARGETS)
git tag -am v$(CUR_VERSION) v$(CUR_VERSION)
twine upload $(TARGETS)

init:
pip install -r requirements.txt

test:
py.test tests -x

.PHONY: init test
.PHONY: init test wheel

22 changes: 14 additions & 8 deletions python/bbqr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#
#
import click, sys, os, pdb, io, random
from pprint import pformat
from functools import wraps
from bbqr import split_qrs, join_qrs
from bbqr.consts import FILETYPE_NAMES, KNOWN_FILETYPES

Expand Down Expand Up @@ -162,22 +160,30 @@ def make_qrs(randomize_order, infile=None, outfile=None, encoding=None, scale=4,
if not outfile or outfile == '-':
for p in parts:
print(p)
print()
return 0

rootpath, ext = os.path.splitext(outfile)
ext = ext.lower()[1:]
if outfile != "stdout":
rootpath, ext = os.path.splitext(outfile)
ext = ext.lower()[1:]

if ext not in {'png', 'svg', 'gif'}:
print(f"Unsupported output file type: {ext}")
return 1
if ext not in {'png', 'svg', 'gif'}:
print(f"Unsupported output file type: {ext}")
return 1

import pyqrcode
# Render graphics -- very slow!
import pyqrcode
print("Building QR images... ", file=sys.stderr, end='', flush=True)
qs = [pyqrcode.create(data, error='L', version=vers, mode='alphanumeric') for
data in parts]
print("done!", file=sys.stderr)

if outfile == "stdout":
for q in qs:
print(q.terminal())
print("\n\n")
return 0

if ext == 'svg':
# limitation: doesn't include progress bar animation
for i in range(num_parts):
Expand Down
6 changes: 2 additions & 4 deletions python/bbqr/split.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
# 05 2-digits of HEX: total number of QR codes
# 00 2-digits of HEX: which QR code this is in the sequence
#
import pyqrcode, zlib
from math import ceil, floor
from base64 import b32encode, b32decode
from .utils import version_to_chars, encode_data, decode_data, int2base36
from math import ceil
from .utils import version_to_chars, encode_data, int2base36
from .consts import HEADER_LEN, KNOWN_FILETYPES

def num_qr_needed(ver, ll, split_mod):
Expand Down
2 changes: 2 additions & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#

from setuptools import setup
from bbqr.version import __version__


requirements = [
'pyqrcode',
Expand Down

0 comments on commit 1c89a4b

Please sign in to comment.