Ejemplo n.º 1
0
def _cmd_system(arg1=None, arg2=None):
    if not arg1:
        create_win()
        prof.win_focus(system_win)
    elif arg1 == "send":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/system")
        else:
            room = prof.get_current_muc()
            recipient = prof.get_current_recipient()
            if room == None and recipient == None:
                prof.cons_show(
                    "You must be in a chat or muc window to send a system command"
                )
                prof.cons_alert()
            else:
                result = _get_result(arg2)
                prof.send_line(u'\u000A' + result)
    elif arg1 == "exec":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/system")
        else:
            create_win()
            prof.win_focus(system_win)
            _handle_win_input(system_win, arg2)
    else:
        prof.cons_bad_cmd_usage("/system")
Ejemplo n.º 2
0
def _cmd_system(arg1=None, arg2=None):
    if not arg1:
        create_win()
        prof.win_focus(system_win)
    elif arg1 == "send":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/system")
        else:
            room = prof.get_current_muc()
            recipient = prof.get_current_recipient()
            if room == None and recipient == None:
                prof.cons_show("You must be in a chat or muc window to send a system command")
                prof.cons_alert()
            else:
                result = _get_result(arg2)
                prof.send_line(u'\u000A' + result)
    elif arg1 == "exec":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/system")
        else:
            create_win()
            prof.win_focus(system_win)
            _handle_win_input(system_win, arg2)
    else:
        prof.cons_bad_cmd_usage("/system")
Ejemplo n.º 3
0
def _boolean(op, group, key, value_str):
    if op != "get" and op != "set":
        prof.cons_bad_cmd_usage("/python-test")
        return

    if group == None or key == None:
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "set" and value_str != "true" and value_str != "false":
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "get":
        dflt = False
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        res = prof.settings_boolean_get(group, key, dflt)
        if res:
            prof.win_show(plugin_win, "Boolean setting: TRUE")
        else:
            prof.win_show(plugin_win, "Boolean setting: FALSE")
    elif op == "set":
        value = False
        if value_str == "true":
            value = True
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.settings_boolean_set(group, key, value)
        prof.win_show(plugin_win,
                      "Set [" + group + "] " + key + " to " + str(value))
Ejemplo n.º 4
0
def _string(op, group, key, value):
    if op != "get" and op != "set":
        prof.cons_bad_cmd_usage("/python-test")
        return

    if group == None or key == None:
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "set" and not value:
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "get":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        res = prof.settings_string_get(group, key, None)
        if res:
            prof.win_show(plugin_win, "String setting: " + res)
        else:
            prof.win_show(plugin_win, "String setting: None")
    elif op == "set":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.settings_string_set(group, key, value)
        prof.win_show(plugin_win,
                      "Set [" + group + "] " + key + " to " + value)
Ejemplo n.º 5
0
def _handle_exec(command=None):
    if command == None:
        prof.cons_bad_cmd_usage("/system")
        return;

    create_win()
    prof.win_focus(system_win)
    _handle_win_input(system_win, command)
Ejemplo n.º 6
0
def _handle_exec(command=None):
    if command == None:
        prof.cons_bad_cmd_usage("/system")
        return

    create_win()
    prof.win_focus(system_win)
    _handle_win_input(system_win, command)
Ejemplo n.º 7
0
def _notify(msg):
    if not msg:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    prof.notify(msg, 5000, "python-test plugin")
    prof.win_show(plugin_win, "called -> prof.notify: " + msg)
Ejemplo n.º 8
0
def _sendline(line):
    if not line:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    prof.send_line(line)
    prof.win_show(plugin_win, "called -> prof.send_line: " + line)
Ejemplo n.º 9
0
def _cmd_upper(line):
    global _win_tag;
    if prof.win_exists(_win_tag) == False:
        prof.win_create(_win_tag, _handle_upper)

    prof.win_focus(_win_tag)

    if line:
        _handle_upper(_win_tag, line)
