当前位置: 首页>>代码示例>>Python>>正文


Python qrcode.make函数代码示例

本文整理汇总了Python中qrcode.make函数的典型用法代码示例。如果您正苦于以下问题:Python make函数的具体用法?Python make怎么用?Python make使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了make函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: item_create

def item_create(form):
    record = db(db.geo_item.f_name == request.vars.f_name).select().first()
    if record.f_qrcode == None:
        arg = str(record.id)
        path = 'http://siri.pythonanywhere.com/byui_art/default/item_details?itemId=' + arg + '&qr=True'
        tiny = ""
        shortSuccess = False
        try:
            shortener = Shortener('Tinyurl')
            tiny = "{}".format(shortener.short(path))
            session.tinyCreateException = tiny
            shortSuccess = True
        except:
            session.tinyCreateException = "There was a problem with the url shortener. Please try again."

        if shortSuccess:
            code = qrcode.make(tiny)
        else:
            code = qrcode.make(path)
        qrName='geo_item.f_qrcode.%s.jpg' % (uuid.uuid4())
        code.save(request.folder + 'uploads/qrcodes/' + qrName, 'JPEG')
        record.update_record(f_qrcode=qrName)
        qr_text(qrName, record.f_name, record.f_alt5, tiny)
    try:
        imgPath = request.folder + 'uploads/' + record.f_image
        thumbName = 'geo_item.f_thumb.%s.%s.jpg' % (uuid.uuid4(), record.id)
        thumb = Image.open(request.folder + 'uploads/' + record.f_image)
        thumb.thumbnail((350, 10000), Image.ANTIALIAS)
        thumb.save(request.folder + 'uploads/thumbs/' + thumbName, 'JPEG')
        record.update_record(f_thumb=thumbName)
    except:
        session.itemCreateException = "there was a problem updating the image in item_create: " + record.f_name
    return dict()
开发者ID:siricenter,项目名称:byui_art,代码行数:33,代码来源:cms.py

示例2: make_qr

def make_qr(src_text):
  img = None
  if len(src_text) < 1024:
    img = qrcode.make( src_text )
  else:
    img = qrcode.make("too long keyword")
  return img
开发者ID:a2chub,项目名称:rqcodeweb,代码行数:7,代码来源:main.py

示例3: get_state

def get_state(**kwargs):
    eppn = mock_auth.authenticate(kwargs)
    current_app.logger.debug('Getting state for user with eppn {}.'.format(eppn))
    proofing_state = current_app.proofing_statedb.get_state_by_eppn(eppn, raise_on_missing=False)
    if not proofing_state:
        current_app.logger.debug('No proofing state found, initializing new proofing flow.'.format(eppn))
        state = get_unique_hash()
        nonce = get_unique_hash()
        token = get_unique_hash()
        proofing_state = OidcProofingState({'eduPersonPrincipalName': eppn, 'state': state, 'nonce': nonce,
                                            'token': token})
        claims_request = ClaimsRequest(userinfo=Claims(identity=None, vetting_time=None, metadata=None))
        # Initiate proofing
        response = do_authentication_request(state, nonce, token, claims_request)
        if response.status_code != 200:
            payload = {'error': response.reason, 'message': response.content}
            raise ApiException(status_code=response.status_code, payload=payload)
        # If authentication request went well save user state
        current_app.proofing_statedb.save(proofing_state)
        current_app.logger.debug('Proofing state {} for user {} saved'.format(proofing_state.state, eppn))
    # Return nonce and nonce as qr code
    current_app.logger.debug('Returning nonce for user {}'.format(eppn))
    buf = BytesIO()
    qr_code = '1' + json.dumps({'nonce': proofing_state.nonce, 'token': proofing_state.token})
    qrcode.make(qr_code).save(buf)
    qr_b64 = base64.b64encode(buf.getvalue()).decode()
    ret = {
        'qr_code': qr_code,
        'qr_img': '<img src="data:image/png;base64, {}"/>'.format(qr_b64),
    }
    return ret
开发者ID:SUNET,项目名称:se-leg-rp,代码行数:31,代码来源:views.py

示例4: generate_QRcodes

def generate_QRcodes():
    for i in range(1, len(checkpoints) + 1):
        img = qrcode.make('%s/item/%s' %(config['base_url'],
            uuid_str(i)))
        img.save('checkpoint_%d.png' %(i))
    img = qrcode.make('%s/start' % (config['base_url']))
    img.save('start.png')
开发者ID:inZka,项目名称:QRienteering,代码行数:7,代码来源:qrserver.py

示例5: generate

def generate(data):
    md5sum = md5(data).hexdigest()
    filename = '%s.png' % md5sum
    filepath = os.path.join(files_path, filename)
    if not os.path.exists(filepath):
        qrcode.make(data).save(open(filepath, 'wb'))
    return (filename, md5sum)
