Esempio n. 1
0
def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.basicConfig(format='[%(asctime)s] [%(levelname)s] %(message)s',
                        level=logging.DEBUG)
    status_code = 200
    try:
        log.info(f"Http trigger. req.params: {req.params}")
        get_change_report(date=datetime.datetime.strptime(
            get_req_param(req, 'date', default=DEFAULT_DAY), DAY_FORMAT))
        return func.HttpResponse(
            '{"output":"This HTTP triggered function executed."}',
            status_code=status_code)
    except Exception as ex:
        log.error(f'Exception {ex}')
        status_code = 500
        return func.HttpResponse(
            f"Exception {ex}"
            f"{''.join(tb.format_exception(etype=type(ex), value=ex, tb=ex.__traceback__))}",
            status_code=status_code)
Esempio n. 2
0
def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.basicConfig(format='[%(asctime)s] [%(levelname)s] %(message)s',
                        level=logging.DEBUG)
    status_code = 200
    try:
        log.info(f"Http trigger. req.params: {req.params}")
        day = datetime.datetime.strptime(
            get_req_param(req, 'date', default=DEFAULT_DAY), DAY_FORMAT)
        process_github_daily_push_events(day=day)
        return func.HttpResponse(
            '{"output":"This HTTP triggered function executed."}',
            status_code=status_code)
    except Exception as ex:
        ex_message = (
            f'Exception {ex} \n'
            f'{"".join(tb.format_exception(etype=type(ex), value=ex, tb=ex.__traceback__))}'
        )
        log.error(ex_message)
        return func.HttpResponse(ex_message, status_code=500)
Esempio n. 3
0
def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.basicConfig(format='[%(asctime)s] [%(levelname)s] %(message)s',
                        level=logging.DEBUG)
    try:
        log.info(f"Http trigger. req.params: {req.params}")

        date = datetime.datetime.strptime(
            get_req_param(req, 'date', default=DEFAULT_DAY), DAY_FORMAT)
        table = load_osci_ranking_to_bq(date=date)

        return func.HttpResponse(
            f"{table.num_rows} and {len(table.schema)} in "
            f"table {BigQueryOSCIRankingReport.table_id}.")
    except Exception as ex:
        log.error(f'Exception {ex}')
        log.exception(ex)
        return func.HttpResponse(
            f"This HTTP triggered function failed {ex} "
            f"{''.join(tb.format_exception(etype=type(ex), value=ex, tb=ex.__traceback__))}",
            status_code=500)