Beispiel #1
0
import os
import barrister
import pdb
import flask
import json
import httplib2

# internal libs
from repository import Repository
from db import Db
from projectservice import ProjectService
from authservice import AuthService

app = flask.Flask(__name__)
app.secret_key = dict_get(os.environ, 'SMS_FLASK_SECRET_KEY')
app.wsgi_app = ProxyFix(app.wsgi_app)

#################################################################
# oauth config #
################

with open('client_secrets.json', 'w') as outfile:
    json.dump({
        'web': {
        'client_id': dict_get(os.environ, 'SMS_GOOGLE_LOGIN_CLIENT_ID'),
        'client_secret': dict_get(os.environ, 'SMS_GOOGLE_LOGIN_CLIENT_SECRET'),
        'redirect_uris': ['http://www.simplemappingsystem.com/oauth2callback', 'http://simplemappingsystem.com/oauth2callback'],
        'auth_uri': 'https://accounts.google.com/o/oauth2/auth',
        'token_uri': 'https://accounts.google.com/o/oauth2/token'
        }
#!/usr/bin/env python

import barrister
import logging
import os
from functools import wraps
from utilities import dict_get

API_URI = dict_get(os.environ, 'API_URI')

# disable debug logging
logging.getLogger("barrister").setLevel(logging.INFO)

# change this to point at wherever your server is running
trans = barrister.HttpTransport(API_URI)

# automatically connects to endpoint and loads IDL JSON contract
client = barrister.Client(trans)

svc = client.ProjectService

def expectsRpcException(code):
    def decorator(function):
        @wraps(function)
        def wrapper(*args, **kwargs):
            try:
                function(*args, **kwargs)
            except barrister.RpcException as e:
                assert e.code == code
            else:
                assert False, "Should have thrown barrister.RpcException with code: %s" % code