Ejemplo n.º 10
0
def _winshow(msg):
    if not msg:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    prof.win_show(plugin_win, msg)
    prof.win_show(plugin_win, "called -> prof.win_show: " + msg)
Ejemplo n.º 11
0
def _constest():
    res = prof.current_win_is_console()
    prof.win_create(plugin_win, _handle_win_input)
    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")
Ejemplo n.º 12
0
def _page(page_str):
    page = wikipedia.page(page_str)
    create_win()
    if not page:
        prof.win_show_themed(win, "wikipedia", "page.nopage", None, "No such page: \"" + page_str + "\"")
        prof.win_show(win, "")
        prof.win_focus(win)
        return

    prof.win_show_themed(win, "wikipedia", "page.title", None, page.title)
    prof.win_show_themed(win, "wikipedia", "page.text", None, page.content)
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 13
0
def _page(page_str):
    page = wikipedia.page(page_str)
    create_win()
    if not page:
        prof.win_show_themed(win, "wikipedia", "page.nopage", None,
                             "No such page: \"" + page_str + "\"")
        prof.win_show(win, "")
        prof.win_focus(win)
        return

    prof.win_show_themed(win, "wikipedia", "page.title", None, page.title)
    prof.win_show_themed(win, "wikipedia", "page.text", None, page.content)
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 14
0
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")
Ejemplo n.º 15
0
def _winshow_t(group, key, dflt, msg):
    if not group or not key or not dflt or not msg:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    groupval = None if group == "none" else group
    keyval = None if key == "none" else key
    dfltval = None if dflt == "none" else dflt
    prof.win_show_themed(plugin_win, groupval, keyval, dfltval, msg)
    prof.win_show(
        plugin_win, "called -> prof_win_show_themed: " + group + ", " + key +
        ", " + dflt + ", " + msg)
Ejemplo n.º 16
0
def _search(search_terms):
    global page_ac

    results = wikipedia.search(search_terms)
    create_win()
    if len(results) > 0:
        prof.win_show_themed(win, "wikipedia", "search", None, "Search results for \"" + search_terms + "\":")
        for index, result in enumerate(results):
            page_ac.append(result)
            prof.win_show_themed(win, "wikipedia", "search.results", None, result)
        _update_autocomplete()
    else:
        prof.win_show_themed(win, "wikipedia", "search.noresults", None, "No search results found for \"" + search_terms + "\"")
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 17
0
def _ping(jid):
    global ping_id

    if not jid:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    res = prof.send_stanza("<iq to='" + jid + "' id='pythonplugin-" +
                           str(ping_id) +
                           "' type='get'><ping xmlns='urn:xmpp:ping'/></iq>")
    ping_id = ping_id + 1
    if res:
        prof.win_show(plugin_win, "Ping sent successfully")
    else:
        prof.win_show(plugin_win, "Error sending ping")
Ejemplo n.º 18
0
def _string_list(op, group, key, value):
    if op != "get" and op != "add" and op != "remove" and op != "remove_all":
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "get":
        if group == None or key == None:
            prof.cons_bad_cmd_usage("/python-test")
            return
        res = prof.settings_string_list_get(group, key)
        prof.win_focus(plugin_win)
        if res is None:
            prof.win_show(plugin_win, "No list found")
            return
        prof.win_show(plugin_win, "String list:")
        for el in res:
            prof.win_show(plugin_win, "  " + el)
        return

    if op == "add":
        if group == None or key == None or value == None:
            prof.cons_bad_cmd_usage("/python-test")
            return
        prof.settings_string_list_add(group, key, value)
        prof.win_focus(plugin_win)
        prof.win_show(plugin_win,
                      "Added '" + value + "' to [" + group + "]" + " " + key)
        return

    if op == "remove":
        if group == None or key == None or value == None:
            prof.cons_bad_cmd_usage("/python-test")
            return
        res = prof.settings_string_list_remove(group, key, value)
        prof.win_focus(plugin_win)
        if res:
            prof.win_show(
                plugin_win,
                "Removed '" + value + "' from [" + group + "]" + " " + key)
        else:
            prof.win_show(plugin_win, "Error removing string item from list")
        return

    if op == "remove_all":
        if group == None or key == None:
            prof.cons_bad_cmd_usage("/python-test")
            return
        res = prof.settings_string_list_clear(group, key)
        prof.win_focus(plugin_win)
        if res:
            prof.win_show(plugin_win,
                          "Removed all items from [" + group + "]" + " " + key)
        else:
            prof.win_show(plugin_win, "Error removing list")
        return
