Пример #1
0
def _init_model(date_str, date_int, dir_temp, params):
    # Validate
    if not date_str:
        return None, 1, "date_str must be provided"
    if not date_int:
        return None, 1, "date_int must be provided"
    if not dir_temp:
        return None, 1, "dir_temp must be provided"

    if not params:
        return None, 1, "params must be provided"

    if not params.get("type", None):
        return None, 1, "params:type must be provided"
    if not params.get("scheme", None):
        return None, 1, "params:scheme must be provided"
    if not params.get("bucket", None):
        return None, 1, "params:bucket must be provided"
    if not params.get("dirstorage", None):
        return None, 1, "params:dirstorage must be provided"

    # Remote DB URL
    url_db = "".join(urlutil.url_build(params["scheme"], params["bucket"], params["dirstorage"], "_aeroback"))

    model = Model(
        atype=params["type"],
        scheme=params["scheme"],
        bucket=params["bucket"],
        dirstorage=params["dirstorage"],
        date_str=date_str,
        date_int=date_int,
        dir_temp=dir_temp,
        url_db=url_db,
    )

    return model, 0, None
Пример #2
0
def build_url(state, *paths):
    """
    Build storage url by adding paths to scheme://bucket/dirstorage
    """
    return "".join(urlutil.url_build(state.model.scheme, state.model.bucket, state.model.dirstorage, *paths))