示例#1
0
文件: trac.py 项目: iganchev/Bicho
    def analyze_attachment(self, arg2):
        printdbg("We're analyzing attachment")

        # Get the time-date of the event
        td = self.__get_time(arg2)

        # Get the submitter
        by = self.__get_submitter(arg2)

        # The comment of the file inbetween <p> tags
        ac = re.search('(?<=\s<div class="comment searchable">)\s+<p>\s+(\w.*)\s</p>\s+</div>', str(arg2))

        # Attachment's name and url (anu)
        anu = re.search('<a href=".*<em>(.*)</em></a><a.*href="(.*)"\stitle=.*</a>', str(arg2))

        if ac is not None:
            comment = ac.group(1).decode('UTF-8')
        else:
            comment = u''

        if anu is not None:
            name = anu.group(1).decode('UTF-8')
            url = anu.group(2).decode('UTF-8')
        else:
            printdbg("Name or url not found, error?")
            name = u''
            url = u''

        printdbg("comment : {}, name : {}, url : {}".format(comment, name, url))

        # TODO: Check whether variables are assigned
        attach = Attachment(url, by, td)
        attach.set_name(name)
        attach.set_description(comment)

        return attach
示例#2
0
文件: lp.py 项目: yujuanjiang/Bicho
    def analyze_bug(self, bug):
        # Retrieving main bug information

        ##
        ## all the retrieval can be improved. The method bug.lp_attributes
        ##offers a list of the available attributes for the object
        ##
        printdbg(bug.web_link + " updated at " + bug.bug.date_last_updated.isoformat())

        issue = bug.web_link[bug.web_link.rfind("/") + 1 :]
        bug_type = bug.importance
        summary = bug.bug.title
        desc = bug.bug.description
        submitted_by = self._get_person(bug.owner)
        submitted_on = self.__drop_timezone(bug.date_created)

        if bug.assignee:
            assignee = self._get_person(bug.assignee)
        else:
            assignee = People("nobody")

        issue = LaunchpadIssue(issue, bug_type, summary, desc, submitted_by, submitted_on)
        issue.set_assigned(assignee)

        issue.set_status(bug.status)
        issue.set_description(bug.bug.description)
        issue.set_web_link(bug.web_link)

        issue.set_target_display_name(bug.bug_target_display_name)
        issue.set_target_name(bug.bug_target_name)

        try:
            if bug.date_assigned:
                issue.set_date_assigned(self.__drop_timezone(bug.date_assigned))
        except AttributeError:
            pass

        try:
            if bug.date_closed:
                issue.set_date_closed(self.__drop_timezone(bug.date_closed))
        except AttributeError:
            pass

        try:
            if bug.date_confirmed:
                issue.set_date_confirmed(self.__drop_timezone(bug.date_confirmed))
        except AttributeError:
            pass

        try:
            if bug.date_created:
                issue.set_date_created(self.__drop_timezone(bug.date_created))
        except AttributeError:
            pass

        try:
            if bug.date_fix_committed:
                issue.set_date_fix_committed(self.__drop_timezone(bug.date_fix_committed))
        except AttributeError:
            pass

        try:
            if bug.date_fix_released:
                issue.set_date_fix_released(self.__drop_timezone(bug.date_fix_released))
        except AttributeError:
            pass

        try:
            if bug.date_in_progress:
                issue.set_date_in_progress(self.__drop_timezone(bug.date_in_progress))
        except AttributeError:
            pass

        try:
            if bug.date_incomplete:
                issue.set_date_incomplete(self.__drop_timezone(bug.date_incomplete))
        except AttributeError:
            pass

        try:
            if bug.date_left_closed:
                issue.set_date_left_closed(self.__drop_timezone(bug.date_left_closed))
        except AttributeError:
            pass

        try:
            if bug.date_left_new:
                issue.set_date_left_new(self.__drop_timezone(bug.date_left_new))
        except AttributeError:
            pass

        try:
            if bug.date_triaged:
                issue.set_date_triaged(self.__drop_timezone(bug.date_triaged))
        except AttributeError:
            pass

        try:
            if bug.date_last_message:
                issue.set_date_last_message(self.__drop_timezone(bug.date_last_message))
        except AttributeError:
            pass

        try:
            if bug.bug.date_last_updated:
                issue.set_date_last_updated(self.__drop_timezone(bug.bug.date_last_updated))
        except AttributeError:
            pass

        if bug.milestone:
            issue.set_milestone_code_name(bug.milestone.code_name)
            issue.set_milestone_data_targeted(bug.milestone.date_targeted)
            issue.set_milestone_name(bug.milestone.name)
            issue.set_milestone_summary(bug.milestone.summary)
            issue.set_milestone_title(bug.milestone.title)
            issue.set_milestone_web_link(bug.milestone.web_link)

        try:
            if bug.bug.duplicate_of:
                temp_rel = TempRelationship(bug.bug.id, unicode("duplicate_of"), unicode(bug.bug.duplicate_of.id))
                issue.add_temp_relationship(temp_rel)
        except NotFound:
            printdbg("Issue %s is a duplicate of a private issue. Ignoring the private issue." % issue.issue)

        issue.set_heat(bug.bug.heat)
        issue.set_linked_branches(bug.bug.linked_branches)

        # storing the comments:
        # first message of the bugs contains the description
        if bug.bug.messages and len(bug.bug.messages) > 1:
            skip = 1
            for c in bug.bug.messages:
                if skip == 1:
                    # we skip the first comment which is the description
                    skip = 0
                    continue
                by = self._get_person(c.owner)
                com = Comment(c.content, by, c.date_created)
                issue.add_comment(com)

        issue.set_tags(bug.bug.tags)
        issue.set_title(bug.bug.title)
        issue.set_users_affected_count(bug.bug.users_affected_count)
        issue.set_web_link_standalone(bug.bug.web_link)

        # activity
        for entry in bug.bug.activity.entries:
            field = entry["whatchanged"]
            removed = entry["oldvalue"]
            added = entry["newvalue"]
            by = self.__get_people_from_uri(entry["person_link"])
            date = self.__to_datetime(entry["datechanged"])
            change = Change(field, removed, added, by, date)

            issue.add_change(change)

        for a in bug.bug.attachments.entries:
            a_url = a["data_link"]
            a_name = a["title"]

            # author and date are stored in the comment object
            aux = a["message_link"]
            comment_id = int(aux[aux.rfind("/") + 1 :])
            comment = bug.bug.messages[comment_id]
            a_by = self._get_person(comment.owner)
            a_on = self.__drop_timezone(comment.date_created)

            # a_desc = a['']
            att = Attachment(a_url, a_by, a_on)
            att.set_name(a_name)
            # att.set_description()
            issue.add_attachment(att)

        return issue
