Example #1
0
def main():
    opts = get_config()

    logger.info("Preparing for data retrieval")
    data_download = DataDownload(opts.tempdir)
    data_download.add_download(
        "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv",
        "covid19_confirmed.csv")
    data_download.add_download(
        "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv",
        "covid19_deaths.csv")
    data_download.add_download(
        "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv",
        "covid19_recovered.csv")
    data_download.add_download(
        "https://population.un.org/wpp/Download/Files/1_Indicators%20(Standard)/CSV_FILES/WPP2019_TotalPopulationBySex.csv",
        "total_population_data.csv")

    data_file_paths = data_download.download_all()

    data = {}
    for file_path in data_file_paths:
        if file_path.endswith('covid19_confirmed.csv'):
            data['infected'] = file_path
        elif file_path.endswith('covid19_deaths.csv'):
            data['dead'] = file_path
        elif file_path.endswith('covid19_recovered.csv'):
            data['recovered'] = file_path
        elif file_path.endswith('total_population_data.csv'):
            data['population'] = file_path

    logger.info('Parsing COVID-19 data')
    data_parser = coviddata.COVIDDataParser(data['infected'],
                                            data['recovered'], data['dead'])
    covid_data = data_parser.parse()

    logger.info('Parsing population data')
    population_data = populationdata.PopulationDataParser(
        data['population']).parse()
    population_data.add_country_aliases('United States of America', 'US',
                                        'USA')
    population_data.add_country_aliases('Dem. People\'s Republic of Korea',
                                        'North Korea', 'Korea, North')
    population_data.add_country_aliases('Republic of Korea', 'South Korea',
                                        'Korea, South')

    app.set_data(covid_data, population_data)
    app.create()

    server = app.start()

    options = {
        'bind': '%s:%s' % (opts.listen, opts.port),
        'workers': opts.workers
    }
    StandaloneApplication(server, options).run()
Example #2
0
def main(args):
    with contextlib.closing(db_store.open_or_create_db(
            args.db_file)) as db_connection:
        temperature_store = db_store.TemperatureStore(db_connection)
        light_store = db_store.LightStore(db_connection)
        soil_moisture_store = db_store.SoilMoistureStore(db_connection)
        humidity_store = db_store.HumidityStore(db_connection)

        app.create(images.Indexer(args.image_path), temperature_store,
                   light_store, soil_moisture_store,
                   humidity_store).run('0.0.0.0', args.port)
Example #3
0
def main(args):
    with contextlib.closing(db_store.open_or_create_db(
            args.db_file)) as db_connection:
        temperature_store = db_store.TemperatureStore(db_connection)
        water_level_store = db_store.WaterLevelStore(db_connection)
        light_store = db_store.LightStore(db_connection)
        soil_moisture_store = db_store.SoilMoistureStore(db_connection)
        humidity_store = db_store.HumidityStore(db_connection)
        watering_event_store = db_store.WateringEventStore(db_connection)

        app.create(images.Indexer(args.image_path, "full_res"),
                   images.Indexer(args.image_path, "reduced_res"),
                   temperature_store, water_level_store, light_store,
                   soil_moisture_store, humidity_store,
                   watering_event_store).run('0.0.0.0', args.port)
Example #4
0
def test_create_put_bot_no_prefix(validate_intent, mock_intent, mock_bot,
                                  cfn_create_no_prefix_event, setup,
                                  monkeypatch):
    """ test_create_puts_bot"""
    context, builder, _ = setup
    resources = cfn_create_no_prefix_event['ResourceProperties']
    messages = resources.get('messages')

    resources.pop('slotTypes')

    mock_bot.return_value = '1234'
    intent = Intent('a', 'b', 'c', 'd', 'e')
    mock_intent.return_value = intent

    builder.put.return_value = {"name": 'LexBot', "version": '$LATEST'}
    patch_builder(context, builder, monkeypatch)

    response = app.create(cfn_create_no_prefix_event, context)
    messages = resources['messages']

    builder.put.assert_called_once_with('1234')
    mock_bot.assert_called_once_with('LexBot', [intent, intent],
                                     messages,
                                     locale=resources.get('locale'),
                                     description=resources.get('description'))
    validate_intent.assert_called_once
    mock_intent.assert_called

    assert response['BotName'] == 'LexBot'
    assert response['BotVersion'] == BOT_VERSION
