def run_report_with_data_blob(report_config: reportConfig, data: dataBlob):
    """

    :param report_config:
    :return:
    """

    data.log.msg("Running report %s" % str(report_config))
    report_function = resolve_function(report_config.function)
    report_kwargs = report_config.kwargs

    report_results = report_function(data, **report_kwargs)
    parsed_report = parse_report_results(report_results)
    output = report_config.output

    # We either print or email
    if output == "console":
        print(parsed_report)
    elif output == "email":
        send_production_mail_msg(data,
                                 parsed_report,
                                 subject=report_config.title,
                                 email_is_report=True)
    elif output == "file":
        filename_with_spaces = report_config.title
        filename = filename_with_spaces.replace(" ", "_")
        write_report_to_file(data, parsed_report, filename=filename)
    else:
        raise Exception("Report config %s not recognised!" % output)
예제 #2
0
    def email_user(self, log_entry: logEntry):
        data = self.data
        subject_line = str(log_entry.attributes)+ ": "+ \
            str(log_entry.text)

        log_entry_text = str(log_entry)
        send_production_mail_msg(data, log_entry_text,
                                 "*CRITICAL* ERROR: %s" % subject_line)
예제 #3
0
def report_fx_data_spike(data: dataBlob, fx_code: str):
    msg = (
        "Spike found in prices for %s: need to manually check by running interactive_manual_check_fx_prices"
        % str(fx_code))
    data.log.warn(msg)
    try:
        send_production_mail_msg(data, msg, "FX Price Spike %s" % str(fx_code))
    except BaseException:
        data.log.warn("Couldn't send email about price spike")
def report_price_spike(data: dataBlob, contract_object: futuresContract):
    # SPIKE
    # Need to email user about this as will need manually checking
    msg = (
        "Spike found in prices for %s: need to manually check by running interactive_manual_check_historical_prices"
        % str(contract_object))
    data.log.warn(msg)
    try:
        send_production_mail_msg(
            data, msg, "Price Spike %s" % contract_object.instrument_code)
    except BaseException:
        data.log.warn("Couldn't send email about price spike for %s" %
                      str(contract_object))
예제 #5
0
def email_report(parsed_report: ParsedReport,
                 report_config: reportConfig,
                 data: dataBlob):

    if parsed_report.contains_pdf:
        send_production_mail_msg_attachment(body = "Report attached",
                                            subject = report_config.title,
                                            filename= parsed_report.pdf_filename)
    else:
        send_production_mail_msg(
            data =data,
            body=parsed_report.text,
            subject=report_config.title,
            email_is_report=True
        )
예제 #6
0
def run_report_with_data_blob(report_config: reportConfig,
                              data: dataBlob):
    """

    :param report_config:
    :return:
    """

    data.log.msg("Running report %s" % str(report_config))
    report_function = resolve_function(report_config.function)
    report_kwargs = report_config.kwargs

    report_results = report_function(data, **report_kwargs)
    parsed_report = parse_report_results(report_results)

    # We either print or email
    if report_config.output is "console":
        print(parsed_report)
    elif report_config.output is "email":
        send_production_mail_msg(
            data, parsed_report, subject=report_config.title, email_is_report=True
        )
예제 #7
0
def run_report_with_data_blob(report_config, data):
    """

    :param report_config:
    :return:
    """

    data.log.msg("Running report %s" % str(report_config))
    report_function = resolve_function(report_config.function)
    report_kwargs = report_config.kwargs

    try:
        report_results = report_function(data, **report_kwargs)
        report_result = success
    except Exception as e:
        report_results = [
            header(
                "Report %s failed to process with error %s" %
                (report_config.title, e))]
        report_result = failure
    try:
        parsed_report = parse_report_results(report_results)
    except Exception as e:
        parsed_report = "Report failed to parse %s with error %s\n" % (
            report_config.title,
            str(e),
        )
        report_result = failure

    # We either print or email
    if report_config.output is "console":
        print(parsed_report)
    elif report_config.output is "email":
        send_production_mail_msg(
            data, parsed_report, subject=report_config.title, email_is_report=True
        )

    return report_result
예제 #8
0
 def email_user(self, log_entry):
     data = self.data
     send_production_mail_msg(data, str(log_entry), "*CRITICAL ERROR*")
예제 #9
0
def email_report(parsed_report, report_config, data):
    send_production_mail_msg(data,
                             parsed_report,
                             subject=report_config.title,
                             email_is_report=True)