def _log(level, msg):
    if not level or not msg:
        prof.cons_bad_cmd_usage("/python-test")
        return

    if level == "debug":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.log_debug(msg)
        prof.win_show(plugin_win, "called -> prof.log_debug: " + msg)
    elif level == "info":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.log_info(msg)
        prof.win_show(plugin_win, "called -> prof.log_info: " + msg)
    elif level == "warning":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.log_warning(msg)
        prof.win_show(plugin_win, "called -> prof.log_warning: " + msg)
    elif level == "error":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.log_error(msg)
        prof.win_show(plugin_win, "called -> prof.log_error: " + msg)
    else:
        prof.cons_bad_cmd_usage("/python-test")
示例#2
0
def _build_job(job):
    try:
        request = urllib2.Request(jenkins_url + "/job/" + job + "/build");
        if username:
            basicauth = base64.encodestring("%s:%s" %(username, password)).replace("\n", "")
            request.add_header("Authorization", "Basic %s" %basicauth);
            request.add_data("")
        urllib2.urlopen(request)
    except Exception, e:
        prof.win_show(win_tag, "Failed to build " + job + ", see the logs.")
        prof.log_warning("Failed to build " + job + ": " + str(e))
示例#3
0
def _build_job(job):
    try:
        request = urllib2.Request(jenkins_url + "/job/" + job + "/build")
        if username:
            basicauth = base64.encodestring(
                "%s:%s" % (username, password)).replace("\n", "")
            request.add_header("Authorization", "Basic %s" % basicauth)
            request.add_data("")
        urllib2.urlopen(request)
    except Exception, e:
        prof.win_show(win_tag, "Failed to build " + job + ", see the logs.")
        prof.log_warning("Failed to build " + job + ": " + str(e))
示例#4
0
def _job_log(job):
    name = job[0]
    build_no = job[1]
    if build_no:
        try:
            response = urllib2.urlopen(jenkins_url + "/job/" + name + "/" + str(build_no) + "/consoleText")
        except Exception, e:
            prof.win_show(win_tag, "Unable to fetch log for " + name + "#" + str(build_no) + ", see the logs.")
            prof.log_warning("Unable to fetch log for " + name + "#" + str(build_no) + ": " + str(e))
        else:
            log_str = "Log for " + name + " #" + str(build_no) + ":\n" + response.read()
            prof.win_show(win_tag, log_str)
示例#5
0
def _prof_callback():
    global changes_list
    if poll_fail:
        if not prof.win_exists(win_tag):
            prof.win_create(win_tag, _handle_input)
        prof.win_show(win_tag, "Could not connect to jenkins, see the logs.")
        if poll_fail_message:
            prof.log_warning("Jenkins poll failed: " + str(poll_fail_message))
        else:
            prof.log_warning("Jenkins poll failed")
    elif changes_list:
        for name in changes_list.get_in_state(STATE_QUEUED):
            if not prof.win_exists(win_tag):
                prof.win_create(win_tag, _handle_input)
            prof.win_show_themed(win_tag, None, None, "cyan",
                                 name + " " + STATE_QUEUED)
        for name in changes_list.get_in_state(STATE_RUNNING):
            if not prof.win_exists(win_tag):
                prof.win_create(win_tag, _handle_input)
            prof.win_show_themed(win_tag, None, None, "cyan",
                                 name + " " + STATE_RUNNING)
        for name, build_number in changes_list.get_in_state(STATE_SUCCESS):
            if not prof.win_exists(win_tag):
                prof.win_create(win_tag, _handle_input)
            prof.win_show_themed(
                win_tag, None, None, "green",
                name + " #" + str(build_number) + " " + STATE_SUCCESS)
            if enable_notify:
                prof.notify(name + " " + STATE_SUCCESS, 5000, "Jenkins")
        for name, build_number in changes_list.get_in_state(STATE_UNSTABLE):
            if not prof.win_exists(win_tag):
                prof.win_create(win_tag, _handle_input)
            prof.win_show_themed(
                win_tag, None, None, "yellow",
                name + " #" + str(build_number) + " " + STATE_UNSTABLE)
            if enable_notify:
                prof.notify(name + " " + STATE_UNSTABLE, 5000, "Jenkins")
        for name, build_number in changes_list.get_in_state(STATE_FAILURE):
            if not prof.win_exists(win_tag):
                prof.win_create(win_tag, _handle_input)
            prof.win_show_themed(
                win_tag, None, None, "red",
                name + " #" + str(build_number) + " " + STATE_FAILURE)
            if enable_notify:
                prof.notify(name + " " + STATE_FAILURE, 5000, "Jenkins")

        changes_list = None
