Exemplo n.º 1
0
"""
Get text for messages.
"""

import datetime
import urllib
import uuid
import quickieconfig as qc

LOG_SERVER_HOST = qc.param("LOG_SERVER_HOST")
LOG_SERVER_PORT = qc.param("LOG_SERVER_PORT")

def make_link(data):
    """Create a logging link from a simple dictionary of stuff."""
    querystring = urllib.urlencode(data)
    return "http://{}:{}/log?{}".format(
            LOG_SERVER_HOST,
            LOG_SERVER_PORT,
            querystring)

def morning_message_body():
    """Get the body text of the morning message."""
    message_uuid = uuid.uuid4()
    lines = []
    lines.append("Hello,")
    lines.append("")
    lines.append("How many hours did you sleep last night?")
    for n in xrange(4, 12):
        lines.append("")
        lines.append("")
        link_uuid = uuid.uuid4()
Exemplo n.º 2
0
"""
Example of how to send a message.
"""

from sendgrid import SendGridClient, Mail

import quickieconfig as qc

SENDGRID_USER = qc.param("SENDGRID_USER")
SENDGRID_PASS = qc.param("SENDGRID_PASS")
FROM_EMAIL = qc.param("FROM_EMAIL")
TO_ADDR = qc.param("TARGET_EMAIL")
BODY = "foo"

client = SendGridClient(SENDGRID_USER, SENDGRID_PASS, raise_errors=True)

message = Mail(from_email=FROM_EMAIL, to=TO_ADDR, subject="test", text=BODY)

status, msg = client.send(message)
print "status", status
print "msg", msg
Exemplo n.º 3
0
"""
Listen and log arbitrary stuff.
"""

import datetime
import pymongo
import quickieconfig as qc
from flask import Flask, request

SERVER_DEBUG_MODE = qc.param("SERVER_DEBUG_MODE") in ["ON", "YES", "TRUE", "1", 1]
MONGO_DB = qc.param("MONGO_DB")

app = Flask(__name__)
mongo_client = pymongo.MongoClient()
mongo_db = mongo_client[MONGO_DB]

@app.route("/")
def root():
    return "Hey there."

@app.route("/heartbeat")
def heartbeat():
    return "Still alive."

@app.route("/log")
def receive_log():
    data = _unmultidict(request.args)
    data["time_logged"] = datetime.datetime.now()
    _add_log_entry(data)
    return "Ok."
Exemplo n.º 4
0
"""
Listen and log arbitrary stuff.
"""

import datetime
import pymongo
import quickieconfig as qc
from flask import Flask, request

SERVER_DEBUG_MODE = qc.param("SERVER_DEBUG_MODE") in [
    "ON", "YES", "TRUE", "1", 1
]
MONGO_DB = qc.param("MONGO_DB")

app = Flask(__name__)
mongo_client = pymongo.MongoClient()
mongo_db = mongo_client[MONGO_DB]


@app.route("/")
def root():
    return "Hey there."


@app.route("/heartbeat")
def heartbeat():
    return "Still alive."


@app.route("/log")
def receive_log():
Exemplo n.º 5
0
"""
Get text for messages.
"""

import datetime
import urllib
import uuid
import quickieconfig as qc

LOG_SERVER_HOST = qc.param("LOG_SERVER_HOST")
LOG_SERVER_PORT = qc.param("LOG_SERVER_PORT")


def make_link(data):
    """Create a logging link from a simple dictionary of stuff."""
    querystring = urllib.urlencode(data)
    return "http://{}:{}/log?{}".format(LOG_SERVER_HOST, LOG_SERVER_PORT,
                                        querystring)


def morning_message_body():
    """Get the body text of the morning message."""
    message_uuid = uuid.uuid4()
    lines = []
    lines.append("Hello,")
    lines.append("")
    lines.append("How many hours did you sleep last night?")
    for n in xrange(4, 12):
        lines.append("")
        lines.append("")
        link_uuid = uuid.uuid4()