Ejemplo n.º 19
0
def _images(page_str):
    global link_ac

    page = wikipedia.page(page_str)
    create_win()
    if not page:
        prof.win_show_themed(win, "wikipedia", "images.nopage", None, "No such page: \"" + page_str + "\"")
        prof.win_show(win, "")
        prof.win_focus(win)
        return

    prof.win_show_themed(win, "wikipedia", "images", None, "Images for " + page_str)
    for image in page.images:
        prof.win_show_themed(win, "wikipedia", "images.url", None, image)
        link_ac.append(image)
    prof.completer_add("/wikipedia open", link_ac)
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 20
0
def _refs(page_str):
    global link_ac

    page = wikipedia.page(page_str)
    create_win()
    if not page:
        prof.win_show_themed(win, "wikipedia", "refs.nopage", None, "No such page: \"" + page_str + "\"")
        prof.win_show(win, "")
        prof.win_focus(win)
        return

    prof.win_show_themed(win, "wikipedia", "refs", None, "References for " + page_str)
    for ref in page.references:
        prof.win_show_themed(win, "wikipedia", "refs.url", None, ref)
        link_ac.append(ref)
    prof.completer_add("/wikipedia open", link_ac)
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 21
0
def _cmd_clients():
    muc = prof.get_current_muc()
    if muc == None:
        prof.cons_show("Command only valid in chat rooms.")
        return

    occupants = prof.get_current_occupants()
    if occupants == None or len(occupants) == 0:
        prof.cons_show("No occupants for /clients command.")
        return

    nick = prof.get_current_nick()

    _create_win()
    prof.win_focus(clients_win)

    for occupant in occupants:
        if nick != occupant:
            _sv_send(muc, occupant)
Ejemplo n.º 22
0
def _links(page_str):
    global page_ac

    page = wikipedia.page(page_str)
    create_win()
    if not page:
        prof.win_show_themed(win, "wikipedia", "links.nopage", None, "No such page: \"" + page_str + "\"")
        prof.win_show(win, "")
        prof.win_focus(win)
        return

    prof.win_show_themed(win, "wikipedia", "links", None, "Links for " + page_str)

    for link in page.links:
        prof.win_show_themed(win, "wikipedia", "links.link", None, link)
        page_ac.append(link)
    _update_autocomplete()
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 23
0
def _cmd_system(arg1=None, arg2=None):
    if not arg1:
        create_win()
        prof.win_focus(system_win)
        return;

    if arg1 == "newline":
        _handle_newline(arg2)
        return

    if arg1 == "send":
        _handle_send(arg2)
        return

    if arg1 == "exec":
        _handle_exec(arg2)
        return

    prof.cons_bad_cmd_usage("/system")
Ejemplo n.º 24
0
def cmd_wp(subcmd, arg):
    try:
        if   subcmd == "search":    _search(arg)
        elif subcmd == "summary":   _summary(arg)
        elif subcmd == "page":      _page(arg)
        elif subcmd == "images":    _images(arg)
        elif subcmd == "links":     _links(arg)
        elif subcmd == "refs":      _refs(arg)
        elif subcmd == "open":      _open_browser(arg)
    except wikipedia.exceptions.WikipediaException as e:
        create_win()
        prof.win_show_themed(win, "wikipedia", "error", None, str(e))
        prof.win_show(win, "")
        prof.win_focus(win)
    except requests.exceptions.ConnectionError:
        create_win()
        prof.win_show_themed(win, "wikipedia", "error", None, "Connection Error")
        prof.win_show(win, "")
        prof.win_focus(win)