示例#3
0
    def analyze_bug(self, bug):
        #Retrieving main bug information

        ##
        ## all the retrieval can be improved. The method bug.lp_attributes
        ##offers a list of the available attributes for the object
        ##
        printdbg(bug.web_link + " updated at " +
                 bug.bug.date_last_updated.isoformat())

        issue = bug.web_link[bug.web_link.rfind('/') + 1:]
        bug_type = bug.importance
        summary = bug.bug.title
        desc = bug.bug.description
        submitted_by = self._get_person(bug.owner)
        submitted_on = self.__drop_timezone(bug.date_created)

        if bug.assignee:
            assignee = self._get_person(bug.assignee)
        else:
            assignee = People("nobody")

        issue = LaunchpadIssue(issue, bug_type, summary, desc, submitted_by,
                               submitted_on)
        issue.set_assigned(assignee)

        issue.set_status(bug.status)
        issue.set_description(bug.bug.description)
        issue.set_web_link(bug.web_link)

        issue.set_target_display_name(bug.bug_target_display_name)
        issue.set_target_name(bug.bug_target_name)

        try:
            if bug.date_assigned:
                issue.set_date_assigned(self.__drop_timezone(
                    bug.date_assigned))
        except AttributeError:
            pass

        try:
            if bug.date_closed:
                issue.set_date_closed(self.__drop_timezone(bug.date_closed))
        except AttributeError:
            pass

        try:
            if bug.date_confirmed:
                issue.set_date_confirmed(
                    self.__drop_timezone(bug.date_confirmed))
        except AttributeError:
            pass

        try:
            if bug.date_created:
                issue.set_date_created(self.__drop_timezone(bug.date_created))
        except AttributeError:
            pass

        try:
            if bug.date_fix_committed:
                issue.set_date_fix_committed(
                    self.__drop_timezone(bug.date_fix_committed))
        except AttributeError:
            pass

        try:
            if bug.date_fix_released:
                issue.set_date_fix_released(
                    self.__drop_timezone(bug.date_fix_released))
        except AttributeError:
            pass

        try:
            if bug.date_in_progress:
                issue.set_date_in_progress(
                    self.__drop_timezone(bug.date_in_progress))
        except AttributeError:
            pass

        try:
            if bug.date_incomplete:
                issue.set_date_incomplete(
                    self.__drop_timezone(bug.date_incomplete))
        except AttributeError:
            pass

        try:
            if bug.date_left_closed:
                issue.set_date_left_closed(
                    self.__drop_timezone(bug.date_left_closed))
        except AttributeError:
            pass

        try:
            if bug.date_left_new:
                issue.set_date_left_new(self.__drop_timezone(
                    bug.date_left_new))
        except AttributeError:
            pass

        try:
            if bug.date_triaged:
                issue.set_date_triaged(self.__drop_timezone(bug.date_triaged))
        except AttributeError:
            pass

        try:
            if bug.date_last_message:
                issue.set_date_last_message(
                    self.__drop_timezone(bug.date_last_message))
        except AttributeError:
            pass

        try:
            if bug.bug.date_last_updated:
                issue.set_date_last_updated(
                    self.__drop_timezone(bug.bug.date_last_updated))
        except AttributeError:
            pass

        if bug.milestone:
            issue.set_milestone_code_name(bug.milestone.code_name)
            issue.set_milestone_data_targeted(bug.milestone.date_targeted)
            issue.set_milestone_name(bug.milestone.name)
            issue.set_milestone_summary(bug.milestone.summary)
            issue.set_milestone_title(bug.milestone.title)
            issue.set_milestone_web_link(bug.milestone.web_link)

        try:
            if bug.bug.duplicate_of:
                temp_rel = TempRelationship(bug.bug.id,
                                            unicode('duplicate_of'),
                                            unicode(bug.bug.duplicate_of.id))
                issue.add_temp_relationship(temp_rel)
        except NotFound:
            printdbg(
                "Issue %s is a duplicate of a private issue. Ignoring the private issue."
                % issue.issue)

        issue.set_heat(bug.bug.heat)
        issue.set_linked_branches(bug.bug.linked_branches)

        # storing the comments:
        # first message of the bugs contains the description
        if (bug.bug.messages and len(bug.bug.messages) > 1):
            skip = 1
            for c in bug.bug.messages:
                if (skip == 1):
                    # we skip the first comment which is the description
                    skip = 0
                    continue
                by = self._get_person(c.owner)
                com = Comment(c.content, by, c.date_created)
                issue.add_comment(com)

        issue.set_tags(bug.bug.tags)
        issue.set_title(bug.bug.title)
        issue.set_users_affected_count(bug.bug.users_affected_count)
        issue.set_web_link_standalone(bug.bug.web_link)

        # activity
        for entry in bug.bug.activity.entries:
            field = entry['whatchanged']
            removed = entry['oldvalue']
            added = entry['newvalue']
            by = self.__get_people_from_uri(entry['person_link'])
            date = self.__to_datetime(entry['datechanged'])
            change = Change(field, removed, added, by, date)

            issue.add_change(change)

        for a in bug.bug.attachments.entries:
            a_url = a['data_link']
            a_name = a['title']

            # author and date are stored in the comment object
            aux = a['message_link']
            comment_id = int(aux[aux.rfind('/') + 1:])
            comment = bug.bug.messages[comment_id]
            a_by = self._get_person(comment.owner)
            a_on = self.__drop_timezone(comment.date_created)

            #a_desc = a['']
            att = Attachment(a_url, a_by, a_on)
            att.set_name(a_name)
            #att.set_description()
            issue.add_attachment(att)

        return issue
