Ejemplo n.º 1
0
Archivo: jira.py Proyecto: roaet/pyhole
    def keyword_jira(self, message, params=None, **kwargs):
        """Retrieve Jira ticket information (ex: jira NCP-1444)"""
        params = utils.ensure_int(params)
        if not params:
            return

        self._find_issue(message, params)
Ejemplo n.º 2
0
    def keyword_k(self, message, params=None, **kwargs):
        """Retrieve kernel.org Bugzilla bug information (ex: K12345)"""
        params = utils.ensure_int(params)
        if not params:
            return

        params = {"id": params}
        url = "https://bugzilla.kernel.org/show_bug.cgi"
        response = utils.fetch_url(url, params=params)
        if response.status_code != 200:
            return

        soup = BeautifulSoup(response.content)
        desc = utils.decode_entities(soup.head.title.string)

        try:
            status = soup.find("span", {"id": "static_bug_status"}).string
            status = status.capitalize().split("\n")[0]

            assignee = utils.decode_entities(
                soup.findAll("span", {
                    "class": "vcard"
                })[0].contents[0].string)

            msg = "%s [Status: %s, Assignee: %s] %s"
            message.dispatch(msg % (desc, status, assignee, url))
        except TypeError:
            return
Ejemplo n.º 3
0
    def keyword_jira(self, message, params=None, **kwargs):
        """Retrieve Jira ticket information (ex: jira NCP-1444)"""
        params = utils.ensure_int(params)
        if not params:
            return

        self._find_issue(message, params)
Ejemplo n.º 4
0
    def keyword_k(self, message, params=None, **kwargs):
        """Retrieve kernel.org Bugzilla bug information (ex: K12345)"""
        if params:
            params = utils.ensure_int(params)
            if not params:
                return

            query = urllib.urlencode({"id": params})
            url = "http://bugzilla.kernel.org/show_bug.cgi?%s" % query
            response = self.irc.fetch_url(url, self.name)
            if not response or not isinstance(params, int):
                return

            soup = BeautifulSoup(response.read())
            desc = utils.decode_entities(soup.head.title.string)

            try:
                status = soup.find("span", {"id": "static_bug_status"}).string.strip().capitalize()
                assignee = utils.decode_entities(soup.findAll("span", {"class": "vcard"})[0].contents[0].string)

                msg = "Kernel.org %s [Status: %s, Assignee: %s] %s"
                message.dispatch(msg % (desc, status, assignee, url))

            except TypeError:
                return
Ejemplo n.º 5
0
    def keyword_k(self, message, params=None, **kwargs):
        """Retrieve kernel.org Bugzilla bug information (ex: K12345)"""
        if params:
            params = utils.ensure_int(params)
            if not params:
                return

            query = urllib.urlencode({"id": params})
            url = "http://bugzilla.kernel.org/show_bug.cgi?%s" % query
            response = self.irc.fetch_url(url, self.name)
            if not response or not isinstance(params, int):
                return

            soup = BeautifulSoup(response.read())
            desc = utils.decode_entities(soup.head.title.string)

            try:
                status = soup.find("span", {
                    "id":
                    "static_bug_status"}).string.strip().capitalize()
                assignee = utils.decode_entities(
                    soup.findAll("span", {
                        "class": "vcard"
                    })[0].contents[0].string)

                msg = "Kernel.org %s [Status: %s, Assignee: %s] %s"
                message.dispatch(msg % (desc, status, assignee, url))

            except TypeError:
                return
Ejemplo n.º 6
0
 def keyword_xsa(self, message, params=None, **kwargs):
     """Retrieve XSA information (ex: xsa123 or xsa-123)."""
     # abs is needed in case we get 'xsa-123', that would be -123
     xsa_num = abs(utils.ensure_int(params))
     xsa_id = "XSA-%d" % xsa_num
     data = self._load_cached_xsa_data()
     msg = self._make_xsa_message(xsa_id, data)
     if not msg:
         msg = "Unable to find matching XSA."
     message.dispatch(msg)
Ejemplo n.º 7
0
 def keyword_xsa(self, message, params=None, **kwargs):
     """Retrieve XSA information (ex: xsa123 or xsa-123)."""
     # abs is needed in case we get 'xsa-123', that would be -123
     xsa_num = abs(utils.ensure_int(params))
     xsa_id = "XSA-%d" % xsa_num
     data = self._load_cached_xsa_data()
     msg = self._make_xsa_message(xsa_id, data)
     if not msg:
         msg = "Unable to find matching XSA."
     message.dispatch(msg)