Example #5
0
def start():

    scheduler.start()

    flask_app = app.create(True)

    flask_app.run(host='0.0.0.0', port=8000, use_reloader=False)
Example #6
0
def main():
    # Ensure that app is on the python module search path
    # by including the directory that holds this file:
    # /some/path/to/app/
    #                 |
    #                 +---> wsgi.py  <- you are here
    #                 +---> app/     <- the goods
    _root_app_path = path.dirname(path.abspath(__file__))
    sys.path.append(_root_app_path)

    _config_name = environ.get('RUNTIME_CONFIG', 'debug')
    print('RUNTIME_CONFIG={}'.format(_config_name))
    import app
    instance = app.create(_root_app_path, _config_name)
    instance.run('0.0.0.0', port=instance.config.get('BIND_PORT'))
Example #7
0
def main():
    # Ensure that app is on the python module search path
    # by including the directory that holds this file:
    # /some/path/to/app/
    #                 |
    #                 +---> wsgi.py  <- you are here
    #                 +---> app/     <- the goods
    _root_app_path = path.dirname(path.abspath(__file__))
    sys.path.append(_root_app_path)

    _config_name = environ.get('RUNTIME_CONFIG', 'debug')
    print('RUNTIME_CONFIG={}'.format(_config_name))
    import app
    instance = app.create(_root_app_path, _config_name)
    instance.run('0.0.0.0', port=instance.config.get('BIND_PORT'))
Example #8
0
    def __init__(self, *args, **kwargs):
        Page.__init__(self, *args, **kwargs)

        #username label and text entry box
        usernameLabel = tk.Label(self, text="Username").grid(row=0, column=0)
        username = tk.StringVar()
        usernameEntry = tk.Entry(self, textvariable=username).grid(row=0, column=1)  

        #password label and password entry box
        passwordLabel = tk.Label(self,text="Password").grid(row=1, column=0)  
        password = tk.StringVar()
        passwordEntry = tk.Entry(self, textvariable=password, show='*').grid(row=1, column=1)

        loginUserButton = tk.Button(self, text ="Login", command = lambda: app.login(username.get(), password.get())).grid(row=4, column=1) 
        createUserButton = tk.Button(self, text ="Create User", command = lambda: app.create(username.get(), password.get())).grid(row=5, column=1) 
Example #9
0
def test_create_put_slottypes(cfn_create_event, setup, monkeypatch):
    """ test_create_put_slottypes_"""
    context, builder, slot_builder = setup

    builder.put.return_value = {"name": BOT_NAME, "version": '$LATEST'}
    slot_types = SlotType.create_slot_types(SLOT_TYPES, prefix=PREFIX)

    slot_builder.put_slot_type.return_value = {
        "pizzasize": 'LexBot',
        "version": '$LATEST'
    }

    patch_builder(context, builder, monkeypatch)
    patch_slot_builder(context, slot_builder, monkeypatch)

    response = app.create(cfn_create_event, context)

    slot_builder.put_slot_type.assert_called_once_with(slot_types[0])
    assert response['BotName'] == BOT_NAME
Example #10
0
def test_create_puts(mock_intent, mock_bot, cfn_create_event, setup,
                     monkeypatch):
    """ test_create_puts_bot"""
    context, builder, _ = setup

    cfn_create_event['ResourceProperties'].pop('slotTypes')
    mock_bot.return_value = '1234'

    builder.put.return_value = {"name": BOT_NAME, "version": '$LATEST'}
    intent = Intent('a', 'b', 'c', 'd', None)
    mock_intent.return_value = intent

    patch_builder(context, builder, monkeypatch)

    response = app.create(cfn_create_event, context)

    builder.put.assert_called_once_with('1234')

    assert response['BotName'] == BOT_NAME
    assert response['BotVersion'] == BOT_VERSION
Example #11
0
def create_pecan(body, headers):
    sys.path.append('./nuts/nuts')
    import app as nuts
    del sys.path[-1]

    return nuts.create()
Example #12
0
import app
from config import DevelopConfig
from flask_script import Manager
from models import db
from flask_migrate import Migrate, MigrateCommand
from my_command import CreateAdmin,LoginTest

# 创建app对象
develop_app = app.create(DevelopConfig)

# 创建扩展命令对象
manager = Manager(develop_app)

# 添加迁移命令
Migrate(develop_app, db)
manager.add_command('db', MigrateCommand)

