本文整理汇总了Python中pyqrcode.create方法的典型用法代码示例。如果您正苦于以下问题:Python pyqrcode.create方法的具体用法?Python pyqrcode.create怎么用?Python pyqrcode.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqrcode
的用法示例。
在下文中一共展示了pyqrcode.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: qrcode
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def qrcode():
"""Two factor auth qrcode page route."""
user_name = User.query.filter_by(username=current_user.username).first()
if user_name is None:
render_error_page_template(404)
# for added security, remove username from session
# render qrcode for FreeTOTP
url = pyqrcode.create(user_name.get_totp_uri())
stream = BytesIO()
url.svg(stream, scale=3)
flash(user_name.otp_secret)
return stream.getvalue(), 200, {
'Content-Type': 'image/svg+xml',
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0'}
示例2: edit_selected_schedule
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def edit_selected_schedule(self):
schedule = None
editing = -1
if self.getFocusId() == self.schedule_list.getId():
editing = self.schedule_list.getSelectedPosition()
schedule = self.schedules[editing]
schedule_dialog = ExportScheduleDialog.create(schedule)
schedule_dialog.doModal()
if not schedule_dialog.iscanceled():
valid = True
if editing >= 0:
schedule = schedule_dialog.schedule
self.schedules[editing] = schedule
self.schedule_list.getListItem(editing).setLabel(self.get_schedule_statement(schedule))
else:
for schedule in self.schedules:
if schedule['type'] == schedule_dialog.schedule['type'] and schedule['at'] == schedule_dialog.schedule['at']:
valid = False
break
if valid:
self.schedules.append(schedule_dialog.schedule)
self.add_schedule_item(schedule_dialog.schedule)
示例3: create
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def create(dom_element):
"""
Create a QRCodeConfiguration object from a QDomElement instance.
:param dom_element: QDomDocument that represents composer configuration.
:type dom_element: QDomElement
:return: QRCodeConfiguration instance whose properties have been
extracted from the composer document instance.
:rtype: PhotoConfiguration
"""
item_id = dom_element.attribute("itemid")
ds_field = dom_element.attribute('dataSourceField')
return QRCodeConfiguration(
item_id=item_id,
data_source_field = ds_field
)
示例4: generate_qr_code
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def generate_qr_code(qr_content):
"""
Generates a QR code SVG item and saves it as a temporary file.
:param qr_content: Content used to generate a QR code.
:type qr_content: str
:return: Returns a QTemporaryFile object containing the SVG file with the
QR code.
:rtype: QTemporaryFile
"""
tmpf = QTemporaryFile()
if tmpf.open():
file_path = tmpf.fileName()
qr_code = pyqrcode.create(qr_content)
qr_code.svg(file_path, scale=6)
tmpf.close()
return tmpf
示例5: qrcode
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def qrcode():
if 'username' not in session:
abort(404)
user = User.query.filter_by(username=session['username']).first()
if user is None:
abort(404)
# for added security, remove username from session
del session['username']
# render qrcode for FreeTOTP
url = pyqrcode.create(user.get_totp_uri())
stream = BytesIO()
url.svg(stream, scale=3)
return stream.getvalue(), 200, {
'Content-Type': 'image/svg+xml',
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0'}
示例6: respond
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def respond(err, res=None):
return {
'statusCode': '400' if err else '200',
'body': err.message if err else json.dumps(res),
'headers': {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
},
}
# input parameters are:
# 1. image ID
# output parameters are:
# 1. generated QRCode
# workflow:
# 1. first get the image_id
# 2. confirm this exists in s3
# 3. generate a presigned URL with this s3 path
# 4. create a QR Code image with this url embedded
# 5. return the QR code stored in S3 temp.
示例7: QrUrl
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def QrUrl(self, url, showQr=True):
if showQr:
notice='or scan this QR '
else:
notice=''
self.callback('Open this link ' + notice + 'on your LINE for smartphone in 2 minutes\n' + url)
if showQr:
try:
import pyqrcode
url = pyqrcode.create(url)
self.callback(url.terminal('green', 'white', 1))
except:
pass
示例8: edit_profile
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def edit_profile():
"""Edit profile function allows the user to modify their about me section."""
form = EditProfileForm(current_user.username)
if form.validate_on_submit():
current_user.username = form.username.data
current_user.about_me = form.about_me.data
user_name = User.query.filter_by(username=current_user.username).first()
if user_name is None:
render_error_page_template(404)
if form.otp_token_checkbox.data:
if user_name.otp_secret:
current_user.otp_secret = user_name.otp_secret
else:
current_user.otp_secret = pyotp.random_base32()
db.session.commit()
url = pyqrcode.create(user_name.get_totp_uri())
stream = BytesIO()
url.svg(stream, scale=3)
return render_template('two-factor-setup.html'), 200, {
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0'}
elif request.method == 'GET':
form.username.data = current_user.username
form.about_me.data = current_user.about_me
if form.otp_token_checkbox:
if form.otp_token_checkbox.data:
form.otp_token.data = current_user.otp_token
else:
form.otp_token_checkbox = current_user.otp_token_checkbox
else:
for error in form.errors:
flash(str(form.errors[error][0]), 'error')
return render_template('edit_profile.html', title=_('Edit Profile'), form=form)
示例9: two_factor_setup
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def two_factor_setup():
"""Two factory auth user setup page."""
if 'username' not in session:
return redirect(url_for('main.index'))
user_name = User.query.filter_by(username=current_user.username).first()
# since this page contains the sensitive qrcode
# make sure the browser does not cache it
url = pyqrcode.create(user_name.get_totp_uri())
stream = BytesIO()
url.svg(stream, scale=3)
return render_template('two-factor-setup.html'), stream.getvalue(), 200, {
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0'}
示例10: us_qrcode
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def us_qrcode(token):
if "authenticator" not in config_value("US_ENABLED_METHODS"):
return abort(404)
expired, invalid, state = check_and_get_token_status(
token, "us_setup", get_within_delta("US_SETUP_WITHIN")
)
if expired or invalid:
return abort(400)
try:
import pyqrcode
# By convention, the URI should have the username that the user
# logs in with.
username = current_user.calc_username()
url = pyqrcode.create(
_security._totp_factory.get_totp_uri(
username if username else "Unknown", state["totp_secret"]
)
)
except ImportError: # pragma: no cover
raise
from io import BytesIO
stream = BytesIO()
url.svg(stream, scale=3)
return (
stream.getvalue(),
200,
{
"Content-Type": "image/svg+xml",
"Cache-Control": "no-cache, no-store, must-revalidate",
"Pragma": "no-cache",
"Expires": "0",
},
)
示例11: __init__
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def __init__(self, data):
self.matrix = QRMatrix(pyqrcode.create(data, error="L").text().split("\n"))
示例12: QrUrl
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def QrUrl(self, url, showQr=True):
if showQr:
notice='or scan this QR '
else:
notice=''
self.callback("Open this link " + notice + "on your LINE for smartphone in 2 minutes\n" + url)
if showQr:
try:
import pyqrcode
url = pyqrcode.create(url)
self.callback(url.terminal('green', 'white', 1))
except:
pass
示例13: gen_qr_code
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def gen_qr_code(self, qr_file_path):
string = 'https://login.weixin.qq.com/l/' + self.uuid
qr = pyqrcode.create(string)
if self.conf['qr'] == 'png':
qr.png(qr_file_path, scale=8)
show_image(qr_file_path)
# img = Image.open(qr_file_path)
# img.show()
elif self.conf['qr'] == 'tty':
print(qr.terminal(quiet_zone=1))
示例14: addQR
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def addQR(image, data, x, y):
qr = pyqrcode.create(data).text().split("\n")[:-1]
np_qr = np.zeros((len(qr), len(qr[0])), dtype=np.uint8)
for row in range(len(qr)):
np_qr[row] = list(qr[row])
np_qr = np_qr[4:np_qr.shape[0] - 4, 4:np_qr.shape[1] - 4]
np_qr = np_qr[:,:] * 255
np_qr = np_qr
np_qr = resizeQR(np_qr, 15)
image[x:x+np_qr.shape[0], y:y+np_qr.shape[1], 0] = np_qr
image[x:x+np_qr.shape[0], y:y+np_qr.shape[1], 1] = np_qr
示例15: get_language
# 需要导入模块: import pyqrcode [as 别名]
# 或者: from pyqrcode import create [as 别名]
def get_language(message):
"""
Set the language for messaging the user
"""
get_language_call = "SELECT language_code FROM languages WHERE user_id = %s AND languages.system = %s"
language_values = [message['sender_id'], message['system']]
language_return = modules.db.get_db_data_new(get_language_call, language_values)
# If there is no record, create a new one with default EN language
try:
message['language'] = language_return[0][0]
except Exception as e:
logger.info("{}: There was no language entry, setting default".format(datetime.now()))
# Check if the user has an account - if not, create one
no_lang_call = ("SELECT account, register FROM users WHERE user_id = {} AND users.system = '{}'"
.format(message['sender_id'], message['system']))
data = modules.db.get_db_data(no_lang_call)
if not data:
# Create an account for the user
sender_account = modules.db.get_spare_account()
account_create_call = ("INSERT INTO users (user_id, system, user_name, account, register) "
"VALUES(%s, %s, %s, %s, 1)")
account_create_values = [message['sender_id'], message['system'], message['sender_screen_name'],
sender_account]
modules.db.set_db_data(account_create_call, account_create_values)
message['language'] = 'en'