Ejemplo n.º 8
0
    def keyword_lp(self, message, params=None, **kwargs):
        """Retrieve Launchpad bug information (ex: LP12345)"""
        params = utils.ensure_int(params)
        if not params:
            return

        try:
            bug = self.launchpad.bugs[params]
            task = bug.bug_tasks[len(bug.bug_tasks) - 1]
            message.dispatch(
                "LP %s [Status: %s, Assignee: %s] %s"
                % (task.title, task.status, self._find_name(task.assignee_link), bug.web_link)
            )
        except Exception:
            return
Ejemplo n.º 9
0
    def keyword_lp(self, message, params=None, **kwargs):
        """Retrieve Launchpad bug information (ex: LP12345)"""
        params = utils.ensure_int(params)
        if not params:
            return

        try:
            bug = self.launchpad.bugs[params]
            task = bug.bug_tasks[len(bug.bug_tasks) - 1]
            message.dispatch(
                "LP %s [Status: %s, Assignee: %s] %s" %
                (task.title, task.status, self._find_name(
                    task.assignee_link), bug.web_link))
        except Exception:
            return
Ejemplo n.º 10
0
 def keyword_epic(self, message, params=None, **kwargs):
     """Retrieve VersionOne epic information (ex: E-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Epic", "E-%s" % params)
Ejemplo n.º 11
0
 def keyword_request(self, message, params=None, **kwargs):
     """Retrieve VersionOne request information (ex: R-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Request", "R-%s" % params)
Ejemplo n.º 12
0
 def keyword_goal(self, message, params=None, **kwargs):
     """Retrieve VersionOne goal information (ex: G-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Goal", "G-%s" % params)
Ejemplo n.º 13
0
 def keyword_task(self, message, params=None, **kwargs):
     """Retrieve VersionOne task information (ex: TK-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Task", "TK-%s" % params)
Ejemplo n.º 14
0
 def keyword_backlog(self, message, params=None, **kwargs):
     """Retrieve VersionOne backlog information (ex: B-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Story", "B-%s" % params)
Ejemplo n.º 15
0
 def keyword_issue(self, message, params=None, **kwargs):
     """Retrieve VersionOne issue information (ex: I-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Issue", "I-%s" % params)
Ejemplo n.º 16
0
 def test_ensure_int(self):
     self.assertEqual(utils.ensure_int("3"), 3)
Ejemplo n.º 17
0
 def keyword_goal(self, message, params=None, **kwargs):
     """Retrieve VersionOne goal information (ex: G-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Goal", "G-%s" % params)
Ejemplo n.º 18
0
 def keyword_task(self, message, params=None, **kwargs):
     """Retrieve VersionOne task information (ex: TK-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Task", "TK-%s" % params)
Ejemplo n.º 19
0
 def keyword_rm(self, message, params=None, **kwargs):
     """Retrieve Redmine bug information (ex: RM12345)."""
     params = utils.ensure_int(params)
     if params:
         self._find_issue(message, params)
Ejemplo n.º 20
0
 def keyword_request(self, message, params=None, **kwargs):
     """Retrieve VersionOne request information (ex: R-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Request", "R-%s" % params)
Ejemplo n.º 21
0
 def keyword_epic(self, message, params=None, **kwargs):
     """Retrieve VersionOne epic information (ex: E-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Epic", "E-%s" % params)
Ejemplo n.º 22
0
 def test_ensure_int(self):
     self.assertEqual(utils.ensure_int("3"), 3)
Ejemplo n.º 23
0
 def test_ensure_int_3(self):
     self.assertEqual(utils.ensure_int("a"), None)
Ejemplo n.º 24
0
 def test_ensure_int_3(self):
     self.assertEqual(utils.ensure_int("a"), None)
Ejemplo n.º 25
0
 def keyword_issue(self, message, params=None, **kwargs):
     """Retrieve VersionOne issue information (ex: I-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Issue", "I-%s" % params)
Ejemplo n.º 26
0
 def keyword_rm(self, message, params=None, **kwargs):
     """Retrieve Redmine bug information (ex: RM12345)."""
     params = utils.ensure_int(params)
     if params:
         self._find_issue(message, params)
Ejemplo n.º 27
0
 def keyword_backlog(self, message, params=None, **kwargs):
     """Retrieve VersionOne backlog information (ex: B-01234)"""
     if params and not self.disabled:
         params = utils.ensure_int(params)
         if params:
             self._find_asset(message, "Story", "B-%s" % params)