示例#4
0
    def getIssue(self, bug, conn):
        #Return the parse data bug into issue object
        issue_id = bug.key_id
        issue_type = bug.bug_type
        summary = bug.summary
        description = bug.description
        status = bug.status
        resolution = bug.resolution

        assigned_by = People(bug.assignee_username)
        assigned_by.set_name(bug.assignee)
        assigned_by.set_email(BugsHandler.getUserEmail(bug.assignee_username))

        submitted_by = People(bug.reporter_username)
        submitted_by.set_name(bug.reporter)
        submitted_by.set_email(BugsHandler.getUserEmail(bug.reporter_username))

        submitted_on = parse(bug.created).replace(tzinfo=None)

        issue = JiraIssue(issue_id, issue_type, summary, description,
                          submitted_by, submitted_on)
        issue.set_assigned(assigned_by)
        issue.setIssue_key(bug.issue_key)
        issue.setTitle(bug.title)
        issue.setLink(bug.link)
        issue.setEnvironment(bug.environment)
        issue.setSecurity(bug.security)
        issue.setUpdated(parse(bug.updated).replace(tzinfo=None))
        issue.setVersion(bug.version)
        issue.setFixVersion(bug.fix_version)
        issue.setComponent(bug.component)
        issue.setVotes(bug.votes)
        issue.setProject(bug.project)
        issue.setProject_id(bug.project_id)
        issue.setProject_key(bug.project_key)
        issue.setStatus(status)
        issue.setResolution(resolution)

        bug_activity_url = bug.link + '?page=com.atlassian.jira.plugin.system.issuetabpanels%3Achangehistory-tabpanel'
        printdbg("Bug activity: " + bug_activity_url)
        f = conn.urlopen_auth(bug_activity_url)
        data_activity = f.read()
        parser = SoupHtmlParser(data_activity, bug.key_id)
        changes = parser.parse_changes()
        for c in changes:
            issue.add_change(c)

        for comment in bug.comments:
            comment_by = People(comment.comment_author)
            comment_by.set_email(
                BugsHandler.getUserEmail(comment.comment_author))
            comment_on = parse(comment.comment_created).replace(tzinfo=None)
            com = Comment(comment.comment, comment_by, comment_on)
            issue.add_comment(com)

        for attachment in bug.attachments:
            url = "/secure/attachment/" + attachment.attachment_id + "/" + attachment.attachment_name
            attachment_by = People(attachment.attachment_author)
            attachment_by.set_email(
                BugsHandler.getUserEmail(attachment.attachment_author))
            attachment_on = parse(
                attachment.attachment_created).replace(tzinfo=None)
            attach = Attachment(url, attachment_by, attachment_on)
            issue.add_attachment(attach)
        #FIXME customfield are not stored in db because is the fields has the same in all the bugs

        return issue
