From aa6959d86e2d565f1369fb865bb335e57041b721 Mon Sep 17 00:00:00 2001 From: Orestis Ioannou Date: Sat, 20 Jun 2015 09:23:15 +0200 Subject: [PATCH 1/2] Add missing entry mirror_archive_dir in travis and docker config --- contrib/docker/config.ini | 1 + etc/config.travis.ini | 1 + 2 files changed, 2 insertions(+) diff --git a/contrib/docker/config.ini b/contrib/docker/config.ini index 0b9fce46..e6431f95 100644 --- a/contrib/docker/config.ini +++ b/contrib/docker/config.ini @@ -13,6 +13,7 @@ sources_dir: %(mirror_dir)s/pool python_dir: %(root_dir)s/python mirror_dir: %(root_dir)s/testdata/mirror pool_dir: %(mirror_dir)s/pool +mirror_archive_dir: %(root_dir)s/testdata/archive dry_run: false # echoes or not the SQL requests to stdout (can be logged with Apache): sqlalchemy_echo: false diff --git a/etc/config.travis.ini b/etc/config.travis.ini index cb4bb5e0..73d9bf15 100644 --- a/etc/config.travis.ini +++ b/etc/config.travis.ini @@ -13,6 +13,7 @@ sources_dir: %(mirror_dir)s/pool python_dir: %(root_dir)s/python mirror_dir: %(root_dir)s/testdata/mirror pool_dir: %(mirror_dir)s/pool +mirror_archive_dir: %(root_dir)s/testdata/archive dry_run: false # echoes or not the SQL requests to stdout (can be logged with Apache): sqlalchemy_echo: false From 7daa2677b579bc418303b463cf57741976ac2237 Mon Sep 17 00:00:00 2001 From: Orestis Ioannou Date: Sat, 20 Jun 2015 09:24:36 +0200 Subject: [PATCH 2/2] charts: add sticky suites in bar chart, enable refresh of charts Bar charts now take into account the sticky suites as well. The suite-archive has a new action refresh that refreshes a stage for example --stage charts will replot charts for sticky suites --- bin/debsources-suite-archive | 9 +++++++-- debsources/statistics.py | 4 +++- debsources/updater.py | 17 ++++++++++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/bin/debsources-suite-archive b/bin/debsources-suite-archive index 131fecae..99b0e0ee 100755 --- a/bin/debsources-suite-archive +++ b/bin/debsources-suite-archive @@ -23,13 +23,14 @@ import sys from debsources import archiver from debsources import debmirror from debsources import mainlib +from debsources import updater def main(): cmdline = argparse.ArgumentParser(description='Debsources suite ' 'archive manager') cmdline.add_argument('action', metavar='ACTION', - choices=['add', 'list', 'remove'], + choices=['add', 'list', 'remove', 'refresh'], help='action to perform on the archive of ' 'sticky suites') cmdline.add_argument('suite', metavar='SUITE', nargs='?', default=None, @@ -39,7 +40,8 @@ def main(): args = cmdline.parse_args() if args.action in ['add', 'remove'] and args.suite is None: cmdline.error('%s requires a suite name' % args.action) - + if args.action == 'refresh' and args.stages is None: + cmdline.error('%s requires a stage' % args.action) conf = mainlib.load_conf(args.conffile or mainlib.guess_conffile()) mainlib.override_conf(conf, args) mainlib.init_logging(conf, mainlib.log_level_of_verbosity(args.verbose)) @@ -62,6 +64,9 @@ def main(): (suite, present['db'], present['archive'])) elif args.action == 'remove': archiver.remove_suite(conf, session, args.suite) + elif args.action == 'refresh': + conf['refresh'] = True + updater.update(conf, session, stages=conf['stages']) if conf['single_transaction']: session.commit() except SystemExit: # exit as requested diff --git a/debsources/statistics.py b/debsources/statistics.py index 13583468..dbbf7b0e 100644 --- a/debsources/statistics.py +++ b/debsources/statistics.py @@ -60,13 +60,15 @@ def suites(session, suites='release'): return sorted(db_suites, cmp=by_release_date) -def sticky_suites(session): +def sticky_suites(session, order=None): """list sticky suites currently present in Debsources DB """ q = session.query(SuiteInfo.name) \ .filter(SuiteInfo.sticky == True) # NOQA, # '== True' can be dropped starting with sqlalchemy >= 0.8 + if order: + q = q.order_by("release_date") return [row[0] for row in q] diff --git a/debsources/updater.py b/debsources/updater.py index 542cdcb2..4410231c 100644 --- a/debsources/updater.py +++ b/debsources/updater.py @@ -525,7 +525,10 @@ def update_charts(status, conf, session, suites=None): from debsources import charts logging.info('update charts...') ensure_stats_dir(conf) - suites = __target_suites(session, suites) + if 'refresh' in conf.keys(): + suites = statistics.sticky_suites(session, True) + else: + suites = __target_suites(session, suites) CHARTS = [ # paris ('1 month', 'hourly'), @@ -560,26 +563,30 @@ def update_charts(status, conf, session, suites=None): 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 + all_suites = statistics.sticky_suites(session, True) \ + + __target_suites(session, None) + sloc_per_suite = [] + for suite in all_suites: + slocs = statistics.sloccount_summary(session, suite=suite) + sloc_per_suite.append(slocs) + 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) + charts.bar_chart(sloc_per_suite, all_suites, chart_file, top_langs) # update stages (STAGE_EXTRACT,