Ejemplo n.º 1
0
def update_charts(status, conf, session, suites=None):
    """update stage: rebuild charts"""

    logging.info('update charts...')
    ensure_stats_dir(conf)
    suites = __target_suites(session, suites)

    CHARTS = [  # <period, granularity> paris
        ('1 month', 'hourly'),
        ('1 year', 'daily'),
        ('5 years', 'weekly'),
        ('20 years', 'monthly'),
    ]

    # size charts, various metrics
    for metric in ['source_packages', 'disk_usage', 'source_files', 'ctags']:
        for (period, granularity) in CHARTS:
            for suite in suites + ['ALL']:
                series = getattr(statistics, 'history_size_' + granularity)(
                    session, metric, interval=period, suite=suite)
                chart_file = os.path.join(conf['cache_dir'], 'stats',
                                          '%s-%s-%s.png' %
                                          (suite, metric,
                                           period.replace(' ', '-')))
                if not conf['dry_run']:
                    charts.size_plot(series, chart_file)

    # sloccount: historical histograms
    for (period, granularity) in CHARTS:
        for suite in suites + ['ALL']:
            # historical histogram
            mseries = getattr(statistics, 'history_sloc_' + granularity)(
                session, interval=period, suite=suite)
            chart_file = os.path.join(conf['cache_dir'], 'stats',
                                      '%s-sloc-%s.png' %
                                      (suite, period.replace(' ', '-')))
            if not conf['dry_run']:
                charts.sloc_plot(mseries, chart_file)

    # sloccount: current pie charts
    for suite in suites + ['ALL']:
        sloc_suite = suite
        if sloc_suite == 'ALL':
            sloc_suite = None
        slocs = statistics.sloccount_summary(session, suite=sloc_suite)
        chart_file = os.path.join(conf['cache_dir'], 'stats',
                                  '%s-sloc_pie-current.png' % suite)
        if not conf['dry_run']:
            charts.sloc_pie(slocs, chart_file)
Ejemplo n.º 2
0
def update_charts(status, conf, session, suites=None):
    """update stage: rebuild charts"""

    from debsources import charts

    logging.info("update charts...")
    ensure_stats_dir(conf)
    suites = __target_suites(session, suites)

    CHARTS = [  # <period, granularity> paris
        ("1 month", "hourly"),
        ("1 year", "daily"),
        ("5 years", "weekly"),
        ("20 years", "monthly"),
    ]

    # size charts, various metrics
    for metric in ["source_packages", "disk_usage", "source_files", "ctags"]:
        for (period, granularity) in CHARTS:
            for suite in suites + ["ALL"]:
                series = getattr(statistics, "history_size_" + granularity)(
                    session, metric, interval=period, suite=suite)
                filename = "%s-%s-%s.png" % (suite, metric,
                                             period.replace(" ", "-"))
                chart_file = conf["cache_dir"] / "stats" / filename
                if not conf["dry_run"]:
                    charts.size_plot(series, chart_file)

    # sloccount: historical histograms
    for (period, granularity) in CHARTS:
        for suite in suites + ["ALL"]:
            # historical histogram
            mseries = getattr(statistics,
                              "history_sloc_" + granularity)(session,
                                                             interval=period,
                                                             suite=suite)
            filename = "%s-sloc-%s.png" % (suite, period.replace(" ", "-"))
            chart_file = conf["cache_dir"] / "stats" / filename
            if not conf["dry_run"]:
                charts.multiseries_plot(mseries, chart_file)

    # sloccount: current pie charts
    sloc_per_suite = []
    for suite in suites + ["ALL"]:
        sloc_suite = suite
        if sloc_suite == "ALL":
            sloc_suite = None
        slocs = statistics.sloccount_summary(session, suite=sloc_suite)
        if suite not in ["ALL"]:
            sloc_per_suite.append(slocs)
        filename = "%s-sloc_pie-current.png" % suite
        chart_file = conf["cache_dir"] / "stats" / filename
        if not conf["dry_run"]:
            charts.pie_chart(slocs, chart_file)

    # sloccount: bar chart plot
    if "charts_top_langs" in conf.keys():
        top_langs = int(conf["charts_top_langs"])
    else:
        top_langs = 6
    chart_file = conf["cache_dir"] / "stats" / "sloc_bar_plot.png"
    charts.bar_chart(sloc_per_suite, suites, chart_file, top_langs, "SLOC")

    def update_license_charts():
        # License: historical histogramms
        for (period, granularity) in CHARTS:
            for suite in suites + ["ALL"]:
                mseries = getattr(statistics, "history_copyright_" +
                                  granularity)(session,
                                               interval=period,
                                               suite=suite)
                filename = "copyright_%s-license-%s.png" % (
                    suite,
                    period.replace(" ", "-"),
                )
                chart_file = conf["cache_dir"] / "stats" / filename
                if not conf["dry_run"]:
                    charts.multiseries_plot(mseries, chart_file, cols=3)

        # License: overall pie chart
        overall_licenses = statistics.licenses_summary(
            statistics.get_licenses(session, "ALL"))
        ratio = qry.get_ratio(session)
        chart_file = conf[
            "cache_dir"] / "stats" / "copyright_overall-license_pie.png"
        if not conf["dry_run"]:
            charts.pie_chart(overall_licenses, chart_file, ratio)

        # License: bar chart and per suite pie chart.
        all_suites = statistics.sticky_suites(session) + __target_suites(
            session, None)
        licenses_per_suite = []
        for suite in all_suites:
            licenses = statistics.licenses_summary(
                statistics.get_licenses(session, suite))
            ratio = qry.get_ratio(session, suite=suite)
            # draw license pie chart
            if not conf["dry_run"]:
                filename = "copyright_%s-license_pie-current.png" % suite
                chart_file = conf["cache_dir"] / "stats" / filename
                charts.pie_chart(licenses, chart_file, ratio)

            licenses_per_suite.append(licenses)

        chart_file = conf[
            "cache_dir"] / "stats" / "copyright_license_bar_plot.png"
        if not conf["dry_run"]:
            charts.bar_chart(licenses_per_suite, all_suites, chart_file,
                             top_langs, "Number of files")

    # LICENSE CHARTS
    if "copyright" in conf["hooks"]:
        update_license_charts()