Ejemplo n.º 25
0
def _cmd_system(arg1=None, arg2=None):
    if not arg1:
        create_win()
        prof.win_focus(system_win)
        return

    if arg1 == "newline":
        _handle_newline(arg2)
        return

    if arg1 == "send":
        _handle_send(arg2)
        return

    if arg1 == "exec":
        _handle_exec(arg2)
        return

    prof.cons_bad_cmd_usage("/system")
Ejemplo n.º 26
0
def _cmd_clients():
    muc = prof.get_current_muc()
    if muc == None:
        prof.cons_show("Command only valid in chat rooms.")
        return
	
    occupants = prof.get_current_occupants()
    if occupants == None or len(occupants) == 0:
        prof.cons_show("No occupants for /clients command.")
        return

    nick = prof.get_current_nick()

    _create_win()
    prof.win_focus(clients_win)

    for occupant in occupants:
        if nick != occupant:
            _sv_send(muc, occupant)
Ejemplo n.º 27
0
def _search(search_terms):
    global page_ac

    results = wikipedia.search(search_terms)
    create_win()
    if len(results) > 0:
        prof.win_show_themed(win, "wikipedia", "search", None,
                             "Search results for \"" + search_terms + "\":")
        for index, result in enumerate(results):
            page_ac.append(result)
            prof.win_show_themed(win, "wikipedia", "search.results", None,
                                 result)
        _update_autocomplete()
    else:
        prof.win_show_themed(
            win, "wikipedia", "search.noresults", None,
            "No search results found for \"" + search_terms + "\"")
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 28
0
def _int(op, group, key, value):
    if op != "get" and op != "set":
        prof.cons_bad_cmd_usage("/python-test")
        return

    if group == None or key == None:
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "get":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        res = prof.settings_int_get(group, key, 0)
        prof.win_show(plugin_win, "Integer setting: " + str(res))
    elif op == "set":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.settings_int_set(group, key, int(value))
        prof.win_show(plugin_win,
                      "Set [" + group + "] " + key + " to " + str(value))
Ejemplo n.º 29
0
def cmd_wp(subcmd, arg):
    try:
        if subcmd == "search": _search(arg)
        elif subcmd == "summary": _summary(arg)
        elif subcmd == "page": _page(arg)
        elif subcmd == "images": _images(arg)
        elif subcmd == "links": _links(arg)
        elif subcmd == "refs": _refs(arg)
        elif subcmd == "open": _open_browser(arg)
    except wikipedia.exceptions.WikipediaException as e:
        create_win()
        prof.win_show_themed(win, "wikipedia", "error", None, str(e))
        prof.win_show(win, "")
        prof.win_focus(win)
    except requests.exceptions.ConnectionError:
        create_win()
        prof.win_show_themed(win, "wikipedia", "error", None,
                             "Connection Error")
        prof.win_show(win, "")
        prof.win_focus(win)
