示例#1
0
文件: store.py 项目: islenv/openradar
    def __init__(self, timeframe, prodcode):
        self.timeframe = timeframe
        self.prodcode = prodcode

        # stores
        self.names = NAMES[timeframe][prodcode]
        group_path = os.path.join(config.STORE_DIR, self.names['group'])
        store_path = os.path.join(group_path, self.names['store'])
        self.store = stores.get(store_path)
        self.group = stores.get(group_path)

        # others
        self.helper = get_path_helper(timeframe, prodcode)
        self.level = LEVELS[prodcode]
示例#2
0
    def __init__(self, timeframe, prodcode):
        self.timeframe = timeframe
        self.prodcode = prodcode

        # stores
        self.names = NAMES[timeframe][prodcode]
        group_path = os.path.join(config.STORE_DIR, self.names['group'])
        store_path = os.path.join(group_path, self.names['store'])
        self.store = stores.get(store_path)
        self.group = stores.get(group_path)

        # others
        self.helper = get_path_helper(timeframe, prodcode)
        self.level = LEVELS[prodcode]
示例#3
0
def rotate_nowcast_stores(region):
    """
    Rotate the contents of the nowcast stores, filling the currently empty
    one with the latest data and removing the data from the currently
    loaded store.
    """
    # paths
    base = os.path.join(config.STORE_DIR, '5min')
    locker = turn.Locker(host=config.REDIS_HOST, db=config.REDIS_DB)
    with locker.lock(resource='5min', label='nowcast'):
        old = stores.get(os.path.join(base, 'nowcast1'))
        new = stores.get(os.path.join(base, 'nowcast2'))
        if new:
            old, new = new, old
        new.update([region])
        if old:
            start, stop = old.period
            old.delete(start=start, stop=stop)
示例#4
0
def get_metas(name, period):
    store = stores.get(os.path.join(config.STORE_DIR, name))
    metas = store.get_meta_direct(start=period.start, stop=period.stop)
    return {k: json.loads(v) for k, v in metas.items() if v}
示例#5
0
文件: move.py 项目: islenv/openradar
def get_store(time_name, store_name):
    """ Return a raster store. """
    path = os.path.join(config.STORE_DIR, time_name, store_name)
    return stores.get(path)
示例#6
0
def get_metas(name, period):
    store = stores.get(os.path.join(config.STORE_DIR, name))
    metas = store.get_meta_direct(start=period.start, stop=period.stop)
    return {k: json.loads(v) for k, v in metas.items() if v}
示例#7
0
def get_store(time_name, store_name):
    """ Return a raster store. """
    path = os.path.join(config.STORE_DIR, time_name, store_name)
    return stores.get(path)