Beispiel #1
0
    def take_action(self, args):
        basedir = self.app.config['basedir']

        if not args.template_dir:
            args.template_dir = self.app.config.get('template_dir')

        if args.data is None:
            date = arrow.now()
            args.data = os.path.join(basedir,
                                     date.format('YYYYMMDD'),
                                     'bugs.json')

        with open(args.data) as fd:
            data = json.load(fd)

        date = arrow.get(data['metadata']['date']).format('YYYYMMDD')
        workdir = os.path.join(basedir, date)
        if not os.path.isdir(workdir):
            os.makedirs(workdir)

        attributes = self.app.config.get('report_attributes', {})
        report = RDOStats(data,
                          template_dir=args.template_dir,
                          attributes=attributes)

        if args.graph:
            report.attributes['graph'] = component_graph(report,
                                                         max_comp_len=25)

        if args.template:
            templates = args.template
        else:
            templates = default_templates

        if args.owners:
            templates.append('report-people.html')

        for template in templates:
            with open(os.path.join(workdir, template), 'w') as fd:
                LOG.info('generating %s', fd.name)
                fd.write(report.render(template))

        if args.components:
            for comp in report.components():
                with open(os.path.join(
                        workdir, 'report-%s.html' % comp), 'w') as fd:
                    LOG.info('generating %s', fd.name)
                    fd.write(report.render('report-ungrouped.html',
                                           component=comp))

        if args.latest:
            latest = os.path.join(basedir, 'latest')
            if os.path.islink(latest):
                os.unlink(latest)
            os.symlink(date, latest)
Beispiel #2
0
    def take_action(self, args):
        basedir = self.app.config['basedir']

        if not args.template_dir:
            args.template_dir = self.app.config.get('template_dir')

        with open(args.data) as fd:
            data = json.load(fd)

        update_bugs(data)
        report = RDOStats(data, template_dir=args.template_dir)
        print report.render('report-changed.html')