Beispiel #1
0
def process_exception(ex):
    if settings.SEND_EX_TO_SLACK:
        slack_msg = SlackMessenger(settings.USE_THIS_SLACK_CONFIG)
        slack_msg.handle_send_slack_internal_ex(ex)
        lg("Sent Slack Message", 0)
    else:
        lg("Hit Exception(" + str(ex) + ")", 0)
    return None
def process_exception(ex):
    if settings.SEND_EX_TO_SLACK:
        slack_msg = SlackMessenger(settings.USE_THIS_SLACK_CONFIG)
        slack_msg.handle_send_slack_internal_ex(ex)
        lg("Sent Slack Message", 0)
    else:
        lg("Hit Exception(" + str(ex) + ")", 0)
    return None
def handle_ajax_post(request):

    status      = "Display Error"
    err_msg     = "Failed to Process Post" 
    record      = {
                    "StatusDiv" : "",
                    "ResultDiv" : ""
                }
    try:
        posted_hash     = simplejson.loads(request.body)

        if "Action" not in posted_hash:
            status      = "Display Error"
            err_msg     = "Missing 'Action' Key in POST"
        else:
            action      = str(posted_hash["Action"])

            lg("POST - Processing(" + str(action) + ")", 6)

            if action == "AjaxDemo":
                proc_rs = handle_post_ajax_demo(posted_hash)
                status  = str(proc_rs["Status"])
                err_msg = str(proc_rs["Error"])
                record  = proc_rs["Record"]
            # end of AjaxDemo

            else:
                status  = "Display Error"
                err_msg = "Unsupported Ajax Action(" + str(action) + ")"
                lg("ERROR: Failed POST" + str(err_msg), 0)

                # If Slack is enabled, send the unsupported error:
                if settings.SEND_EX_TO_SLACK:
                    slack_msg = SlackMessenger(settings.USE_THIS_SLACK_CONFIG)
                    slack_msg.handle_send_slack_internal_ex(err_msg)
                # end of if send to slack 

            # end of if a supported server-side action

        # end of handling all Posts

        # Assign final results:
        results         = build_def_result(status, err_msg, record)

    except Exception,e:
        results         = build_def_result("Display Error", "Failed to decode Post-ed JSON with Ex(" + str(e) + ")", record)
        lg("ERROR: " + str(e), 0)
        process_exception(e)
Beispiel #4
0
def handle_ajax_post(request):

    status = "Display Error"
    err_msg = "Failed to Process Post"
    record = {"StatusDiv": "", "ResultDiv": ""}
    try:
        posted_hash = simplejson.loads(request.body)

        if "Action" not in posted_hash:
            status = "Display Error"
            err_msg = "Missing 'Action' Key in POST"
        else:
            action = str(posted_hash["Action"])

            lg("POST - Processing(" + str(action) + ")", 6)

            if action == "AjaxDemo":
                proc_rs = handle_post_ajax_demo(posted_hash)
                status = str(proc_rs["Status"])
                err_msg = str(proc_rs["Error"])
                record = proc_rs["Record"]
            # end of AjaxDemo

            else:
                status = "Display Error"
                err_msg = "Unsupported Ajax Action(" + str(action) + ")"
                lg("ERROR: Failed POST" + str(err_msg), 0)

                # If Slack is enabled, send the unsupported error:
                if settings.SEND_EX_TO_SLACK:
                    slack_msg = SlackMessenger(settings.USE_THIS_SLACK_CONFIG)
                    slack_msg.handle_send_slack_internal_ex(err_msg)
                # end of if send to slack

            # end of if a supported server-side action

        # end of handling all Posts

        # Assign final results:
        results = build_def_result(status, err_msg, record)

    except Exception, e:
        results = build_def_result(
            "Display Error",
            "Failed to decode Post-ed JSON with Ex(" + str(e) + ")", record)
        lg("ERROR: " + str(e), 0)
        process_exception(e)
#!/usr/bin/python

from slack_messenger import SlackMessenger

slack_config = {
                "BotName"     : "bugbot",
                "ChannelName" : "debugging",
                "NotifyUser"  : "jay",
                "Token"       : "xoxb-51351043345-oHKTiT5sXqIAlxwYzQspae54",
                "EnvName"     : "LocalDev"
             }

slack_msg = SlackMessenger(slack_config)

try:
    print "Testing an Exception that shows up in Slack"
    testing_how_this_looks_from_slack
except Exception,k:
    print "Sending an error message to Slack for the expected Exception(" + str(k) + ")"
    slack_msg.handle_send_slack_internal_ex(k)
# end of try/ex

print "Done"

#!/usr/bin/python

from slack_messenger import SlackMessenger

slack_config = {
    "BotName": "bugbot",
    "ChannelName": "debugging",
    "NotifyUser": "******",
    "Token": "xoxb-51351043345-oHKTiT5sXqIAlxwYzQspae54",
    "EnvName": "LocalDev"
}

slack_msg = SlackMessenger(slack_config)

try:
    print "Testing an Exception that shows up in Slack"
    testing_how_this_looks_from_slack
except Exception, k:
    print "Sending an error message to Slack for the expected Exception(" + str(
        k) + ")"
    slack_msg.handle_send_slack_internal_ex(k)
# end of try/ex

print "Done"