示例#6
0
def _job_log(job):
    name = job[0]
    build_no = job[1]
    if build_no:
        try:
            response = urllib2.urlopen(jenkins_url + "/job/" + name + "/" +
                                       str(build_no) + "/consoleText")
        except Exception, e:
            prof.win_show(
                win_tag, "Unable to fetch log for " + name + "#" +
                str(build_no) + ", see the logs.")
            prof.log_warning("Unable to fetch log for " + name + "#" +
                             str(build_no) + ": " + str(e))
        else:
            log_str = "Log for " + name + " #" + str(
                build_no) + ":\n" + response.read()
            prof.win_show(win_tag, log_str)
示例#7
0
def _prof_callback():
    global changes_list
    if poll_fail:
        if not prof.win_exists(win_tag):
            prof.win_create(win_tag, _handle_input)
        prof.win_show(win_tag, "Could not connect to jenkins, see the logs.")
        if poll_fail_message:
            prof.log_warning("Jenkins poll failed: " + str(poll_fail_message))
        else:
            prof.log_warning("Jenkins poll failed")
    elif changes_list:
        for name in changes_list.get_in_state(STATE_QUEUED):
            if not prof.win_exists(win_tag):
                prof.win_create(win_tag, _handle_input)
            prof.win_show_themed(win_tag, None, None, "cyan", name + " " + STATE_QUEUED)
        for name in changes_list.get_in_state(STATE_RUNNING):
            if not prof.win_exists(win_tag):
                prof.win_create(win_tag, _handle_input)
            prof.win_show_themed(win_tag, None, None, "cyan", name + " " + STATE_RUNNING)
        for name, build_number in changes_list.get_in_state(STATE_SUCCESS):
            if not prof.win_exists(win_tag):
                prof.win_create(win_tag, _handle_input)
            prof.win_show_themed(win_tag, None, None, "green", name + " #" + str(build_number) + " " + STATE_SUCCESS)
            if enable_notify:
                prof.notify(name + " " + STATE_SUCCESS, 5000, "Jenkins")
        for name, build_number in changes_list.get_in_state(STATE_UNSTABLE):
            if not prof.win_exists(win_tag):
                prof.win_create(win_tag, _handle_input)
            prof.win_show_themed(win_tag, None, None, "yellow", name + " #" + str(build_number) + " " + STATE_UNSTABLE)
            if enable_notify:
                prof.notify(name + " " + STATE_UNSTABLE, 5000, "Jenkins")
        for name, build_number in changes_list.get_in_state(STATE_FAILURE):
            if not prof.win_exists(win_tag):
                prof.win_create(win_tag, _handle_input)
            prof.win_show_themed(win_tag, None, None, "red", name + " #" + str(build_number) + " " + STATE_FAILURE)
            if enable_notify:
                prof.notify(name + " " + STATE_FAILURE, 5000, "Jenkins")

        changes_list = None
