示例#1
0
    def get_timestamp(self):
        """ Returns a datetime object """
        timestamp, microseconds = self.timestamp.split('.')
        microseconds, _ = microseconds.split('Z')
        if len(microseconds) > 6:
            # Version One returns 7 digits of microseconds which is non-standard
            microseconds = microseconds[:6]

        return parse("{0}.{1}Z".format(timestamp, microseconds))
示例#2
0
    def test_report(self, plugin):
        self.config.process_boolean_config('list_archived')
        self.config.process_boolean_config('list_tasks')
        self.config.process_date_config('created_after')
        self.config.process_date_config('created_before')
        self.config.process_boolean_config('show_progress')

        app_list = plugin.api.get_applications()

        csv_file = csv.writer(open(self.config['write_file'], 'wb'))
        header = ['Application', 'Project', 'Created', 'Creator']
        if self.config['list_tasks']:
            header += ['Task', 'Weakness', 'Status']

        csv_file.writerow(header)

        for app_ind in xrange(len(app_list)):
            app = app_list[app_ind]
            if self.config['show_progress']:
                print "Progress: %2d %% - App: %s" % (int(float(app_ind + 1) * 100 / len(app_list)), app['name'])
            logger.info('Going through App: %s' % (app['name']))
            args = {}
            # TODO: Once the server side bug is fixed, use this instead of listing all
            # if not self.config['list_archived']:
            #     args['archived'] = 'false'
            proj_list = plugin.api.get_projects(app['id'], **args)

            for proj_ind in xrange(len(proj_list)):
                proj = proj_list[proj_ind]
                if not self.config['list_archived']:
                    if proj['archived']:
                        continue
                create_date = iso8601.parse(proj['created'])
                if create_date.date() < self.config['created_after']:
                    continue
                if create_date.date() > self.config['created_before']:
                    continue
                logger.info('Going through Project: %s' % (proj['name']))

                row = [app['name'], proj['name'], create_date, proj['creator']]
                if not self.config['list_tasks']:
                    csv_file.writerow(row)
                    continue
                if self.config['show_progress']:
                    print "    Prj (%d / %d): %s" % (proj_ind + 1, len(proj_list), proj['name'])

                task_list = plugin.api.get_tasks(proj['id'], {'include': 'problem'})
                for task_ind in xrange(len(task_list)):
                    task = task_list[task_ind]
                    csv_file.writerow(row + [task['title'], task['problem']['title'], task['status']])
示例#3
0
    def _determine_latest(self, alm_task, sde_task):
        """
        Used in synchronize() for the timestamp conflict policy to determine which
        task status takes precedence. Extracted from synchronize() so it is easier
        to test.
        """
        if 'status_updated' not in sde_task:
            raise AlmException('SDE does not support timestamp conflict policy')
        if sde_task['status_updated'] is None:
            return 'alm'

        sde_time = parse(sde_task['status_updated'])
        alm_time = alm_task.get_timestamp()
        logger.debug('Comparing timestamps for task %s - SDE: %s, ALM: %s' %
                     (sde_task['id'], str(sde_time), str(alm_time)))

        return 'sde' if sde_time > alm_time else 'alm'
示例#4
0
 def get_timestamp(self):
     """ Returns a datetime object """
     return parse(self.timestamp)