Ejemplo n.º 30
0
def _images(page_str):
    global link_ac

    page = wikipedia.page(page_str)
    create_win()
    if not page:
        prof.win_show_themed(win, "wikipedia", "images.nopage", None,
                             "No such page: \"" + page_str + "\"")
        prof.win_show(win, "")
        prof.win_focus(win)
        return

    prof.win_show_themed(win, "wikipedia", "images", None,
                         "Images for " + page_str)
    for image in page.images:
        prof.win_show_themed(win, "wikipedia", "images.url", None, image)
        link_ac.append(image)
    prof.completer_add("/wikipedia open", link_ac)
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 31
0
def _refs(page_str):
    global link_ac

    page = wikipedia.page(page_str)
    create_win()
    if not page:
        prof.win_show_themed(win, "wikipedia", "refs.nopage", None,
                             "No such page: \"" + page_str + "\"")
        prof.win_show(win, "")
        prof.win_focus(win)
        return

    prof.win_show_themed(win, "wikipedia", "refs", None,
                         "References for " + page_str)
    for ref in page.references:
        prof.win_show_themed(win, "wikipedia", "refs.url", None, ref)
        link_ac.append(ref)
    prof.completer_add("/wikipedia open", link_ac)
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 32
0
def _completer(op, item):
    if not item:
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "add":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.completer_add("/python-test", [item])
        prof.win_show(plugin_win,
                      "Added \"" + item + "\" to /python-test completer")
        prof.completer_add("/python-test completer remove", [item])
    elif op == "remove":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.completer_remove("/python-test", [item])
        prof.win_show(plugin_win,
                      "Removed \"" + item + "\" to /python-test completer")
        prof.completer_remove("/python-test completer remove", [item])
    else:
        prof.cons_bad_cmd_usage("/python-test")
Ejemplo n.º 33
0
def _links(page_str):
    global page_ac

    page = wikipedia.page(page_str)
    create_win()
    if not page:
        prof.win_show_themed(win, "wikipedia", "links.nopage", None,
                             "No such page: \"" + page_str + "\"")
        prof.win_show(win, "")
        prof.win_focus(win)
        return

    prof.win_show_themed(win, "wikipedia", "links", None,
                         "Links for " + page_str)

    for link in page.links:
        prof.win_show_themed(win, "wikipedia", "links.link", None, link)
        page_ac.append(link)
    _update_autocomplete()
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 34
0
def _summary(page_str):
    global link_ac

    page = wikipedia.page(page_str)
    create_win()
    if not page:
        prof.win_show_themed(win, "wikipedia", "summary.nopage", None, "No such page: \"" + page_str + "\"")
        prof.win_show(win, "")
        prof.win_focus(win)
        return

    link_ac.append(page.url)
    prof.completer_add("/wikipedia open", link_ac)

    prof.win_show_themed(win, "wikipedia", "summary.title", None, page.title)
    prof.win_show_themed(win, "wikipedia", "summary.url", None, page.url)

    summary = wikipedia.summary(page_str)
    prof.win_show_themed(win, "wikipedia", "summary.text", None, summary)
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 35
0
def _summary(page_str):
    global link_ac

    page = wikipedia.page(page_str)
    create_win()
    if not page:
        prof.win_show_themed(win, "wikipedia", "summary.nopage", None,
                             "No such page: \"" + page_str + "\"")
        prof.win_show(win, "")
        prof.win_focus(win)
        return

    link_ac.append(page.url)
    prof.completer_add("/wikipedia open", link_ac)

    prof.win_show_themed(win, "wikipedia", "summary.title", None, page.title)
    prof.win_show_themed(win, "wikipedia", "summary.url", None, page.url)

    summary = wikipedia.summary(page_str)
    prof.win_show_themed(win, "wikipedia", "summary.text", None, summary)
    prof.win_show(win, "")
    prof.win_focus(win)
Ejemplo n.º 36
0
def _get(subject):
    if subject == "recipient":
        prof.win_create(plugin_win, _handle_win_input)
        recipient = prof.get_current_recipient()
        if recipient:
            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 subject == "room":
        prof.win_create(plugin_win, _handle_win_input)
        room = prof.get_current_muc()
        if room:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win,
                          "called -> prof_get_current_muc: " + room)
            nick = prof.get_room_nick(room)
            if nick:
                prof.win_focus(plugin_win)
                prof.win_show(
                    plugin_win,
                    "called -> prof_get_room_nick('" + room + "'): " + nick)
        else:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win, "called -> prof_get_current_muc: <none>")
    elif subject == "nick":
        prof.win_create(plugin_win, _handle_win_input)
        nick = prof.get_current_nick()
        if nick:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win,
                          "called -> prof_get_current_nick: " + nick)
        else:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win,
                          "called -> prof_get_current_nick: <none>")
    elif subject == "occupants":
        prof.win_create(plugin_win, _handle_win_input)
        occupants = prof.get_current_occupants()
        if occupants:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win, "called -> prof_get_current_occupants:")
            for occupant in occupants:
                prof.win_show(plugin_win, occupant)
        else:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win,
                          "called -> prof_get_current_occupants: <none>")
    else:
        prof.cons_bad_cmd_usage("/python-test")