Ejemplo n.º 3
0
def update_charts(status, conf, session, suites=None):
    """update stage: rebuild charts"""

    from debsources import charts
    logging.info('update charts...')
    ensure_stats_dir(conf)
    suites = __target_suites(session, suites)

    CHARTS = [  # <period, granularity> paris
        ('1 month', 'hourly'),
        ('1 year', 'daily'),
        ('5 years', 'weekly'),
        ('20 years', 'monthly'),
    ]

    # size charts, various metrics
    for metric in ['source_packages', 'disk_usage', 'source_files', 'ctags']:
        for (period, granularity) in CHARTS:
            for suite in suites + ['ALL']:
                series = getattr(statistics, 'history_size_' + granularity)(
                    session, metric, interval=period, suite=suite)
                chart_file = os.path.join(conf['cache_dir'], 'stats',
                                          '%s-%s-%s.png' %
                                          (suite, metric,
                                           period.replace(' ', '-')))
                if not conf['dry_run']:
                    charts.size_plot(series, chart_file)

    # sloccount: historical histograms
    for (period, granularity) in CHARTS:
        for suite in suites + ['ALL']:
            # historical histogram
            mseries = getattr(statistics, 'history_sloc_' + granularity)(
                session, interval=period, suite=suite)
            chart_file = os.path.join(conf['cache_dir'], 'stats',
                                      '%s-sloc-%s.png' %
                                      (suite, period.replace(' ', '-')))
            if not conf['dry_run']:
                charts.sloc_plot(mseries, chart_file)

    # sloccount: current pie charts
    sloc_per_suite = []
    for suite in suites + ['ALL']:
        sloc_suite = suite
        if sloc_suite == 'ALL':
            sloc_suite = None
        slocs = statistics.sloccount_summary(session, suite=sloc_suite)
        if suite not in ['ALL']:
            sloc_per_suite.append(slocs)
        chart_file = os.path.join(conf['cache_dir'], 'stats',
                                  '%s-sloc_pie-current.png' % suite)
        if not conf['dry_run']:
            charts.sloc_pie(slocs, chart_file)

    # sloccount: bar chart plot
    if 'charts_top_langs' in conf.keys():
        top_langs = int(conf['charts_top_langs'])
    else:
        top_langs = 6
    chart_file = os.path.join(conf['cache_dir'], 'stats', 'sloc_bar_plot.png')
    charts.bar_chart(sloc_per_suite, suites, chart_file, top_langs)
