def _handle_win_input(win, command): prof.win_show_themed(win, "system", "command", None, command) prof.win_show(win, "") result = _get_result(command) split = result.splitlines() for s in split: prof.win_show_themed(win, "system", "result", None, s) prof.win_show(win, "")
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)
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 _list_jobs(jobs): for name, build_number, state in jobs: if state == STATE_SUCCESS: prof.win_show_themed(win_tag, None, None, "green", " " + name + " #" + str(build_number) + " " + STATE_SUCCESS) elif state == STATE_UNSTABLE: prof.win_show_themed(win_tag, None, None, "yellow", " " + name + " #" + str(build_number) + " " + STATE_UNSTABLE) elif state == STATE_FAILURE: prof.win_show_themed(win_tag, None, None, "red", " " + name + " #" + str(build_number) + " " + STATE_FAILURE) elif state == STATE_NOBUILDS: prof.win_show(win_tag, " " + name + ", no builds") else: prof.win_show_themed(win_tag, None, None, "cyan", " " + name + " " + state)
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)
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 _list_jobs(jobs): for name, build_number, state in jobs: if state == STATE_SUCCESS: prof.win_show_themed( win_tag, None, None, "green", " " + name + " #" + str(build_number) + " " + STATE_SUCCESS) elif state == STATE_UNSTABLE: prof.win_show_themed( win_tag, None, None, "yellow", " " + name + " #" + str(build_number) + " " + STATE_UNSTABLE) elif state == STATE_FAILURE: prof.win_show_themed( win_tag, None, None, "red", " " + name + " #" + str(build_number) + " " + STATE_FAILURE) elif state == STATE_NOBUILDS: prof.win_show(win_tag, " " + name + ", no builds") else: prof.win_show_themed(win_tag, None, None, "cyan", " " + name + " " + state)
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)
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)
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)
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)
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)
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)
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)
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")