# 添加管理员命令
manager.add_command('createadmin', CreateAdmin())
manager.add_command('logintest', LoginTest())

if __name__ == '__main__':
    manager.run()
def spaces():
    print("     list - To list all spaces")
    print("--------------------------------------")
    print("     sno - To list number of spaces")
    print("--------------------------------------")
    print("     create - To create a new space")
    print("--------------------------------------")
    print("     help - To view more")
    print("--------------------------------------")
    print("Advanced features will be added soon")
    print("Kindly send any suggestions or bugs to - [email protected] ")
    print("I will be very excited to add it")
    while True:
        ex = input("Spaces-> ")
        cmd = ex.lower()
        if cmd.strip() == "list":
            app.count()
        elif cmd == "sno":
            print("Available Spaces: " + str(app.amount_of_spaces))
        elif cmd == "create":
            name = input("Name: ")
            if len(name) > 0:
                region = input("Region: ")
                app.create(name, region)
        elif cmd == "help":
            app.help()
        elif cmd[:3] == "use":
                try:
                    use, space, region = cmd.split(" ")
                    if region in regions:
                        app.use(space, region)
                    else:
                        print("Invalid region")
                        for region in regions:
                            print("[+] " + region)
                        print("Usage: use space_name region_name [ex: use my-tes-space nyc3]")

                except:
                    print("Usage: use space_name region_name [ex: use my-tes-space nyc3]")
        elif cmd[:7] == 'destroy':

            print("Format: space_name region [Ex: my-test-space nyc3]")
            space_name = input("Please type the name. not the number -> ")
            print("We are still working on a security feature to make the user ...")
            print("... is 100% sure that they know what they are doing ")
            print("Sorry :( ")
        elif cmd[:6] == "upload":
            try:
                new = cmd[7:]
                a, b, c = new.split(":")
                space = a.strip()
                region, file = b.split("->")
                detect = os.path.isfile(str(file))
                if detect:
                    if len(c) > 0:
                        app.upload_file(file, space, region, c)
                    else:
                        print("Invalid FileName to put on the space")
                        print("Usage: upload space_name:region->file_on_local_disk:name_when_uploaded")
                        print("EX: upload myspace:nyc3->my-file-from-disk:output-name.txt")
                        print("Type 'list' to view spaces")
                else:
                    print("File Not Found")
                    print("Usage: upload space_name:region->file_on_local_disk:name_when_uploaded")
                    print("EX: upload myspace:nyc3->my-file-from-disk:output-name.txt")
                    print("Type 'list' to view spaces")
            except:
                print("Error")
                print("Usage: upload space_name:region->file_on_local_disk:name_when_uploaded")
                print("EX: upload myspace:nyc3->my-file-from-disk:output-name.txt")
                print("Type 'list' to view spaces")
        elif cmd[:7] == "list in":
            try:
                spaces_a = ['ams3', 'nyc3', 'sgp1', 'sfo2']
                l, a, space_name, region = cmd.split(" ")
                if region.strip() in spaces_a:
                    app.show(space_name, region)
                else:
                    print('Invalid Space_region')
                    print('Available Regions')
                    for region in spaces_a:
                        print("[+] " + region)
                    print("Usage: [ex: list in my-test-space nyc3]")
            except:
                print("Usage: list in space_name region_name [ex: list in my-test-space nyc3]")
        else:
            print("Unknow Command")
 def setUp(self):
     super(TestBase, self).setUp()
     self.app = app.create()
Example #15
0
# -*- coding: utf-8 -*-
from flask import Flask
from flask_cors import *
from app import create
from app.models import create_table, db
from config import *
from playhouse.flask_utils import FlaskDB

import sys
app = Flask(__name__)
FlaskDB(app, db)
# from app import novel
CORS(app, supports_credentials=True)
# app.register_blueprint(novel.app, url_prefix="/erolight")
app = create(app)
if __name__ == "__main__":
    if len(sys.argv) is not 1: create_table()

    app.run(port=WEB_PORT, host=WEB_ADDRESS, debug=True)
Example #16
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask_script import Manager
import config
import app

# 指定使用哪个配置,来创建flask对象
#flask_app=Flask()
flask_app = app.create(config.DevelopConfig)

# 添加扩展对象
manager = Manager(flask_app)