Ejemplo n.º 4
0
def update_charts(status, conf, session, suites=None):
    """update stage: rebuild charts"""

    from debsources import charts
    logging.info('update charts...')
    ensure_stats_dir(conf)
    suites = __target_suites(session, suites)

    CHARTS = [  # <period, granularity> paris
        ('1 month', 'hourly'),
        ('1 year', 'daily'),
        ('5 years', 'weekly'),
        ('20 years', 'monthly'),
    ]

    # size charts, various metrics
    for metric in ['source_packages', 'disk_usage', 'source_files', 'ctags']:
        for (period, granularity) in CHARTS:
            for suite in suites + ['ALL']:
                series = getattr(statistics, 'history_size_' + granularity)(
                    session, metric, interval=period, suite=suite)
                chart_file = os.path.join(conf['cache_dir'], 'stats',
                                          '%s-%s-%s.png' %
                                          (suite, metric,
                                           period.replace(' ', '-')))
                if not conf['dry_run']:
                    charts.size_plot(series, chart_file)

    # sloccount: historical histograms
    for (period, granularity) in CHARTS:
        for suite in suites + ['ALL']:
            # historical histogram
            mseries = getattr(statistics, 'history_sloc_' + granularity)(
                session, interval=period, suite=suite)
            chart_file = os.path.join(conf['cache_dir'], 'stats',
                                      '%s-sloc-%s.png' %
                                      (suite, period.replace(' ', '-')))
            if not conf['dry_run']:
                charts.multiseries_plot(mseries, chart_file)

    # sloccount: current pie charts
    sloc_per_suite = []
    for suite in suites + ['ALL']:
        sloc_suite = suite
        if sloc_suite == 'ALL':
            sloc_suite = None
        slocs = statistics.sloccount_summary(session, suite=sloc_suite)
        if suite not in ['ALL']:
            sloc_per_suite.append(slocs)
        chart_file = os.path.join(conf['cache_dir'], 'stats',
                                  '%s-sloc_pie-current.png' % suite)
        if not conf['dry_run']:
            charts.pie_chart(slocs, chart_file)

    # sloccount: bar chart plot
    if 'charts_top_langs' in conf.keys():
        top_langs = int(conf['charts_top_langs'])
    else:
        top_langs = 6
    chart_file = os.path.join(conf['cache_dir'], 'stats', 'sloc_bar_plot.png')
    charts.bar_chart(sloc_per_suite, suites, chart_file, top_langs, 'SLOC')

    def update_license_charts():
        # License: historical histogramms
        for (period, granularity) in CHARTS:
            for suite in suites + ['ALL']:
                mseries = getattr(statistics,
                                  'history_copyright_' + granularity)(
                    session, interval=period, suite=suite)
                chart_file = os.path.join(conf['cache_dir'], 'stats',
                                          'copyright_%s-license-%s.png' %
                                          (suite, period.replace(' ', '-')))
                if not conf['dry_run']:
                    charts.multiseries_plot(mseries, chart_file, cols=3)

        # License: overall pie chart
        overall_licenses = statistics.licenses_summary(
            statistics.get_licenses(session, 'ALL'))
        ratio = qry.get_ratio(session)
        chart_file = os.path.join(conf['cache_dir'], 'stats',
                                  'copyright_overall-license_pie.png')
        if not conf['dry_run']:
            charts.pie_chart(overall_licenses, chart_file, ratio)

        # License: bar chart and per suite pie chart.
        all_suites = statistics.sticky_suites(session) \
            + __target_suites(session, None)
        licenses_per_suite = []
        for suite in all_suites:
            licenses = statistics.licenses_summary(
                statistics.get_licenses(session, suite))
            ratio = qry.get_ratio(session, suite=suite)
            # draw license pie chart
            if not conf['dry_run']:
                chart_file = os.path.join(conf['cache_dir'], 'stats',
                                          'copyright_%s'
                                          '-license_pie-current.png'
                                          % suite)
                charts.pie_chart(licenses, chart_file, ratio)

            licenses_per_suite.append(licenses)

        chart_file = os.path.join(conf['cache_dir'], 'stats',
                                  'copyright_license_bar_plot.png')
        if not conf['dry_run']:
            charts.bar_chart(licenses_per_suite, all_suites, chart_file,
                             top_langs, 'Number of files')

    # LICENSE CHARTS
    if 'copyright' in conf['hooks']:
        update_license_charts()