Ejemplo n.º 37
0
def _cmd_jenkins(cmd=None, arg=None):
    global enable_remind
    global enable_notify

    if not prof.win_exists(win_tag):
        prof.win_create(win_tag, _handle_input)

    prof.win_focus(win_tag)

    if cmd == "jobs":
        if job_list and job_list.get_jobs():
            prof.win_show(win_tag, "Jobs:")
            _list_jobs(job_list.get_jobs())
        else:
            prof.win_show(win_tag, "No job data yet.")
    elif cmd == "failing":
        if job_list:
            jobs_in_state = job_list.get_jobs(STATE_FAILURE)
            if jobs_in_state:
                prof.win_show(win_tag, "Failing jobs:")
                _list_jobs(jobs_in_state)
            else:
                prof.win_show(win_tag, "No failing jobs.")
        else:
            prof.win_show(win_tag, "No job data yet.")
    elif cmd == "passing":
        if job_list:
            jobs_in_state = job_list.get_jobs(STATE_SUCCESS)
            if jobs_in_state:
                prof.win_show(win_tag, "Passing jobs:")
                _list_jobs(jobs_in_state)
            else:
                prof.win_show(win_tag, "No passing jobs.")
        else:
            prof.win_show(win_tag, "No job data yet.")
    elif cmd == "unstable":
        if job_list:
            jobs_in_state = job_list.get_jobs(STATE_UNSTABLE)
            if jobs_in_state:
                prof.win_show(win_tag, "Unstable jobs:")
                _list_jobs(jobs_in_state)
            else:
                prof.win_show(win_tag, "No unstable jobs.")
        else:
            prof.win_show(win_tag, "No job data yet.")
    elif cmd == "build":
        if not arg:
            prof.win_show(win_tag, "You must supply a job argument.")
        elif job_list and job_list.contains_job(arg):
            _build_job(arg)
        else:
            prof.win_show(win_tag, "No such job: " + arg)
    elif cmd == "open":
        if not arg:
            prof.win_show(win_tag, "You must supply a job argument.")
        elif job_list and job_list.contains_job(arg):
            _open_job_url(jenkins_url + "/job/" + arg)
        else:
            prof.win_show(win_tag, "No such job: " + arg)
    elif cmd == "remind":
        if not arg:
            prof.win_show(win_tag, "You must specify either 'on' or 'off'.")
        elif arg == "on":
            enable_remind = True
            prof.win_show(win_tag, "Reminder notifications enabled.")
        elif arg == "off":
            enable_remind = False
            prof.win_show(win_tag, "Reminder notifications disabled.")
        else:
            prof.win_show(win_tag, "You must specify either 'on' or 'off'.")
    elif cmd == "notify":
        if not arg:
            prof.win_show(win_tag, "You must specify either 'on' or 'off'.")
        elif arg == "on":
            enable_notify = True
            prof.win_show(win_tag, "Build notifications enabled.")
        elif arg == "off":
            enable_notify = False
            prof.win_show(win_tag, "Build notifications disabled.")
        else:
            prof.win_show(win_tag, "You must specify either 'on' or 'off'.")
    elif cmd == "settings":
        _settings()
    elif cmd == "help":
        _help()
    elif cmd == "log":
        if not arg:
            prof.win_show(win_tag, "You must specify a job.")
        else:
            job = job_list.get_job(arg)
            if job:
                _job_log(job)
            else:
                prof.win_show(win_tag, "No job found: " + arg)
    else:
        prof.win_show(win_tag, "Unknown command.")