def cmd_pythontest(arg1=None, arg2=None, arg3=None, arg4=None, arg5=None):
    if arg1 == "consalert":
        create_win()
        prof.win_focus(plugin_win)
        prof.cons_alert()
        prof.win_show(plugin_win, "called -> prof.cons_alert")
    elif arg1 == "consshow":
        if arg2 != None:
            create_win()
            prof.win_focus(plugin_win)
            prof.cons_show(arg2)
            prof.win_show(plugin_win, "called -> prof.cons_show: " + arg2)
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "consshow_t":
        if arg2 == None or arg3 == None or arg4 == None or arg5 == None:
            prof.cons_bad_cmd_usage("/python-test");
        else:
            group = None if arg2 == "none" else arg2
            key = None if arg3 == "none" else arg3
            dflt = None if arg4 == "none" else arg4
            message = arg5
            create_win()
            prof.win_focus(plugin_win)
            prof.cons_show_themed(group, key, dflt, message)
            prof.win_show(plugin_win, "called -> prof.cons_show_themed: " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5)
    elif arg1 == "constest":
        res = prof.current_win_is_console()
        create_win()
        prof.win_focus(plugin_win)
        if res:
            prof.win_show(plugin_win, "called -> prof.current_win_is_console: true")
        else:
            prof.win_show(plugin_win, "called -> prof.current_win_is_console: false")
    elif arg1 == "winshow":
        if arg2 != None:
            create_win()
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win, arg2)
            prof.win_show(plugin_win, "called -> prof.win_show: " + arg2)
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "winshow_t":
        if arg2 == None or arg3 == None or arg4 == None or arg5 == None:
            prof.cons_bad_cmd_usage("/python-test");
        else:
            group = None if arg2 == "none" else arg2
            key = None if arg3 == "none" else arg3
            dflt = None if arg4 == "none" else arg4
            message = arg5
            create_win()
            prof.win_focus(plugin_win)
            prof.win_show_themed(plugin_win, group, key, dflt, message)
            prof.win_show(plugin_win, "called -> prof_win_show_themed: " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5)
    elif arg1 == "sendline":
        if arg2 != None:
            create_win()
            prof.win_focus(plugin_win)
            prof.send_line(arg2)
            prof.win_show(plugin_win, "called -> prof.send_line: " + arg2)
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "notify":
        if arg2 != None:
            create_win()
            prof.win_focus(plugin_win)
            prof.notify(arg2, 5000, "python-test plugin")
            prof.win_show(plugin_win, "called -> prof.notify: " + arg2)
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "get":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/python-test")
        elif arg2 == "recipient":
            create_win()
            recipient = prof.get_current_recipient();
            if recipient != None:
                prof.win_focus(plugin_win)
                prof.win_show(plugin_win, "called -> prof.get_current_recipient: " + recipient)
            else:
                prof.win_focus(plugin_win)
                prof.win_show(plugin_win, "called -> prof_get_current_recipient: <none>")
        elif arg2 == "room":
            create_win()
            room = prof.get_current_muc()
            if room != None:
                prof.win_focus(plugin_win)
                prof.win_show(plugin_win, "called -> prof_get_current_muc: " + room)
            else:
                prof.win_focus(plugin_win)
                prof.win_show(plugin_win, "called -> prof_get_current_muc: <none>")
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "log":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/python-test")
        elif arg2 == "debug":
            if arg3 == None:
                prof.cons_bad_cmd_usage("/python-test")
            else:
                create_win()
                prof.win_focus(plugin_win)
                prof.log_debug(arg3)
                prof.win_show(plugin_win, "called -> prof.log_debug: " + arg3)
        elif arg2 == "info":
            if arg3 == None:
                prof.cons_bad_cmd_usage("/python-test")
            else:
                create_win()
                prof.win_focus(plugin_win)
                prof.log_info(arg3)
                prof.win_show(plugin_win, "called -> prof.log_info: " + arg3)
        elif arg2 == "warning":
            if arg3 == None:
                prof.cons_bad_cmd_usage("/python-test")
            else:
                create_win()
                prof.win_focus(plugin_win)
                prof.log_warning(arg3)
                prof.win_show(plugin_win, "called -> prof.log_warning: " + arg3)
        elif arg2 == "error":
            if arg3 == None:
                prof.cons_bad_cmd_usage("/python-test")
            else:
                create_win()
                prof.win_focus(plugin_win)
                prof.log_error(arg3)
                prof.win_show(plugin_win, "called -> prof.log_error: " + arg3)
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "count":
        create_win()
        prof.win_focus(plugin_win)
        prof.win_show(plugin_win, "Count: " + str(count))
    else:
        prof.cons_bad_cmd_usage("/python-test")
示例#9
0
def prof_on_start():
    prof.cons_show("python-test: on_start")
    prof.log_debug("python-test: logged debug")
    prof.log_info("python-test: logged info")
    prof.log_warning("python-test: logged warning")
    prof.log_error("python-test: logged error")