예제 #1
0
def attachment_beacons():
    if 'credentials' not in flask.session:
        return flask.redirect(flask.url_for('portal.oauth2callback'))
    credentials = client.OAuth2Credentials.from_json(
        flask.session['credentials']
    )

    if credentials.access_token_expired:
        return flask.redirect(flask.url_for('portal.oauth2callback'))
    else:
        beacon_name = request.args.get('name')
        decoded_message = ''
        beacon = BeaconHelper.create_beacon(request.args)
        status = controller.namespace_of_beacon(credentials)
        data = status['namespaces'][0]['namespaceName']
        namespace = ((data.strip("namespaces")).replace('/', '')) + "/json"
        status = controller.list_beacons_attachment(beacon, credentials)

        if ("attachments") in (json.loads(status)):
            decoded_message = base64.b64decode(
                (json.loads(status))['attachments'][0]['data']
            )

    return render_template(
        'attachment.jinja', beacon=namespace, name=beacon_name,
        attachment=decoded_message)
예제 #2
0
def list_beacons_attachment():
    """
    Returns status of deactivation of beacon
    """
    if "credentials" not in flask.session:
        return flask.redirect(flask.url_for("portal.oauth2callback"))
    credentials = client.OAuth2Credentials.from_json(flask.session["credentials"])
    if credentials.access_token_expired:
        return flask.redirect(flask.url_for("portal.oauth2callback"))
    else:
        beacon = BeaconHelper.create_beacon(request.args)
        status = controller.list_beacons_attachment(beacon, credentials)

        if ("attachments") in (json.loads(status)):
            decoded_message = base64.b64decode((json.loads(status))["attachments"][0]["data"])
            return render_template("view_attachment.jinja", attachment=decoded_message, status=json.loads(status))
        else:
            return render_template("view_attachment.jinja", msg="Sorry No Attachments Found")
예제 #3
0
def attachment_beacons():
    if "credentials" not in flask.session:
        return flask.redirect(flask.url_for("portal.oauth2callback"))
    credentials = client.OAuth2Credentials.from_json(flask.session["credentials"])

    if credentials.access_token_expired:
        return flask.redirect(flask.url_for("portal.oauth2callback"))
    else:
        beacon_name = request.args.get("name")
        decoded_message = ""
        beacon = BeaconHelper.create_beacon(request.args)
        status = controller.namespace_of_beacon(credentials)
        data = status["namespaces"][0]["namespaceName"]
        namespace = ((data.strip("namespaces")).replace("/", "")) + "/json"
        status = controller.list_beacons_attachment(beacon, credentials)

        if ("attachments") in (json.loads(status)):
            decoded_message = base64.b64decode((json.loads(status))["attachments"][0]["data"])

    return render_template("attachment.jinja", beacon=namespace, name=beacon_name, attachment=decoded_message)