Пример #1
0
    def _import_issues(self):
        # show progress bar
        progress = DisplayProgress(len(self.jiraData['issues']),
                                   'Issues')
        
        # import new issues into trac
        for issue in self.jiraData['issues']:
            # TODO: version
            description = issue['description']            
            reporter = issue['reporter']
            owner = issue['assignee']
            summary = issue['summary']
            time = issue['created']
            status = self._get_item(issue['status'], 'statuses')
            component = self._get_item(issue['project'], 'projects')
            resolution = self._get_item(issue['resolution'], 'resolutions')
            type = self._get_item(issue['type'], 'issueTypes')
            priority = self._get_item(issue['priority'], 'priorities')
            comments = self._get_comments(issue['id'])
            attachments = self._get_attachments(issue['id'])

            attr = {'reporter': reporter, 'owner': owner, 'component': component,
                    'type': type, 'priority': priority, 'status': status}

            if resolution is not None:
                attr['resolution'] = resolution

            # import issue in trac
            id = self.proxy.ticket.create(summary, description, time, attr)

            # import associated comments for issue in trac
            cnum = 0
            for comment in comments:
                cnum += 1
                self.proxy.ticket.update(id, comment['body'], comment['created'],
                                         comment['author'], cnum+1)

            # import associated attachments for issue in trac
            for attachment in attachments:
                author = attachment['author']
                description = ''
                key = issue['key']
                created = attachment['created']
                filename = attachment['filename']
                path = self._get_attachment_path(attachment['attachmentId'], key,
                                               filename)
                if os.path.exists(path):
                    file = open(path, 'rb').read()
                    data = client.Binary(file)
                    self.proxy.ticket.putAttachment(id, filename, description,
                                            data, author, created, False)
            progress.update()

        log.info('  {} Actions'.format(len(self.jiraData['actions'])))
        log.info('  {} Attachments'.format(len(self.jiraData['attachments'])))
Пример #2
0
    def _import_issue_types(self):
        # get existing issue types from trac
        issueTypes = self.proxy.ticket.type.getAll()

        # remove existing issue types from trac if necessary
        if len(issueTypes) > 0:
            for issueType in issueTypes:
                self.proxy.ticket.type.delete(issueType)

        # show progress bar
        progress = DisplayProgress(len(self.jiraData['issueTypes']),
                                   'Issue Types')

        # import new issue types into trac
        for issueType in self.jiraData['issueTypes']:
            name = issueType['name']
            order = issueType['sequence']
            self.proxy.ticket.type.create(name, order)
            progress.update()
Пример #3
0
    def _importIssueTypes(self):
        # get existing issue types from trac
        issueTypes = self.proxy.ticket.type.getAll()

        # remove existing issue types from trac if necessary
        if len(issueTypes) > 0:
            for issueType in issueTypes:
                self.proxy.ticket.type.delete(issueType)

        # show progress bar
        progress = DisplayProgress(len(self.jiraData['issueTypes']),
                                   'Issue Types')

        # import new issue types into trac
        for issueType in self.jiraData['issueTypes']:
            name = issueType['name']
            order = issueType['sequence']
            self.proxy.ticket.type.create(name, order)
            progress.update()
Пример #4
0
    def _import_priorities(self):
        # get existing priorities from trac
        priorities = self.proxy.ticket.priority.getAll()

        # remove existing priorities from trac if necessary
        if len(priorities) > 0:
            for priority in priorities:
                self.proxy.ticket.priority.delete(priority)

        # show progress bar
        progress = DisplayProgress(len(self.jiraData['priorities']),
                                   'Priorities')

        # import new priorities into trac
        order = 1
        for priority in self.jiraData['priorities']:
            name = priority['name']
            self.proxy.ticket.priority.create(name, order)
            order += 1
            progress.update()
Пример #5
0
    def _import_resolutions(self):
        # get existing resolutions from trac
        resolutions = self.proxy.ticket.resolution.getAll()

        # remove existing resolutions from trac if necessary
        if len(resolutions) > 0:
            for resolution in resolutions:
                self.proxy.ticket.resolution.delete(resolution)

        # show progress bar
        progress = DisplayProgress(len(self.jiraData['resolutions']),
                                    'Resolutions')

        # import new resolutions into trac
        order = 1
        for resolution in self.jiraData['resolutions']:
            name = resolution['name']
            self.proxy.ticket.resolution.create(name, order)
            order += 1
            progress.update()
Пример #6
0
    def _importPriorities(self):
        # get existing priorities from trac
        priorities = self.proxy.ticket.priority.getAll()

        # remove existing priorities from trac if necessary
        if len(priorities) > 0:
            for priority in priorities:
                self.proxy.ticket.priority.delete(priority)

        # show progress bar
        progress = DisplayProgress(len(self.jiraData['priorities']),
                                   'Priorities')

        # import new priorities into trac
        order = 1
        for priority in self.jiraData['priorities']:
            name = priority['name']
            self.proxy.ticket.priority.create(name, order)
            order += 1
            progress.update()
