Esempio n. 1
0
def init_db():
    import plenario.models
    from plenario.utils.weather import WeatherETL, WeatherStationsETL
    from plenario.utils.shapefile_helpers import PlenarioShapeETL
    import datetime

    print 'creating master, meta and user tables'
    Base.metadata.create_all(bind=app_engine)
    if plenario.settings.DEFAULT_USER:
        print 'creating default user %s' % plenario.settings.DEFAULT_USER['name']
        user = plenario.models.User(**plenario.settings.DEFAULT_USER)
        session.add(user)
        session.commit()

    print 'initializing NOAA weather stations'
    s = WeatherStationsETL()
    s.initialize()

    print 'initializing NOAA daily and hourly weather observations for %s/%s' % (datetime.datetime.now().month, datetime.datetime.now().year) 
    print 'this will take a few minutes ...'
    e = WeatherETL()
    e.initialize_month(datetime.datetime.now().year, datetime.datetime.now().month)

    print 'initializing and populating US Census blocks'
    print 'this will *also* take a few minutes ...'
    shp = PlenarioShapeETL(plenario.settings.CENSUS_BLOCKS)
    shp.add()
Esempio n. 2
0
def init_db():
    import plenario.models
    from plenario.utils.weather import WeatherETL, WeatherStationsETL
    from plenario.utils.shapefile_helpers import PlenarioShapeETL
    import datetime

    print 'creating master, meta and user tables'
    Base.metadata.create_all(bind=app_engine)
    if plenario.settings.DEFAULT_USER:
        print 'creating default user %s' % plenario.settings.DEFAULT_USER[
            'name']
        user = plenario.models.User(**plenario.settings.DEFAULT_USER)
        session.add(user)
        session.commit()

    print 'initializing NOAA weather stations'
    s = WeatherStationsETL()
    s.initialize()

    print 'initializing NOAA daily and hourly weather observations for %s/%s' % (
        datetime.datetime.now().month, datetime.datetime.now().year)
    print 'this will take a few minutes ...'
    e = WeatherETL()
    e.initialize_month(datetime.datetime.now().year,
                       datetime.datetime.now().month)

    print 'initializing and populating US Census blocks'
    print 'this will *also* take a few minutes ...'
    shp = PlenarioShapeETL(plenario.settings.CENSUS_BLOCKS)
    shp.add()
Esempio n. 3
0
def init_weather():
    print 'initializing NOAA weather stations'
    s = WeatherStationsETL()
    s.initialize()

    print 'initializing NOAA daily and hourly weather observations for %s/%s' % (datetime.datetime.now().month, datetime.datetime.now().year)
    print 'this will take a few minutes ...'
    e = WeatherETL()
    e.initialize_month(datetime.datetime.now().year, datetime.datetime.now().month)
Esempio n. 4
0
def init_weather():
    print 'initializing NOAA weather stations'
    s = WeatherStationsETL()
    s.initialize()

    print 'initializing NOAA daily and hourly weather observations for %s/%s' % (datetime.datetime.now().month, datetime.datetime.now().year)
    print 'this will take a few minutes ...'
    e = WeatherETL()
    try:
        e.initialize_month(datetime.datetime.now().year, datetime.datetime.now().month)
    except Exception as e:
        session.rollback()
        raise e
Esempio n. 5
0
def init_weather():
    print 'initializing NOAA weather stations'
    s = WeatherStationsETL()
    s.initialize()

    print 'initializing NOAA daily and hourly weather observations for %s/%s' % (datetime.datetime.now().month, datetime.datetime.now().year)
    print 'this will take a few minutes ...'
    e = WeatherETL()
    try:
        e.initialize_month(datetime.datetime.now().year, datetime.datetime.now().month)
    except Exception as e:
        session.rollback()
        raise e