Ejemplo n.º 5
0
def update_charts(status, conf, session, suites=None):
    """update stage: rebuild charts"""

    from debsources import charts
    logging.info('update charts...')
    ensure_stats_dir(conf)
    suites = __target_suites(session, suites)

    CHARTS = [  # <period, granularity> paris
        ('1 month', 'hourly'),
        ('1 year', 'daily'),
        ('5 years', 'weekly'),
        ('20 years', 'monthly'),
    ]

    # size charts, various metrics
    for metric in ['source_packages', 'disk_usage', 'source_files', 'ctags']:
        for (period, granularity) in CHARTS:
            for suite in suites + ['ALL']:
                series = getattr(statistics, 'history_size_' + granularity)(
                    session, metric, interval=period, suite=suite)
                chart_file = os.path.join(
                    conf['cache_dir'], 'stats',
                    '%s-%s-%s.png' % (suite, metric, period.replace(' ', '-')))
                if not conf['dry_run']:
                    charts.size_plot(series, chart_file)

    # sloccount: historical histograms
    for (period, granularity) in CHARTS:
        for suite in suites + ['ALL']:
            # historical histogram
            mseries = getattr(statistics,
                              'history_sloc_' + granularity)(session,
                                                             interval=period,
                                                             suite=suite)
            chart_file = os.path.join(
                conf['cache_dir'], 'stats',
                '%s-sloc-%s.png' % (suite, period.replace(' ', '-')))
            if not conf['dry_run']:
                charts.multiseries_plot(mseries, chart_file)

    # sloccount: current pie charts
    sloc_per_suite = []
    for suite in suites + ['ALL']:
        sloc_suite = suite
        if sloc_suite == 'ALL':
            sloc_suite = None
        slocs = statistics.sloccount_summary(session, suite=sloc_suite)
        if suite not in ['ALL']:
            sloc_per_suite.append(slocs)
        chart_file = os.path.join(conf['cache_dir'], 'stats',
                                  '%s-sloc_pie-current.png' % suite)
        if not conf['dry_run']:
            charts.pie_chart(slocs, chart_file)

    # sloccount: bar chart plot
    if 'charts_top_langs' in conf.keys():
        top_langs = int(conf['charts_top_langs'])
    else:
        top_langs = 6
    chart_file = os.path.join(conf['cache_dir'], 'stats', 'sloc_bar_plot.png')
    charts.bar_chart(sloc_per_suite, suites, chart_file, top_langs, 'SLOC')

    def update_license_charts():
        # License: historical histogramms
        for (period, granularity) in CHARTS:
            for suite in suites + ['ALL']:
                mseries = getattr(statistics, 'history_copyright_' +
                                  granularity)(session,
                                               interval=period,
                                               suite=suite)
                chart_file = os.path.join(
                    conf['cache_dir'], 'stats', 'copyright_%s-license-%s.png' %
                    (suite, period.replace(' ', '-')))
                if not conf['dry_run']:
                    charts.multiseries_plot(mseries, chart_file, cols=3)

        # License: overall pie chart
        overall_licenses = statistics.licenses_summary(
            statistics.get_licenses(session, 'ALL'))
        ratio = qry.get_ratio(session)
        chart_file = os.path.join(conf['cache_dir'], 'stats',
                                  'copyright_overall-license_pie.png')
        if not conf['dry_run']:
            charts.pie_chart(overall_licenses, chart_file, ratio)

        # License: bar chart and per suite pie chart.
        all_suites = statistics.sticky_suites(session) \
            + __target_suites(session, None)
        licenses_per_suite = []
        results = statistics.get_licenses(session)
        for suite in all_suites:
            temp = dict(
                (item[0], item[2]) for item in results if item[1] == suite)
            licenses = statistics.licenses_summary(temp)
            ratio = qry.get_ratio(session, suite=suite)
            # draw license pie chart
            if not conf['dry_run']:
                chart_file = os.path.join(
                    conf['cache_dir'], 'stats', 'copyright_%s'
                    '-license_pie-current.png' % suite)
                charts.pie_chart(licenses, chart_file, ratio)

            licenses_per_suite.append(licenses)

        chart_file = os.path.join(conf['cache_dir'], 'stats',
                                  'copyright_license_bar_plot.png')
        if not conf['dry_run']:
            charts.bar_chart(licenses_per_suite, all_suites, chart_file,
                             top_langs, 'Number of files')

    # LICENSE CHARTS
    if 'copyright' in conf['hooks']:
        update_license_charts()