开发者ID:scottsask,项目名称:spawn-flask,代码行数:7,代码来源:core.py

示例6: main

def main():

    if common.debug:
        print "BEGIN offline_sign_tx"

    qrcode_tx_to_sign = Popen(["zbarimg", "--quiet", "images/raw_tx_to_sign.png"], stdout=PIPE).stdout.read()
    tx_to_sign = common.get_qrcode_val_from_str(qrcode_tx_to_sign).split(",")

    unspent_tx_output_details = [{"txid": str(tx_to_sign[1]),
                                  "vout": int(tx_to_sign[2]),
                                  "scriptPubKey": str(tx_to_sign[3])}]

    if common.debug:
        print "raw tx data read from qrcode"

    offline_sign_raw_tx = common.request(common_offline.off_url,
                                         {'method': 'signrawtransaction',
                                        'params': [tx_to_sign[0], unspent_tx_output_details]})

    if not offline_sign_raw_tx["result"]["complete"]:
        print "ERROR! tx signing incomplete!"
        print offline_sign_raw_tx
        sys.exit(1)

    if common.debug:
        print "signed tx offline: " + str(offline_sign_raw_tx)

    qrcode.make(offline_sign_raw_tx["result"]["hex"]).save('images/offline_signed_tx.png')

    if common.debug:
        print "signed offline transaction and saved qrcode: offline_signed_tx.png"
        print "END offline_sign_tx"
开发者ID:ramann,项目名称:bitcoin-qrcode,代码行数:32,代码来源:offline_sign_tx.py

示例7: _genBarcode

 def _genBarcode(self, content):
     md5 = hashlib.md5(bytes(content, 'utf-8')).hexdigest()
     path = os.path.join(PKG_DIR, 'images', 'qrcodes', '{}.png'.format(md5))
     # 是否存在这个md5文件,如果有直接返回结果,如果没有则生成
     if os.path.isfile(path):
         return path
     qrcode.make(content).save(path)
     return path
开发者ID:ousui,项目名称:Wox.Plugin.Py.Qrcode,代码行数:8,代码来源:Qrcode.py

示例8: vote_qr_code

def vote_qr_code(vote):
    if vote not in votes_config:
        return None
    out = StringIO.StringIO()
    qrcode.make('bitcoin:%s?amount=%s&label=%s' % (votes_config[vote]['address'], votes_config[vote]['ammount'], votes_config[vote]['label'])).save(out)
    resp = make_response(out.getvalue())
    resp.content_type = 'image/png'
    return resp
开发者ID:zparmley,项目名称:YH12,代码行数:8,代码来源:app.py

示例9: qr

def qr(uid, task, filetype, tempfile=False):
    endpoint = ".download_temp" if tempfile else ".download"
    url = url_for(endpoint, uid=uid, taskname=task, filetype=filetype, _external=True)

    img = StringIO()
    qrcode.make(url, box_size=3).save(img)
    img.seek(0)

    return send_file(img, mimetype="image/png")
开发者ID:Turbo87,项目名称:proSoar,代码行数:9,代码来源:tasks.py

示例10: make_qrcode_base64

def make_qrcode_base64(text):
    # Create a temporary placeholder to the image
    with BytesIO() as stream:
        # Generate the qrcode and save to the stream
        qrcode.make(text).save(stream)

        # Get the image bytes, then encode to base64
        image_data = b64encode(stream.getvalue())

    return image_data
开发者ID:humrochagf,项目名称:bsl-server,代码行数:10,代码来源:helpers.py

示例11: qrc

def qrc(data):
    import cStringIO
    import qrcode
    import qrcode.image.svg

    out = cStringIO.StringIO()
    qrcode.make(data, image_factory=qrcode.image.svg.SvgPathImage).save(out)
    qrsvg = out.getvalue()

    return re.search('d="(.*?)"', qrsvg).group(1)
开发者ID:avinodkumar,项目名称:stb-tester,代码行数:10,代码来源:stbt_camera_calibrate.py

示例12: main

def main():
    if common.debug:
        print "BEGIN offline_create_address"

    offline_address1 = common.request(common_offline.off_url, {'method': 'getnewaddress'})["result"]
    qrcode.make(offline_address1).save("images/offline_address1.png")
    offline_address2 = common.request(common_offline.off_url, {'method': 'getnewaddress'})["result"]
    qrcode.make(offline_address2).save("images/offline_address2.png")

    if common.debug:
        print "offline address1: " + offline_address1
        print "offline address2: " + offline_address2
        print "offline addresses saved to qrcode"
        print "END offline_create_address"
开发者ID:ramann,项目名称:bitcoin-qrcode,代码行数:14,代码来源:offline_create_address.py

