<commit_before>from flask import Flask
from flask import request
from flask import session
from flask_oauth import OAuth
#from flask_login import LoginManager, current_user
from flask.ext.restful import reqparse, abort, Api, Resource
import flask.ext.restful as restful
import json
import types
from ConfigParser import ConfigParser
from teeminus10_helpers import T10Helper, T10ACSHelper

app = Flask("T-10")
api = restful.Api(app)

#login_manager = LoginManager()
#login_manager.init_app(app)

#oauth = OAuth()
#twitter = oauth.remote_app('twitter',
#    base_url='https://api.twitter.com/1/',
#    request_token_url='https://api.twitter.com/oauth/request_token',
#    access_token_url='https://api.twitter.com/oauth/access_token',
#    authorize_url='https://api.twitter.com/oauth/authenticate',
#    consumer_key='<your key here>',
#    consumer_secret='<your secret here>'
#)

config = ConfigParser()
config.read("teeminus10.config")
acs_helper = T10ACSHelper(config.get('ACS', 'user'), config.get('ACS', 'password'), config.get('ACS', 'key'))
t10_helper = T10Helper(acs_helper)

class Alert(Resource):
    def get(self):
        return {'response': []}
    def put(self):
        data = request.json
        if data is not None:
            try:
                city = data['location']['city']
                coord = (0.0, 0.0)
            except KeyError:
                city = None
                coord = (data['location']['latitude'], data['location']['longitude'])
            finally:
                device_id = data['device_id']
                next_passes = t10_helper.alert_next_passes(data['max_cloud_cover'], data['time_of_day'], "foo", city=city, coord=coord)
                print next_passes
                return {'response': next_passes}
    def delete(self, alert_id):
        return {'response': 'ok'}

class Wave(Resource):
    def post(self, alert_id=None):
        if alert_id is None:
            self.do_wave_back()
        else:
            self.do_wave_start(alert_id)

    def do_wave_start(self):
        pass

    def do_wave_back(self):
        pass

class ISSPass(Resource):
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('lat', type=float, default=0.0)
        parser.add_argument('lon', type=float, default=0.0)
        parser.add_argument('alt', type=int, default=0)
        parser.add_argument('count', type=int, default=10)

        args = parser.parse_args()

        return t10_helper.get_next_visible_passes(args['lat'], args['lon'], args['alt'], args['count'], True)

class ISSLocation(Resource):
    def get(self):
        return t10_helper.get_current_iss_location()

api.add_resource(ISSLocation, '/location')
api.add_resource(ISSPass, '/passes')
api.add_resource(Alert, '/alerts', '/alerts/<int:alert_id>')
api.add_resource(Wave, '/alerts/wave/start/<int:alert_id>', '/alerts/wave/back')

#@<EMAIL>.route('/login')
#def login():
#    if current_user.is_authenticated():
#        return redirect('/')

if __name__ == '__main__':
    app.run(debug=True)<commit_msg>Whoops.<commit_after>from flask import Flask
from flask import request
from flask import session
from flask_oauth import OAuth
#from flask_login import LoginManager, current_user
from flask.ext.restful import reqparse, abort, Api, Resource
import flask.ext.restful as restful
import json
import types
from ConfigParser import ConfigParser
from teeminus10_helpers import T10Helper, T10ACSHelper

app = Flask("T-10")
api = restful.Api(app)

#login_manager = LoginManager()
#login_manager.init_app(app)

#oauth = OAuth()
#twitter = oauth.remote_app('twitter',
#    base_url='https://api.twitter.com/1/',
#    request_token_url='https://api.twitter.com/oauth/request_token',
#    access_token_url='https://api.twitter.com/oauth/access_token',
#    authorize_url='https://api.twitter.com/oauth/authenticate',
#    consumer_key='<your key here>',
#    consumer_secret='<your secret here>'
#)

config = ConfigParser()
config.read("teeminus10.config")
acs_helper = T10ACSHelper(config.get('ACS', 'user'), config.get('ACS', 'password'), config.get('ACS', 'key'))
t10_helper = T10Helper(acs_helper)

class Alert(Resource):
    def get(self):
        return {'response': []}
    def put(self):
        data = request.json
        if data is not None:
            try:
                city = data['location']['city']
                coord = (0.0, 0.0)
            except KeyError:
                city = None
                coord = (data['location']['latitude'], data['location']['longitude'])
            finally:
                device_id = data['device_id']
                next_passes = t10_helper.alert_next_passes(data['max_cloud_cover'], data['time_of_day'], "foo", city=city, coord=coord)
                print next_passes
                return {'response': next_passes}
    def delete(self, alert_id):
        return {'response': 'ok'}

class Wave(Resource):
    def post(self, alert_id=None):
        if alert_id is None:
            self.do_wave_back()
        else:
            self.do_wave_start(alert_id)

    def do_wave_start(self):
        pass

    def do_wave_back(self):
        pass

class ISSPass(Resource):
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('lat', type=float, default=0.0)
        parser.add_argument('lon', type=float, default=0.0)
        parser.add_argument('alt', type=int, default=0)
        parser.add_argument('count', type=int, default=10)

        args = parser.parse_args()

        return t10_helper.get_next_passes(args['lat'], args['lon'], args['alt'], args['count'], True)

class ISSLocation(Resource):
    def get(self):
        return t10_helper.get_current_iss_location()

api.add_resource(ISSLocation, '/location')
api.add_resource(ISSPass, '/passes')
api.add_resource(Alert, '/alerts', '/alerts/<int:alert_id>')
api.add_resource(Wave, '/alerts/wave/start/<int:alert_id>', '/alerts/wave/back')

<EMAIL>('/login')
#def login():
#    if current_user.is_authenticated():
#        return redirect('/')

if __name__ == '__main__':
    app.run(debug=True)
{'fraction_non_alphanumeric': 0.14182534471437952, 'fraction_numerical': 0.011162179908076166, 'mean_word_length': 3.3929343907714493, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2594788', 'n_tokens_mistral': 2009, 'n_tokens_neox': 1937, 'n_words': 393}