Skip to content

Commit

Permalink
Replace unmaintained pyqrcode dependency with qrcode (#1573)
Browse files Browse the repository at this point in the history
replace pyqrcode with qrcode (see #1572)
  • Loading branch information
mgorny committed May 20, 2022
1 parent 05da974 commit 0090f30
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
16 changes: 7 additions & 9 deletions autobahn/wamp/auth.py
Expand Up @@ -476,17 +476,15 @@ def qrcode_from_totp(secret, label, issuer):
raise Exception('label must be of type unicode, not {}'.format(type(label)))

try:
import pyqrcode
import qrcode
import qrcode.image.svg
except ImportError:
raise Exception('pyqrcode not installed')
raise Exception('qrcode not installed')

import io
buffer = io.BytesIO()

data = pyqrcode.create('otpauth://totp/{}?secret={}&issuer={}'.format(label, secret, issuer))
data.svg(buffer, omithw=True)

return buffer.getvalue()
return qrcode.make(
'otpauth://totp/{}?secret={}&issuer={}'.format(label, secret, issuer),
box_size=3,
image_factory=qrcode.image.svg.SvgImage).to_string()


@public
Expand Down
20 changes: 11 additions & 9 deletions autobahn/wamp/cryptosign.py
Expand Up @@ -295,24 +295,26 @@ def _qrcode_from_signify_ed25519_pubkey(pubkey_file, mode='text'):
"""
assert(mode in ['text', 'svg'])

import pyqrcode
import qrcode

with open(pubkey_file) as f:
pubkey = f.read().splitlines()[1]

qr = pyqrcode.create(pubkey, error='L', mode='binary')
qr = qrcode.QRCode(box_size=3,
error_correction=qrcode.ERROR_CORRECT_L)
qr.add_data(pubkey)

if mode == 'text':
return qr.terminal()

elif mode == 'svg':
import io
data_buffer = io.BytesIO()

qr.svg(data_buffer, omithw=True)

return data_buffer.getvalue()
with io.StringIO() as data_buffer:
qr.print_ascii(out=data_buffer, invert=True)
return data_buffer.getvalue()
elif mode == 'svg':
import qrcode.image.svg

image = qr.make_image(image_factory=qrcode.image.svg.SvgImage)
return image.to_string()
else:
raise Exception('logic error')

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -92,7 +92,7 @@
'service_identity>=18.1.0', # MIT license
'pynacl>=1.4.0', # Apache license
'pytrie>=0.4.0', # BSD license
'pyqrcode>=1.2.1' # BSD license
'qrcode>=7.3.1', # BSD license
]

# Support for WAMP-SCRAM authentication
Expand Down

0 comments on commit 0090f30

Please sign in to comment.