Пример #7
0
    def _importResolutions(self):
        # get existing resolutions from trac
        resolutions = self.proxy.ticket.resolution.getAll()

        # remove existing resolutions from trac if necessary
        if len(resolutions) > 0:
            for resolution in resolutions:
                self.proxy.ticket.resolution.delete(resolution)

        # show progress bar
        progress = DisplayProgress(len(self.jiraData['resolutions']),
                                   'Resolutions')

        # import new resolutions into trac
        order = 1
        for resolution in self.jiraData['resolutions']:
            name = resolution['name']
            self.proxy.ticket.resolution.create(name, order)
            order += 1
            progress.update()
Пример #8
0
    def _importVersions(self):
        # get existing versions from trac
        versions = self.proxy.ticket.version.getAll()

        # remove existing versions from trac if necessary
        if len(versions) > 0:
            for version in versions:
                self.proxy.ticket.version.delete(version)

        # show progress bar
        progress = DisplayProgress(len(self.jiraData['versions']), 'Versions')

        # import new versions into trac
        for version in self.jiraData['versions']:
            # exclude trailing 'v' from version number
            nr = version['number'][1:]
            desc = version['description']
            date = version['releasedate']
            attr = {'name': nr, 'time': date, 'description': desc}
            self.proxy.ticket.version.create(nr, attr)
            progress.update()
Пример #9
0
    def _import_versions(self):
        # get existing versions from trac
        versions = self.proxy.ticket.version.getAll()

        # remove existing versions from trac if necessary
        if len(versions) > 0:
            for version in versions:
                self.proxy.ticket.version.delete(version)

        # show progress bar
        progress = DisplayProgress(len(self.jiraData['versions']),
                                   'Versions')
        
        # import new versions into trac
        for version in self.jiraData['versions']:
            # exclude trailing 'v' from version number
            nr = version['number'][1:]
            desc = version['description']
            date = version['releasedate']
            attr = {'name': nr, 'time': date, 'description': desc}
            self.proxy.ticket.version.create(nr, attr)
            progress.update()
Пример #10
0
    def _import_components(self):
        # get existing components from trac
        components = self.proxy.ticket.component.getAll()

        # remove existing components from trac if necessary
        if len(components) > 0:
            for component in components:
                self.proxy.ticket.component.delete(component)

        # show progress bar
        progress = DisplayProgress(len(self.jiraData['projects']),
                                   'Components')

        # import new components into trac
        # note: we import jira's projects as components into trac because
        # components in jira are children of projects, and trac doesn't
        # support this type of hierarchy
        for component in self.jiraData['projects']:
            name = component['name']
            owner = component['owner']
            desc = component['description']
            attr = {'name': name, 'owner': owner, 'description': desc}
            self.proxy.ticket.component.create(name, attr)
            progress.update()
Пример #11
0
    def _importComponents(self):
        # get existing components from trac
        components = self.proxy.ticket.component.getAll()

        # remove existing components from trac if necessary
        if len(components) > 0:
            for component in components:
                self.proxy.ticket.component.delete(component)

        # show progress bar
        progress = DisplayProgress(len(self.jiraData['projects']),
                                   'Components')

        # import new components into trac
        # note: we import jira's projects as components into trac because
        # components in jira are children of projects, and trac doesn't
        # support this type of hierarchy
        for component in self.jiraData['projects']:
            name = component['name']
            owner = component['owner']
            desc = component['description']
            attr = {'name': name, 'owner': owner, 'description': desc}
            self.proxy.ticket.component.create(name, attr)
            progress.update()
Пример #12
0
    def _importIssues(self):
        # show progress bar
        progress = DisplayProgress(len(self.jiraData['issues']), 'Issues')

        # import new issues into trac
        for issue in self.jiraData['issues']:
            # TODO: version
            description = issue['description']
            reporter = issue['reporter']
            owner = issue['assignee']
            summary = issue['summary']
            time = issue['created']
            status = self._getItem(issue['status'], 'statuses')
            component = self._getItem(issue['project'], 'projects')
            resolution = self._getItem(issue['resolution'], 'resolutions')
            type = self._getItem(issue['type'], 'issueTypes')
            priority = self._getItem(issue['priority'], 'priorities')
            comments = self._getComments(issue['id'])
            attachments = self._getAttachments(issue['id'])

            attr = {
                'reporter': reporter,
                'owner': owner,
                'component': component,
                'type': type,
                'priority': priority,
                'status': status
            }

            if resolution is not None:
                attr['resolution'] = resolution

            # import issue in trac
            id = self.proxy.ticket.create(summary, description, time, attr)

            # import associated comments for issue in trac
            cnum = 0
            for comment in comments:
                cnum += 1
                self.proxy.ticket.update(id, comment['body'],
                                         comment['created'], comment['author'],
                                         cnum + 1)

            # import associated attachments for issue in trac
            for attachment in attachments:
                author = attachment['author']
                description = ''
                key = issue['key']
                created = attachment['created']
                filename = attachment['filename']
                path = self._getAttachmentPath(attachment['attachmentId'], key,
                                               filename)
                if os.path.exists(path):
                    file = open(path, 'rb').read()
                    data = client.Binary(file)
                    self.proxy.ticket.putAttachment(id, filename, description,
                                                    data, author, created,
                                                    False)
            progress.update()

        log.info('  %d Actions' % len(self.jiraData['actions']))
        log.info('  %d Attachments' % len(self.jiraData['attachments']))