Beispiel #1
0
from xml.sax.saxutils import escape as htmlescape
from habitat import uploader
from . import couch_to_xml
from habitat.utils.startup import load_config, setup_logging

# Monkey patch float precision
json.encoder.FLOAT_REPR = lambda o: format(o, '.5f')

app = flask.Flask("habitat_transition.app")
cache = Cache(threshold=10, default_timeout=60)

# Load config here :S ?
# N.B.: Searches working directory since it won't be specified in argv.
# Configure uwsgi appropriately.
config = load_config()
setup_logging(config, "transition_app")
couch_settings = {"couch_uri": config["couch_uri"],
                  "couch_db": config["couch_db"]}

@app.route("/")
def hello():
    return """
    <html>
    <body>

    <h3>payloads list</h3>
    <p><a href="allpayloads">XML</a></p>

    <h3>receivers list</h3>
    <p><a href="receivers">JSON</a></p>
Beispiel #2
0
import couchdbkit
import datetime
import icalendar
import pytz
from habitat.utils.startup import load_config, setup_logging
from flask import Flask, Response
app = Flask(__name__)

# N.B.: Searches working directory since it won't be specified in argv.
# Configure uwsgi appropriately.
config = load_config()
setup_logging(config, "calendar")
couch_settings = {"couch_uri": config["couch_uri"],
                  "couch_db": config["couch_db"]}

def load_flights():
    db = couchdbkit.Server(config["couch_uri"])[config["couch_db"]]
    view = db.view("flight/launch_time_including_payloads",
                   stale="update_after", include_docs=True)
    flights = []

    # very similar to habitat.uploader.Uploader.flights()
    for row in view:
        launch_timestamp, flight_id, is_pcfg = row["key"]
        doc = row["doc"]

        if not is_pcfg:
            doc["_payload_docs"] = []
            doc["_launch_timestamp"] = launch_timestamp
            flights.append(doc)
        elif doc is not None:
from xml.sax.saxutils import escape as htmlescape
from habitat import uploader
from . import couch_to_xml
from habitat.utils.startup import load_config, setup_logging

# Monkey patch float precision
json.encoder.FLOAT_REPR = lambda o: format(o, '.5f')

app = flask.Flask("habitat_transition.app")
cache = Cache(threshold=10, default_timeout=60)

# Load config here :S ?
# N.B.: Searches working directory since it won't be specified in argv.
# Configure uwsgi appropriately.
config = load_config()
setup_logging(config, "transition_app")
couch_settings = {"couch_uri": config["couch_uri"],
                  "couch_db": config["couch_db"]}

@app.route("/")
def hello():
    return """
    <html>
    <body>

    <h3>payloads list</h3>
    <p><a href="allpayloads">XML</a></p>

    <h3>receivers list</h3>
    <p><a href="receivers">JSON</a></p>