Beispiel #1
0
def do_post(sess):
    start_date = req_date("start", "day")
    finish_year = req_int("finish_year")
    finish_month = req_int("finish_month")
    finish_day = req_int("finish_day")
    finish_date_ct = ct_datetime(finish_year, finish_month, finish_day, 23, 30)
    finish_date = to_utc(finish_date_ct)

    finish_date_str = finish_date_ct.strftime("%Y%m%d%H%M")
    if "site_id" in request.values:
        site_id = req_int("site_id")
        file_name = f"sites_hh_data_{site_id}_{finish_date_str}.csv"
        args = site_id, start_date, finish_date, g.user, file_name
        threading.Thread(target=site_content, args=args).start()
        return chellow_redirect("/downloads", 303)
    else:
        typ = req_str("type")
        site_codes_str = req_str("site_codes")
        site_codes = site_codes_str.splitlines()
        if len(site_codes) == 0:
            site_codes = None

        file_name = f"sites_hh_data_{finish_date_str}_filter.zip"
        args = site_codes, typ, start_date, finish_date, g.user, file_name
        threading.Thread(target=none_content, args=args).start()
        return chellow_redirect("/downloads", 303)
Beispiel #2
0
def do_get(sess):
    contract_id = req_int('hhdc_contract_id')
    days_hidden = req_int('days_hidden')

    args = (contract_id, days_hidden, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #3
0
def do_get(sess):
    year = req_int('year')
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    return send_response(
        content, args=(year, supply_id, sess), status=200,
        content_type='text/csv; charset=utf-8',
        file_name='output.csv')
def do_get(sess):
    base_name = []
    year = req_int("finish_year")
    month = req_int("finish_month")
    months = req_int("months")
    start_date = utc_datetime(year, month,
                              1) - relativedelta(months=months - 1)
    base_name.append('g_monthly_duration')

    site_id = req_int('site_id') if 'site_id' in request.values else None

    if 'g_supply_id' in request.values:
        g_supply_id = req_int('g_supply_id')
    else:
        g_supply_id = None

    if 'compression' in request.values:
        compression = req_bool('compression')
    else:
        compression = True

    user = g.user

    threading.Thread(target=content,
                     args=(base_name, site_id, g_supply_id, user, compression,
                           start_date, months)).start()
    return chellow_redirect("/downloads", 303)
Beispiel #5
0
def do_get(sess):
    contract_id = req_int("dc_contract_id")
    days_hidden = req_int("days_hidden")

    args = (contract_id, days_hidden, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #6
0
def do_get(sess):
    end_year = req_int('finish_year')
    end_month = req_int('finish_month')
    months = req_int('months')
    contract_id = req_int('supplier_contract_id')
    args = (contract_id, end_year, end_month, months, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #7
0
def do_get(sess):
    end_year = req_int('finish_year')
    end_month = req_int('finish_month')
    months = req_int('months')
    site_id = req_int('site_id')
    return send_response(
        content, args=(end_year, end_month, months, site_id, sess),
        file_name='displaced.csv')
Beispiel #8
0
def do_get(sess):
    end_year = req_int("finish_year")
    end_month = req_int("finish_month")
    months = req_int("months")
    contract_id = req_int("supplier_contract_id")
    args = contract_id, end_year, end_month, months, g.user
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #9
0
def do_get(sess):
    year = req_int("end_year")
    month = req_int("end_month")
    months = req_int("months")
    supply_id = req_int("supply_id") if "supply_id" in request.values else None
    args = (year, month, months, supply_id, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #10
0
def do_get(sess):
    end_year = req_int('finish_year')
    end_month = req_int('finish_month')
    months = req_int('months')
    contract_id = req_int('supplier_contract_id')
    args = (contract_id, end_year, end_month, months, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #11
0
def do_get(sess):
    year = req_int('end_year')
    month = req_int('end_month')
    months = req_int('months')
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    user = g.user
    threading.Thread(
        target=content, args=(year, month, months, supply_id, user)).start()
    return chellow_redirect("/downloads", 303)
Beispiel #12
0
def do_get(sess):
    year = req_int('end_year')
    month = req_int('end_month')
    months = req_int('months')
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    user = g.user
    threading.Thread(target=content,
                     args=(year, month, months, supply_id, user)).start()
    return chellow_redirect("/downloads", 303)
Beispiel #13
0
def do_get(sess):
    year = req_int('end_year')
    month = req_int('end_month')
    months = req_int('months')
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    file_name = 'reads_' + \
        Datetime.now(pytz.utc).strftime("%Y%M%d%H%m") + '.csv'
    return send_response(
        content, args=(
            year, month, months, supply_id, sess), file_name=file_name)
Beispiel #14
0
def do_get(sess):
    end_year = req_int("end_year")
    end_month = req_int("end_month")
    months = req_int("months")
    contract_id = req_int('dc_contract_id')

    user = g.user

    threading.Thread(target=content,
                     args=(contract_id, end_year, end_month, months,
                           user)).start()
    return chellow_redirect("/downloads", 303)
Beispiel #15
0
def do_get(sess):
    if "g_batch_id" in request.values:
        g_batch_id = req_int("g_batch_id")
        g_bill_id = None
    elif "g_bill_id" in request.values:
        g_bill_id = req_int("g_bill_id")
        g_batch_id = None
    else:
        raise BadRequest("The bill check needs a g_batch_id or g_bill_id.")

    threading.Thread(target=content, args=(g_batch_id, g_bill_id, g.user)).start()
    return chellow_redirect("/downloads", 303)
Beispiel #16
0
def do_get(sess):
    end_year = req_int("end_year")
    end_month = req_int("end_month")
    months = req_int("months")
    contract_id = req_int('hhdc_contract_id')

    user = g.user

    threading.Thread(
        target=content, args=(contract_id, end_year, end_month, months, user)
        ).start()
    return chellow_redirect("/downloads", 303)
Beispiel #17
0
def do_get(sess):
    if 'batch_id' in request.values:
        batch_id = req_int("batch_id")
        bill_id = None
    elif 'bill_id' in request.values:
        bill_id = req_int("bill_id")
        batch_id = None
    else:
        raise BadRequest("The bill check needs a batch_id or bill_id.")

    user = g.user
    threading.Thread(target=content, args=(batch_id, bill_id, user)).start()
    return chellow_redirect('/downloads', 303)
Beispiel #18
0
def do_get(sess):
    if 'g_batch_id' in request.values:
        g_batch_id = req_int('g_batch_id')
        g_bill_id = None
    elif 'g_bill_id' in request.values:
        g_bill_id = req_int('g_bill_id')
        g_batch_id = None
    else:
        raise BadRequest("The bill check needs a g_batch_id or g_bill_id.")

    threading.Thread(
        target=content, args=(g_batch_id, g_bill_id, g.user)).start()
    return chellow_redirect('/downloads', 303)
Beispiel #19
0
def do_get(sess):
    months = req_int('months')
    finish_year = req_int('finish_year')
    finish_month = req_int('finish_month')

    finish_date = Datetime(finish_year, finish_month, 1, tzinfo=pytz.utc) + \
        relativedelta(months=1) - HH
    start_date = finish_date + HH - relativedelta(months=months)

    typ = req_str('type')
    site_id = req_int('site_id')
    args = (start_date, finish_date, site_id, typ, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #20
0
def do_get(sess):
    months = req_int('months')
    finish_year = req_int('finish_year')
    finish_month = req_int('finish_month')

    finish_date = Datetime(finish_year, finish_month, 1, tzinfo=pytz.utc) + \
        relativedelta(months=1) - HH
    start_date = finish_date + HH - relativedelta(months=months)

    typ = req_str('type')
    site_id = req_int('site_id')
    args = (start_date, finish_date, site_id, typ, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #21
0
def do_get(sess):
    months = req_int('months')
    finish_year = req_int('finish_year')
    finish_month = req_int('finish_month')

    finish_date = Datetime(finish_year, finish_month, 1, tzinfo=pytz.utc) + \
        relativedelta(months=1) - HH
    start_date = finish_date + HH - relativedelta(months=months)

    file_name = "site_hh_data_" + start_date.strftime("%Y%m%d%H%M") + ".csv"
    typ = req_str('type')
    site_id = req_int('site_id')
    return send_response(
        content, args=(start_date, finish_date, site_id, typ, sess),
        file_name=file_name)
Beispiel #22
0
def do_get(sess):
    start_date = req_date('start')
    finish_date = req_date('finish')
    contract_id = req_int('mop_contract_id')
    args = (start_date, finish_date, contract_id, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #23
0
def do_post(sess):
    start_date = req_date('start')
    finish_date = req_date('finish')
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None

    if 'mpan_cores' in request.values:
        mpan_cores_str = req_str('mpan_cores')
        mpan_cores = mpan_cores_str.splitlines()
        if len(mpan_cores) == 0:
            mpan_cores = None
        else:
            for i in range(len(mpan_cores)):
                mpan_cores[i] = parse_mpan_core(mpan_cores[i])
    else:
        mpan_cores = None

    if finish_date < start_date:
        raise BadRequest("The finish date can't be before the start date.")

    is_zipped = req_bool('is_zipped')
    user = g.user

    threading.Thread(
        target=content, args=(
            start_date, finish_date, supply_id, mpan_cores, is_zipped, user)
        ).start()
    return chellow_redirect("/downloads", 303)
Beispiel #24
0
def do_get(session):
    user = g.user
    date = req_date('date')
    if 'supply_id' in request.values:
        supply_id = req_int('supply_id')
    else:
        supply_id = None

    if 'mpan_cores' in request.values:
        mpan_cores_str = req_str('mpan_cores')
        mpan_cores = mpan_cores_str.splitlines()
        if len(mpan_cores) == 0:
            mpan_cores = None
        else:
            for i in range(len(mpan_cores)):
                mpan_cores[i] = parse_mpan_core(mpan_cores[i])
    else:
        mpan_cores = None

    running_name, finished_name = chellow.dloads.make_names(
        'supplies_snapshot.csv', user)

    args = (running_name, finished_name, date, supply_id, mpan_cores)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #25
0
def do_post(sess):
    start_date = req_date("start")
    finish_date = req_date("finish")
    supply_id = req_int("supply_id") if "supply_id" in request.values else None

    if "mpan_cores" in request.values:
        mpan_cores_str = req_str("mpan_cores")
        mpan_cores = mpan_cores_str.splitlines()
        if len(mpan_cores) == 0:
            mpan_cores = None
        else:
            for i in range(len(mpan_cores)):
                mpan_cores[i] = parse_mpan_core(mpan_cores[i])
    else:
        mpan_cores = None

    if finish_date < start_date:
        raise BadRequest("The finish date can't be before the start date.")

    is_zipped = req_bool("is_zipped")
    user = g.user

    threading.Thread(
        target=content,
        args=(start_date, finish_date, supply_id, mpan_cores, is_zipped, user),
    ).start()
    return chellow_redirect("/downloads", 303)
Beispiel #26
0
def do_get(sess):
    start_date = req_date('start')
    finish_date = req_date('finish')
    site_id = req_int('site_id') if 'site_id' in request.values else None
    args = (start_date, finish_date, site_id, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #27
0
def do_get(sess):
    months = req_int("months")
    finish_year = req_int("finish_year")
    finish_month = req_int("finish_month")

    month_list = list(
        c_months_u(finish_year=finish_year,
                   finish_month=finish_month,
                   months=months))
    start_date, finish_date = month_list[0][0], month_list[-1][-1]

    typ = req_str("type")
    site_id = req_int("site_id")
    args = (start_date, finish_date, site_id, typ, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #28
0
def do_get(sess):
    start_date = req_date('start')
    finish_date = req_date('finish')
    contract_id = req_int('mop_contract_id')
    return send_response(
        content, args=(start_date, finish_date, contract_id, sess),
        file_name='output.csv')
Beispiel #29
0
def do_get(sess):
    start_date = req_date("start")
    finish_date = req_date("finish")
    contract_id = req_int("mop_contract_id")
    args = (start_date, finish_date, contract_id, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #30
0
def do_get(session):
    user = g.user
    date = req_date("date")
    if "supply_id" in request.values:
        supply_id = req_int("supply_id")
    else:
        supply_id = None

    if "mpan_cores" in request.values:
        mpan_cores_str = req_str("mpan_cores")
        mpan_cores = mpan_cores_str.splitlines()
        if len(mpan_cores) == 0:
            mpan_cores = None
        else:
            for i in range(len(mpan_cores)):
                mpan_cores[i] = parse_mpan_core(mpan_cores[i])
    else:
        mpan_cores = None

    running_name, finished_name = chellow.dloads.make_names(
        "supplies_snapshot.csv", user)

    args = (running_name, finished_name, date, supply_id, mpan_cores)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #31
0
def do_get(sess):
    year = req_int("finish_year")
    month = req_int("finish_month")
    months = req_int("months")

    st_id = req_int('site_id') if 'site_id' in request.values else None

    finish_date = Datetime(year, month, 1, tzinfo=pytz.utc) + \
        relativedelta(months=1) - HH
    start_date = Datetime(year, month, 1, tzinfo=pytz.utc) - \
        relativedelta(months=months-1)
    user = g.user
    threading.Thread(
        target=long_process, args=(
            start_date, finish_date, st_id, months, year, month, user)).start()
    return chellow_redirect("/downloads", 303)
Beispiel #32
0
def do_get(sess):
    start_date = req_date('start')
    finish_date = req_date('finish')
    site_id = req_int('site_id') if 'site_id' in request.values else None
    args = (start_date, finish_date, site_id, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #33
0
def do_get(sess):
    supply_id = req_int('supply_id')
    months = req_int('months')
    finish_year = req_int("finish_year")
    finish_month = req_int("finish_month")
    supply = Supply.get_by_id(sess, supply_id)

    finish_date = Datetime(finish_year, finish_month, 1, tzinfo=pytz.utc) + \
        relativedelta(months=1) - HH
    start_date = Datetime(finish_year, finish_month, 1, tzinfo=pytz.utc) - \
        relativedelta(months=months-1)

    era = sess.query(Era).filter(
        Era.supply == supply, Era.start_date <= finish_date,
        or_(
            Era.finish_date == null(),
            Era.finish_date >= start_date)).order_by(
        Era.start_date.desc()).first()

    keys = {
        True: {
            'ACTIVE': 'import_active',
            'REACTIVE_IMP': 'import_reactive_imp',
            'REACTIVE_EXP': 'import_reactive_exp'},
        False: {
            'ACTIVE': 'export_active',
            'REACTIVE_IMP': 'export_reactive_imp',
            'REACTIVE_EXP': 'export_reactive_exp'}}

    hh_data = iter(sess.query(HhDatum).join(Channel).join(Era).filter(
        Era.supply == supply, HhDatum.start_date >= start_date,
        HhDatum.start_date <= finish_date).order_by(
        HhDatum.start_date))
    hh_lines = []

    hh_date = start_date
    hh_datum = next(hh_data, None)
    while hh_date <= finish_date:
        hh_line = {'timestamp': hh_date}
        hh_lines.append(hh_line)
        while hh_datum is not None and hh_datum.start_date == hh_date:
            channel = hh_datum.channel
            hh_line[keys[channel.imp_related][channel.channel_type]] = hh_datum
            hh_datum = next(hh_data, None)
        hh_date += HH
    return render_template(
        'report_17.html', supply=supply, era=era, hh_lines=hh_lines)
Beispiel #34
0
def do_get(sess):
    start_date = req_hh_date('start')
    finish_date = req_hh_date('finish')
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    thread = threading.Thread(
        target=content, args=(supply_id, start_date, finish_date, g.user))
    thread.start()
    return chellow_redirect("/downloads", 303)
Beispiel #35
0
def do_get(sess):
    supply_id = req_int('supply_id')
    start_date = req_date('start')
    finish_date = req_date('finish')

    args = supply_id, start_date, finish_date, g.user
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #36
0
def do_get(sess):
    supply_id = req_int('supply_id')
    start_date = req_date('start')
    finish_date = req_date('finish')
    file_name = 'supply_virtual_bills_hh_' + str(supply_id) + '.csv'
    return send_response(
        content, args=(supply_id, start_date, finish_date, sess),
        file_name=file_name)
Beispiel #37
0
def do_get(sess):
    g_supply_id = req_int('g_supply_id')
    start_date = req_date('start')
    finish_date = req_date('finish')

    args = g_supply_id, start_date, finish_date, g.user
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #38
0
def do_get(sess):
    supply_id = req_int("supply_id")
    start_date = req_date("start")
    finish_date = req_date("finish")

    args = supply_id, start_date, finish_date, g.user
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #39
0
def do_get(sess):
    start_date = req_hh_date('start')
    finish_date = req_hh_date('finish')
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    thread = threading.Thread(
        target=content, args=(supply_id, start_date, finish_date, g.user))
    thread.start()
    return chellow_redirect("/downloads", 303)
Beispiel #40
0
def do_post(session):
    user = g.user
    file_item = request.files["dno_file"]
    gsp_group_id = req_int("gsp_group_id")

    args = user, file_item.filename, BytesIO(file_item.read()), gsp_group_id
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #41
0
def do_get(sess):
    batch_id = bill_id = contract_id = start_date = finish_date = None
    if "mpan_cores" in request.values:
        mpan_cores = req_str("mpan_cores").splitlines()
    else:
        mpan_cores = []

    fname_additional = ""

    if "batch_id" in request.values:
        batch_id = req_int("batch_id")
        batch = Batch.get_by_id(sess, batch_id)
        fname_additional = f"_batch_{batch.reference}"
    elif "bill_id" in request.values:
        bill_id = req_int("bill_id")
        bill = Bill.get_by_id(sess, bill_id)
        fname_additional = "bill_" + str(bill.id)
    elif "contract_id" in request.values:
        contract_id = req_int("contract_id")
        contract = Contract.get_by_id(sess, contract_id)

        start_date = req_date("start_date")
        finish_date = req_date("finish_date")

        s = ["contract", str(contract.id)]
        for dt in (start_date, finish_date):
            s.append(hh_format(dt).replace(" ", "T").replace(":", ""))
        fname_additional = "_".join(s)
    else:
        raise BadRequest(
            "The bill check needs a batch_id, a bill_id or a start_date "
            "and finish_date.")

    args = (
        batch_id,
        bill_id,
        contract_id,
        start_date,
        finish_date,
        g.user,
        mpan_cores,
        fname_additional,
    )
    print(args)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #42
0
def handle_request(mpan_cores=None):
    start_year = req_int("start_year")
    start_month = req_int("start_month")
    start_day = req_int("start_day")
    start_date_ct = ct_datetime(start_year, start_month, start_day)

    finish_year = req_int("finish_year")
    finish_month = req_int("finish_month")
    finish_day = req_int("finish_day")
    finish_date_ct = ct_datetime(finish_year, finish_month, finish_day, 23, 30)

    imp_related = req_bool("imp_related")
    channel_type = req_str("channel_type")
    is_zipped = req_bool("is_zipped")
    supply_id = req_int("supply_id") if "supply_id" in request.values else None
    user = g.user
    args = (
        start_date_ct,
        finish_date_ct,
        imp_related,
        channel_type,
        is_zipped,
        supply_id,
        mpan_cores,
        user,
    )
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #43
0
def do_get(sess):
    start_year = req_int("start_year")
    start_month = req_int("start_month")
    start_day = req_int("start_day")

    finish_year = req_int("finish_year")
    finish_month = req_int("finish_month")
    finish_day = req_int("finish_day")

    is_import = req_bool("is_import")
    supply_id = req_int("supply_id")

    threading.Thread(
        target=content,
        args=(
            start_year,
            start_month,
            start_day,
            finish_year,
            finish_month,
            finish_day,
            is_import,
            supply_id,
            g.user,
        ),
    ).start()
    return chellow_redirect("/downloads", 303)
def do_get(sess):
    start_date = req_date('start')
    finish_date = req_date('finish')
    g_contract_id = req_int('g_contract_id')

    threading.Thread(target=content,
                     args=(start_date, finish_date, g_contract_id,
                           g.user)).start()
    return chellow_redirect("/downloads", 303)
Beispiel #45
0
def do_get(sess):
    supply_id = req_int('supply_id')
    file_name = 'supply_virtual_bills_' + str(supply_id) + '.csv'
    start_date = req_date('start')
    finish_date = req_date('finish')
    args = (supply_id, file_name, start_date, finish_date, g.user)

    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #46
0
def do_get(sess):
    batch_id = bill_id = contract_id = start_date = finish_date = None
    if 'batch_id' in request.values:
        batch_id = req_int("batch_id")
    elif 'bill_id' in request.values:
        bill_id = req_int("bill_id")
    elif 'contract_id' in request.values:
        contract_id = req_int("contract_id")
        start_date = req_date("start_date")
        finish_date = req_date("finish_date")
    else:
        raise BadRequest(
            "The bill check needs a batch_id, a bill_id or a start_date "
            "and finish_date.")

    args = batch_id, bill_id, contract_id, start_date, finish_date, g.user
    threading.Thread(target=content, args=args).start()
    return chellow_redirect('/downloads', 303)
Beispiel #47
0
def do_get(sess):
    supply_id = req_int("supply_id")
    file_name = "supply_virtual_bills_" + str(supply_id) + ".csv"
    start_date = req_date("start")
    finish_date = req_date("finish")
    args = (supply_id, file_name, start_date, finish_date, g.user)

    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #48
0
def do_get(sess):
    g_supply_id = req_int('g_supply_id')
    file_name = 'g_supply_virtual_bill_' + str(g_supply_id) + '.csv'
    start_date = req_date('start')
    finish_date = req_date('finish')
    args = (g_supply_id, file_name, start_date, finish_date, g.user)

    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #49
0
def do_get(sess):
    start_date = req_date("start")
    finish_date = req_date("finish")
    if "site_id" in request.values:
        site_id = req_int("site_id")
    else:
        site_id = None

    args = (sess, start_date, finish_date, site_id, g.user)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #50
0
def handle_request(mpan_cores=None):
    start_date = req_date('start')
    finish_date = req_date('finish')
    imp_related = req_bool('imp_related')
    channel_type = req_str('channel_type')
    is_zipped = req_bool('is_zipped')
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    user = g.user
    threading.Thread(target=content,
                     args=(start_date, finish_date, imp_related, channel_type,
                           is_zipped, supply_id, mpan_cores, user)).start()
    return chellow_redirect("/downloads", 303)
Beispiel #51
0
def do_get(sess):

    base_name = []

    if 'scenario_id' in request.values:
        scenario_id = req_int('scenario_id')
        scenario_props = None
    else:
        year = req_int("finish_year")
        month = req_int("finish_month")
        months = req_int("months")
        start_date = Datetime(year, month, 1) - \
            relativedelta(months=months - 1)
        scenario_props = {
            'scenario_start': start_date, 'scenario_duration': months}
        scenario_id = None
        base_name.append('unified_supplies_monthly_duration')

    site_id = req_int('site_id') if 'site_id' in request.values else None
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    user = g.user

    threading.Thread(
        target=content, args=(
            scenario_props, scenario_id, base_name, site_id, supply_id,
            user)).start()
    return chellow_redirect("/downloads", 303)
Beispiel #52
0
def do_get(sess):

    base_name = []

    if 'scenario_id' in request.values:
        scenario_id = req_int('scenario_id')
        scenario_props = None
    else:
        year = req_int("finish_year")
        month = req_int("finish_month")
        months = req_int("months")
        start_date = Datetime(year, month, 1) - \
            relativedelta(months=months - 1)
        scenario_props = {
            'scenario_start': start_date,
            'scenario_duration': months
        }
        scenario_id = None
        base_name.append('monthly_duration')

    site_id = req_int('site_id') if 'site_id' in request.values else None
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    if 'compression' in request.values:
        compression = req_bool('compression')
    else:
        compression = True
    user = g.user

    threading.Thread(target=content,
                     args=(scenario_props, scenario_id, base_name, site_id,
                           supply_id, user, compression)).start()
    return chellow_redirect("/downloads", 303)
Beispiel #53
0
def handle_request(mpan_cores=None):
    start_date = req_date('start')
    finish_date = req_date('finish')
    imp_related = req_bool('imp_related')
    channel_type = req_str('channel_type')
    is_zipped = req_bool('is_zipped')
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    user = g.user
    threading.Thread(
        target=content, args=(
            start_date, finish_date, imp_related, channel_type, is_zipped,
            supply_id, mpan_cores, user)).start()
    return chellow_redirect("/downloads", 303)
def do_get(sess):
    finish_year = req_int("finish_year")
    finish_month = req_int("finish_month")
    months = req_int("months")

    site_id = req_int("site_id") if "site_id" in request.values else None

    if "g_supply_id" in request.values:
        g_supply_id = req_int("g_supply_id")
    else:
        g_supply_id = None

    if "compression" in request.values:
        compression = req_bool("compression")
    else:
        compression = True

    user = g.user
    args = (site_id, g_supply_id, user, compression, finish_year, finish_month,
            months)

    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #55
0
def do_get(sess):
    start_date = req_date('start', 'day')
    finish_date = req_date('finish', 'day')
    finish_date = finish_date + relativedelta(days=1) - HH

    if 'site_id' in request.values:
        site_id = req_int('site_id')
        file_name = "sites_hh_data_" + str(site_id) + "_" + \
            finish_date.strftime('%Y%m%d%H%M') + ".csv"
    else:
        site_id = None
        file_name = "supplies_hh_data_" + \
            finish_date.strftime('%Y%m%d%H%M') + ".zip"

    content = none_content if site_id is None else site_content
    args = (site_id, start_date, finish_date, g.user, file_name)
    threading.Thread(target=content, args=args).start()
    return chellow_redirect("/downloads", 303)
Beispiel #56
0
def do_get(sess):
    start_year = req_int('start_year')
    start_month = req_int('start_month')
    start_day = req_int("start_day")

    finish_year = req_int('finish_year')
    finish_month = req_int('finish_month')
    finish_day = req_int('finish_day')

    is_import = req_bool('is_import')
    supply_id = req_int('supply_id')

    return send_response(
        content, args=(
            start_year, start_month, start_day, finish_year, finish_month,
            finish_day, is_import, supply_id, sess),
        file_name='daily_supplier_virtual_bill.csv')
Beispiel #57
0
def do_get(sess):
    year = req_int('year')
    supply_id = req_int('supply_id') if 'supply_id' in request.values else None
    return send_response(
        content, args=(year, supply_id, sess), file_name='supplies_triad.csv')
Beispiel #58
0
def do_get(sess):
    site_id = req_int('site_id') if 'site_id' in request.values else None
    year = req_int('year')
    return send_response(
        content, args=(year, site_id, sess), file_name='output.csv')
Beispiel #59
0
def do_get(sess):
    site_id = req_int('site_id') if 'site_id' in request.values else None
    year = req_int('year')
    threading.Thread(target=content, args=(year, site_id, g.user)).start()
    return chellow_redirect("/downloads", 303)