示例13: get_state

def get_state(**kwargs):
    # TODO: Authenticate user authn response:
    # TODO: Look up user in central db
    eppn = mock_auth.authenticate(kwargs)
    current_app.logger.debug('Getting state for user with eppn {!s}.'.format(eppn))
    proofing_state = current_app.proofing_statedb.get_state_by_eppn(eppn, raise_on_missing=False)
    if not proofing_state:
        current_app.logger.debug('No proofing state found, initializing new proofing flow.'.format(eppn))
        state = get_unique_hash()
        nonce = get_unique_hash()
        proofing_state = OidcProofingState({'eduPersonPrincipalName': eppn, 'state': state, 'nonce': nonce})
        # Initiate proofing
        args = {
            'client_id': current_app.oidc_client.client_id,
            'response_type': 'code id_token token',
            'response_mode': 'query',
            'scope': ['openid'],
            'redirect_uri': url_for('oidc_proofing.authorization_response', _external=True),
            'state': state,
            'nonce': nonce,
            'claims': ClaimsRequest(userinfo=Claims(identity=None)).to_json()
        }
        current_app.logger.debug('AuthenticationRequest args:')
        current_app.logger.debug(args)
        try:
            response = requests.post(current_app.oidc_client.authorization_endpoint, data=args)
        except requests.exceptions.ConnectionError as e:
            msg = 'No connection to authorization endpoint: {!s}'.format(e)
            current_app.logger.error(msg)
            raise ApiException(payload={'error': msg})
        # If authentication request went well save user state
        if response.status_code == 200:
            current_app.logger.debug('Authentication request delivered to provider {!s}'.format(
                current_app.config['PROVIDER_CONFIGURATION_INFO']['issuer']))
            current_app.proofing_statedb.save(proofing_state)
            current_app.logger.debug('Proofing state {!s} for user {!s} saved'.format(proofing_state.state, eppn))
        else:
            payload = {'error': response.reason, 'message': response.content}
            raise ApiException(status_code=response.status_code, payload=payload)
    # Return nonce and nonce as qr code
    current_app.logger.debug('Returning nonce for user {!s}'.format(eppn))
    buf = StringIO()
    qrcode.make(proofing_state.nonce).save(buf)
    qr_b64 = buf.getvalue().encode('base64')
    ret = {
        'nonce': proofing_state.nonce,
        'qr_img': '<img src="data:image/png;base64, {!s}"/>'.format(qr_b64),
    }
    return ret
开发者ID:digideskio,项目名称:eduid-webapp,代码行数:49,代码来源:views.py

示例14: encode

    def encode(user, secret, organization, otp_type):
        """Encodes a HOTP or TOTP URL into a QR Code.

        The URL format conforms to what is expected by Google Authenticator.
        https://code.google.com/p/google-authenticator/wiki/KeyUriFormat

        Keyword arguments:
        user -- The user of the HOTP or TOTP secret
        secret -- The shared secret used to generate the TOTP value
        organization -- The issuer for the HOTP or TOTP secret
        otp_type -- The OTP type. Accepted values are hotp or totp

        Returns:
        The encoded QR Code image as a PIL Image type.

        """

        otp_types = ['hotp', 'totp']

        if otp_type not in otp_types:
            raise IncorrectOTPType()

        url = ''.join(['otpauth://', otp_type, '/', organization,
                       ':', user, '?', 'secret=', secret])

        return qrcode.make(url)
开发者ID:nidhog,项目名称:python-security,代码行数:26,代码来源:__init__.py

示例15: format_element

def format_element(bfo, width="100"):
    """
    Generate a QR-code image linking to the current record.

    @param width: Width of QR-code image.
    """
    if not HAS_QR:
        return ""

    width = int(width)

    bibrec_id = bfo.control_field("001")
    link = "%s/%s/%s" % (CFG_SITE_SECURE_URL, CFG_SITE_RECORD, bibrec_id)
    hash_val = _get_record_hash(link)

    filename = "%s_%s.png" % (bibrec_id, hash_val)
    filename_url = "/img/qrcodes/%s" % filename
    filename_path = os.path.join(CFG_WEBDIR, "img/qrcodes/%s" % filename)

    if not os.path.exists(filename_path):
        if not os.path.exists(os.path.dirname(filename_path)):
            os.makedirs(os.path.dirname(filename_path))

        img = qrcode.make(link)
        img._img = img._img.convert("RGBA")
        img._img = img._img.resize((width, width), Image.ANTIALIAS)
        img.save(filename_path, "PNG")

    return """<img src="%s" width="%s" />""" % (filename_url, width)
开发者ID:mhellmic,项目名称:b2share,代码行数:29,代码来源:bfe_qrcode.py


注:本文中的qrcode.make函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。