def prof_on_unload(): global thread_stop prof.win_create(plugin_win, _handle_win_input) prof.win_show(plugin_win, "fired -> prof_on_unload") thread_stop.set() count_thread.join()
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 _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)
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)
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)
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")
def prof_on_room_history_message(barejid, nick, message, timestamp): prof.win_create(plugin_win, _handle_win_input) if timestamp: prof.win_show( plugin_win, "fired -> prof_on_room_history_message: " + barejid + ", " + nick + ", " + message + ", " + timestamp) else: prof.win_show( plugin_win, "fired -> prof_on_room_history_message: " + barejid + ", " + nick + ", " + message)
def prof_on_contact_offline(barejid, resource, status): prof.win_create(plugin_win, _handle_win_input) if status: prof.win_show( plugin_win, "fired -> prof_on_contact_offline: " + barejid + "/" + resource + " \"" + status + "\"") else: prof.win_show( plugin_win, "fired -> prof_on_contact_offline: " + barejid + "/" + resource)
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))
def prof_on_contact_presence(barejid, resource, presence, status, priority): prof.win_create(plugin_win, _handle_win_input) if status: prof.win_show( plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority) + " \"" + status + "\"") else: prof.win_show( plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority))
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))
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)
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 _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")
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 _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 _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 _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")
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)
def _list_jobs(jobs): for name, build_number, state in jobs: if state == STATE_SUCCESS: prof.win_show_green( win_tag, " " + name + " #" + str(build_number) + " " + STATE_SUCCESS) elif state == STATE_UNSTABLE: prof.win_show_yellow( win_tag, " " + name + " #" + str(build_number) + " " + STATE_UNSTABLE) elif state == STATE_FAILURE: prof.win_show_red( win_tag, " " + name + " #" + str(build_number) + " " + STATE_FAILURE) elif state == STATE_NOBUILDS: prof.win_show(win_tag, " " + name + ", no builds") else: prof.win_show_cyan(win_tag, " " + name + " " + state)
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 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 _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 _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 _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))
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 _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")
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)
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))
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 prof_on_iq_stanza_receive(stanza): iq = ET.fromstring(stanza) iq_id = iq.get("id") if not iq_id: return True if not iq_id.startswith("clients_"): return True iq_type = iq.get("type") if not iq_type: return True if iq_type != "result": return True iq_from = iq.get("from") if not iq_from: return True query = iq.find("{jabber:iq:version}query") if query is None: return True name = query.find("{jabber:iq:version}name") version = query.find("{jabber:iq:version}version") if name is None and version is None: return True message = iq_from.split("/")[1] if name is not None: message = message + ", " + name.text if version is not None: message = message + ", " + version.text prof.win_show(clients_win, message) return False
def prof_post_priv_message_send(room, nick, message): create_win() prof.win_show(plugin_win, "fired -> prof_post_priv_message_send: " + room + ", " + nick + ", " + message)
def prof_pre_priv_message_display(room, nick, message): create_win() prof.win_show(plugin_win, "fired -> prof_pre_priv_message_display: " + room + ", " + nick + ", " + message)
def prof_pre_room_message_send(room, message): create_win() prof.win_show(plugin_win, "fired -> prof_pre_room_message_send: " + room + ", " + message)
def prof_post_chat_message_send(jid, message): create_win() prof.win_show(plugin_win, "fired -> prof_post_chat_message_send: " + jid + ", " + message)
def prof_pre_chat_message_display(jid, message): create_win() prof.win_show(plugin_win, "fired -> prof_pre_chat_message_display: " + jid + ", " + message)
def prof_on_start(): prof.win_create(win_tag, _handle_input) prof.win_show(win_tag, "Jenkins plugin started.")
def _settings(): prof.win_show(win_tag, "Jenkins settings:") prof.win_show(win_tag, " Jenkins URL : " + jenkins_url) prof.win_show( win_tag, " Jenkins poll interval : " + str(jenkins_poll_interval) + " seconds") prof.win_show( win_tag, " Profanity update interval : " + str(prof_cb_interval) + " seconds") prof.win_show( win_tag, " Reminder interval : " + str(prof_remind_interval) + " seconds") prof.win_show(win_tag, " Notifications enabled : " + str(enable_notify)) prof.win_show(win_tag, " Reminders enabled : " + str(enable_remind))
prof.win_show_themed(win_tag, None, None, "cyan", " " + name + " " + state) 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)) else: prof.win_show(win_tag, "Build request sent for " + job) 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) else:
def prof_on_start(): create_win() prof.win_show(plugin_win, "fired -> prof_on_start")
def timed_callback(): create_win() prof.win_show(plugin_win, "timed -> timed_callback called")
def _handle_win_input(win, line): prof.win_show(win, "Input received: " + line)
def _handle_win_input(win, line): prof.win_show(win, line)
def _help(): prof.win_show(win_tag, "Commands:") prof.win_show(win_tag, " /jenkins help - Show this help") prof.win_show(win_tag, " /jenkins jobs - List all jobs") prof.win_show(win_tag, " /jenkins failing - List all failing jobs") prof.win_show(win_tag, " /jenkins passing - List all passing jobs") prof.win_show(win_tag, " /jenkins unstable - List all unstable jobs") prof.win_show(win_tag, " /jenkins build [job] - Trigger build for job") prof.win_show(win_tag, " /jenkins open [job] - Open job in browser") prof.win_show(win_tag, " /jenkins log [job] - Show the latest build log") prof.win_show(win_tag, " /jenkins remind on|off - Enable/disable reminder notifications") prof.win_show(win_tag, " /jenkins notify on|off - Enable/disable build notifications") prof.win_show(win_tag, " /jenkins settings - Show current settings")
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")
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.")
def _help(): prof.win_show(win_tag, "Commands:") prof.win_show(win_tag, " /jenkins help - Show this help") prof.win_show(win_tag, " /jenkins jobs - List all jobs") prof.win_show(win_tag, " /jenkins failing - List all failing jobs") prof.win_show(win_tag, " /jenkins passing - List all passing jobs") prof.win_show(win_tag, " /jenkins unstable - List all unstable jobs") prof.win_show(win_tag, " /jenkins build [job] - Trigger build for job") prof.win_show(win_tag, " /jenkins open [job] - Open job in browser") prof.win_show(win_tag, " /jenkins log [job] - Show the latest build log") prof.win_show( win_tag, " /jenkins remind on|off - Enable/disable reminder notifications") prof.win_show( win_tag, " /jenkins notify on|off - Enable/disable build notifications") prof.win_show(win_tag, " /jenkins settings - Show current settings")
def prof_on_shutdown(): create_win() prof.win_show(plugin_win, "fired -> prof_on_shutdown")
def _settings(): prof.win_show(win_tag, "Jenkins settings:") prof.win_show(win_tag, " Jenkins URL : " + jenkins_url) prof.win_show(win_tag, " Jenkins poll interval : " + str(jenkins_poll_interval) + " seconds") prof.win_show(win_tag, " Profanity update interval : " + str(prof_cb_interval) + " seconds") prof.win_show(win_tag, " Reminder interval : " + str(prof_remind_interval) + " seconds") prof.win_show(win_tag, " Notifications enabled : " + str(enable_notify)) prof.win_show(win_tag, " Reminders enabled : " + str(enable_remind))
def prof_on_disconnect(account_name, fulljid): create_win() prof.win_show(plugin_win, "fired -> prof_on_disconnect: " + account_name + ", " + fulljid)