示例#5
0
文件: sf.py 项目: sferdi/lucenebug
    def parse_issue(self, html):
        """
        """
        soup = BeautifulSoup.BeautifulSoup(
            html, convertEntities=BeautifulSoup.BeautifulSoup.XHTML_ENTITIES)
        self.__prepare_soup(soup)

        try:
            id = self.__parse_issue_id(soup)
            summary = self.__parse_issue_summary(soup)
            desc = self.__parse_issue_description(soup)
            submission = self.__parse_issue_submission(soup)
            priority = self.__parse_issue_priority(soup)
            status = self.__parse_issue_status(soup)
            resolution = self.__parse_issue_resolution(soup)
            asignation = self.__parse_issue_assigned_to(soup)
            category = self.__parse_issue_category(soup)
            group = self.__parse_issue_group(soup)

            # FIXME the visibility var below is never used!!
            #visibility = self.__parse_issue_visibility(soup)

            try:
                comments = self.__parse_issue_comments(soup)
            except SourceForgeParserError:
                printerr("Error parsing issue's comments")
                comments = None
                pass

            try:
                attachments = self.__parse_issue_attachments(soup)
            except SourceForgeParserError:
                printerr("Error parsing issue's attachments")
                attachments = None
                pass

            try:
                changes = self.__parse_issue_changes(soup)
            except SourceForgeParserError:
                printerr("Error parsing issue's changes")
                changes = None
                pass

        except:
            raise

        submitted_by = People(submission['id'])
        submitted_by.set_name(submission['name'])
        submitted_on = submission['date']
        #assigned_to = People(asignation)
        assigned_to = People('')
        assigned_to.set_name(asignation)

        issue = SourceForgeIssue(id, 'bug', summary, desc, submitted_by,
                                 submitted_on)
        issue.set_priority(priority)
        issue.set_status(status, resolution)
        issue.set_assigned(assigned_to)
        issue.set_category(category)
        issue.set_group(group)

        if comments:
            for comment in comments:
                submitted_by = People(comment['by']['id'])
                submitted_by.set_name(comment['by']['name'])
                issue.add_comment(
                    Comment(comment['desc'], submitted_by, comment['date']))

        if attachments:
            for attachment in attachments:
                a = Attachment(attachment['url'])
                a.set_name(attachment['filename'])
                a.set_description(attachment['desc'])
                issue.add_attachment(a)

        if changes:
            for change in changes:
                changed_by = People(change['by']['id'])
                changed_by.set_name(change['by']['name'])
                issue.add_change(
                    Change(change['field'], change['old_value'], 'unknown',
                           changed_by, change['date']))

        return issue