#添加管理员命令
from super_command import CreateSuperUserCommand, CreateTestUser, CreateTestLogin
manager.add_command('createuser', CreateSuperUserCommand())
manager.add_command('createtest', CreateTestUser())
manager.add_command('createlogin', CreateTestLogin())

#添加迁移命令
from models import db
from flask_migrate import Migrate, MigrateCommand
migrate = Migrate(flask_app, db)
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    # print(flask_app.url_map)
    #manager.run()
    flask_app.run(host='0.0.0.0', port=8889)
Example #17
0
import app

if __name__ == '__main__':
    app.create()
Example #18
0
def start():
    flask_app = app.create(True)

    flask_app.run()
Example #19
0
# coding: utf-8

import os
import sys

libdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib')
sys.path.insert(0, libdir)

from google.appengine.ext.webapp.util import run_wsgi_app

import app

app = app.create()

run_wsgi_app(app)
Example #20
0
def create_pecan(body, headers):
    sys.path.append('./nuts/nuts')
    import app as nuts
    del sys.path[-1]

    return nuts.create()
Example #21
0
"""WSGI application declaration."""
import app

application = app.create(settings_module_name='settings')
Example #22
0
def client():
    return testing.TestClient(app.create())
Example #23
0
import os
from app import create, models
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

app = create()
manage = Manager(app)
migrate = Migrate(app, models)
app.secret_key = "123123"

manage.add_command("db", MigrateCommand)

if __name__ == '__main__':
    manage.run()
def app():
    app = hello_app.create()
    app.debug = True
    return app
Example #25
0
def create_pecan(body, headers):
    return nuts.create()
Example #26
0
def app(loop):
    return create(loop)
# Application entry point.
# Gunicorn calls this process to start it up.
# Use the startup script provided for understanding it better
import os
import app

if __name__ == "__main__":
    production = "gunicorn" in os.environ.get("SERVER_SOFTWARE", "")
    print('Application loaded as ', 'PROD' if production else 'DEBUG')
    application = app.create()
    serve(application, host='0.0.0.0', port=8000)
Example #28
0
# -*- coding: utf-8 -*-
"""wsgi like"""

import os
import sys
import asyncio
import logging.config


SRC_ROOT = os.path.abspath(os.path.dirname(__file__))
sys.path.append(SRC_ROOT)


from app import create  # noqa


loop = asyncio.get_event_loop()
app = create(loop=loop)
from app import create

if __name__ == '__main__':
    application = create()
    application.run(host='0.0.0.0', port=8000, debug=True)
Example #30
0
import requests
from flask.ext.script import Manager


root_app_path = path.dirname(path.abspath(__file__))
sys.path.append(root_app_path)

try:
    # manage <config> <cmd> <args>
    _ = sys.argv[2] # Assert that there is a 3rd element
    config_name = sys.argv.pop(1)
except IndexError:
    config_name = 'debug'

import app
instance = app.create(root_app_path, config_name=config_name)

manager = Manager(instance)

@manager.command
def server():
    instance.run(port=instance.config.get('BIND_PORT'))

@manager.command
def example():
    resp = requests.get('http://127.0.0.1:8000/api/place?latitude=47.6&longitude=-122.3&search_radius_meters=1000')
    entries = resp.json()
    print(resp.text)

    photo_url = next(e['photo_url'] for e in entries if e['photo_url'] is not None)
    print('Photo URL:', photo_url)
Example #31
0
import app as x

x.create('a', 1)
x.create('b', 2)
x.create('c', 3)
x.create('d', 4)
x.create('e', 5)
x.create('f', 6)
x.create('g', 7)

x.read('a')
x.read('b')
x.completeData()
x.delete('a')
x.delete('b')
x.completeData()
x.save_data()
Example #32
0
import requests
from flask.ext.script import Manager

root_app_path = path.dirname(path.abspath(__file__))
sys.path.append(root_app_path)

try:
    # manage <config> <cmd> <args>
    _ = sys.argv[2]  # Assert that there is a 3rd element
    config_name = sys.argv.pop(1)
except IndexError:
    config_name = 'debug'

import app
instance = app.create(root_app_path, config_name=config_name)

manager = Manager(instance)


@manager.command
def server():
    instance.run(port=instance.config.get('BIND_PORT'))


@manager.command
def example():
    resp = requests.get(
        'http://127.0.0.1:8000/api/place?latitude=47.6&longitude=-122.3&search_radius_meters=1000'
    )
    entries = resp.json()