Ejemplo n.º 38
0
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")
Ejemplo n.º 39
0
def _cmd_jenkins(cmd=None, arg=None):
    global enable_remind
    global enable_notify

    if not prof.win_exists(win_tag):
        prof.win_create(win_tag, _handle_input)

    prof.win_focus(win_tag)

    if cmd == "jobs":
        if job_list and job_list.get_jobs():
            prof.win_show(win_tag, "Jobs:")
            _list_jobs(job_list.get_jobs())
        else:
            prof.win_show(win_tag, "No job data yet.")
    elif cmd == "failing":
        if job_list:
            jobs_in_state = job_list.get_jobs(STATE_FAILURE)
            if jobs_in_state:
                prof.win_show(win_tag, "Failing jobs:")
                _list_jobs(jobs_in_state)
            else:
                prof.win_show(win_tag, "No failing jobs.")
        else:
            prof.win_show(win_tag, "No job data yet.")
    elif cmd == "passing":
        if job_list:
            jobs_in_state = job_list.get_jobs(STATE_SUCCESS)
            if jobs_in_state:
                prof.win_show(win_tag, "Passing jobs:")
                _list_jobs(jobs_in_state)
            else:
                prof.win_show(win_tag, "No passing jobs.")
        else:
            prof.win_show(win_tag, "No job data yet.")
    elif cmd == "unstable":
        if job_list:
            jobs_in_state = job_list.get_jobs(STATE_UNSTABLE)
            if jobs_in_state:
                prof.win_show(win_tag, "Unstable jobs:")
                _list_jobs(jobs_in_state)
            else:
                prof.win_show(win_tag, "No unstable jobs.")
        else:
            prof.win_show(win_tag, "No job data yet.")
    elif cmd == "build":
        if not arg:
            prof.win_show(win_tag, "You must supply a job argument.")
        elif job_list and job_list.contains_job(arg):
            _build_job(arg)
        else:
            prof.win_show(win_tag, "No such job: " + arg)
    elif cmd == "open":
        if not arg:
            prof.win_show(win_tag, "You must supply a job argument.")
        elif job_list and job_list.contains_job(arg):
            _open_job_url(jenkins_url + "/job/" + arg)
        else:
            prof.win_show(win_tag, "No such job: " + arg)
    elif cmd == "remind":
        if not arg:
            prof.win_show(win_tag, "You must specify either 'on' or 'off'.")
        elif arg == "on":
            enable_remind = True
            prof.win_show(win_tag, "Reminder notifications enabled.")
        elif arg == "off":
            enable_remind = False
            prof.win_show(win_tag, "Reminder notifications disabled.")
        else:
            prof.win_show(win_tag, "You must specify either 'on' or 'off'.")
    elif cmd == "notify":
        if not arg:
            prof.win_show(win_tag, "You must specify either 'on' or 'off'.")
        elif arg == "on":
            enable_notify = True
            prof.win_show(win_tag, "Build notifications enabled.")
        elif arg == "off":
            enable_notify = False
            prof.win_show(win_tag, "Build notifications disabled.")
        else:
            prof.win_show(win_tag, "You must specify either 'on' or 'off'.")
    elif cmd == "settings":
        _settings()
    elif cmd == "help":
        _help()
    elif cmd == "log":
        if not arg:
            prof.win_show(win_tag, "You must specify a job.")
        else:
            job = job_list.get_job(arg)
            if job:
                _job_log(job)
            else:
                prof.win_show(win_tag, "No job found: " + arg)
    else:
        prof.win_show(win_tag, "Unknown command.")
Ejemplo n.º 40
0
def _count():
    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    prof.win_show(plugin_win, "Count: " + str(count))
Ejemplo n.º 41
0
def _consalert():
    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    prof.cons_alert()
    prof.win_show(plugin_win, "called -> prof.cons_alert")