示例#6
0
    def parse_issue(self, html):
        """
        """
        soup = BeautifulSoup.BeautifulSoup(html,
                                           convertEntities=BeautifulSoup.BeautifulSoup.XHTML_ENTITIES)
        self.__prepare_soup(soup)

        try:
            id = self.__parse_issue_id(soup)
            summary = self.__parse_issue_summary(soup)
            desc = self.__parse_issue_description(soup)
            submission = self.__parse_issue_submission(soup)
            priority = self.__parse_issue_priority(soup)
            status = self.__parse_issue_status(soup)
            resolution = self.__parse_issue_resolution(soup)
            asignation = self.__parse_issue_assigned_to(soup)
            category = self.__parse_issue_category(soup)
            group = self.__parse_issue_group(soup)

            # FIXME the visibility var below is never used!!
            #visibility = self.__parse_issue_visibility(soup)

            try:
                comments = self.__parse_issue_comments(soup)
            except SourceForgeParserError:
                printerr("Error parsing issue's comments")
                comments = None
                pass

            try:
                attachments = self.__parse_issue_attachments(soup)
            except SourceForgeParserError:
                printerr("Error parsing issue's attachments")
                attachments = None
                pass

            try:
                changes = self.__parse_issue_changes(soup)
            except SourceForgeParserError:
                printerr("Error parsing issue's changes")
                changes = None
                pass

        except:
            raise

        submitted_by = People(submission['id'])
        submitted_by.set_name(submission['name'])
        submitted_on = submission['date']
        #assigned_to = People(asignation)
        assigned_to = People('')
        assigned_to.set_name(asignation)

        issue = SourceForgeIssue(id, 'bug', summary, desc,
                                 submitted_by, submitted_on)
        issue.set_priority(priority)
        issue.set_status(status, resolution)
        issue.set_assigned(assigned_to)
        issue.set_category(category)
        issue.set_group(group)

        if comments:
            for comment in comments:
                submitted_by = People(comment['by']['id'])
                submitted_by.set_name(comment['by']['name'])
                issue.add_comment(Comment(comment['desc'], submitted_by,
                                          comment['date']))

        if attachments:
            for attachment in attachments:
                a = Attachment(attachment['url'])
                a.set_name(attachment['filename'])
                a.set_description(attachment['desc'])
                issue.add_attachment(a)

        if changes:
            for change in changes:
                changed_by = People(change['by']['id'])
                changed_by.set_name(change['by']['name'])
                issue.add_change(Change(change['field'], change['old_value'],
                                        'unknown', changed_by, change['date']))

        return issue