[bts-link] 01/01: generate an overview of the last year executions

Sandro Tosi morph at moszumanska.debian.org
Wed Dec 23 03:53:41 UTC 2015


This is an automated email from the git hooks/post-receive script.

morph pushed a commit to branch master
in repository bts-link.

commit 4128833f531b5fd2f04ff5df7026e62253e3ccf2
Author: Sandro Tosi <morph at debian.org>
Date:   Wed Dec 23 03:53:35 2015 +0000

    generate an overview of the last year executions
---
 rrd/graph_rrd.py | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/rrd/graph_rrd.py b/rrd/graph_rrd.py
index 2d4bc35..2fb2be1 100755
--- a/rrd/graph_rrd.py
+++ b/rrd/graph_rrd.py
@@ -38,6 +38,8 @@
 
 import rrdtool
 import os.path
+import os
+import itertools
 
 history = ['3 months', '6 months',
            '1 year', '5 years', '10 years',
@@ -55,13 +57,18 @@ tags = {
         'U': 'unmatched/unconfigured bts',
         'X': 'bugs not existing',
 }
+tags['elapsed_time'] = 'Elapsed time'
+
+overview = ['A', 'C', 'E', 'T', 'U', 'elapsed_time']
+colors = dict(zip(overview,
+                  ['00CC00', '009900', 'CC0000', '0066CC', 'FF9900', 'CCCC00']
+             ))
+max_ov_tag_length = max(len(tags[x]) for x in overview)
 
 basedir = os.path.dirname(os.path.abspath(__file__))
 imgdir = os.path.join(basedir, '../htdocs/img')
 rrdfile = os.path.join(basedir, 'bts-link.rrd')
 
-tags['elapsed_time'] = 'Elapsed time'
-
 for ds in sorted(tags.keys()):
     for start in history:
         outfile = os.path.join(imgdir, ds + '_' + start.replace(' ', '') + '.png')
@@ -72,4 +79,29 @@ for ds in sorted(tags.keys()):
             '--title', '%s in the last %s' % (tags[ds], start),
             "DEF:%s=%s:%s:LAST" % (ds, rrdfile, ds),
             "LINE:%s#0000FF" % ds,
-        )
\ No newline at end of file
+        )
+
+outfile = os.path.join(imgdir, 'overview' + '.png' )
+rrdtool.graph(outfile,
+              "--start", "-1 year",
+              "--width", "600",
+              "--height", "250",
+              "--logarithmic",
+              '--title', 'bts-link last year executions overview',
+              # graph() expect to receive the directives one-by-one as arguments, but
+              # since we want to generate them dinamically, we need to force the expansions
+              # of the list with *
+              *(["DEF:%s=%s:%s:LAST" % (x, rrdfile, x) for x in overview]
+              +
+              # we can define alle the DEF at once, but LINE and GPRINT for each
+              # datasource need to be one next to each other
+              # since we generate a list of tuples, we unpack them using chain() which
+              # returns a generator, so we list() it
+              # we pad the Current string taking the max length of a tag in the overview
+              # and then removing the current string length
+              list(itertools.chain.from_iterable(
+                  ('LINE:%s#%s:%s' % (x, colors[x], tags[x]),
+                   'GPRINT:%s:LAST:%sCurrent\:%%8.2lf %%s' % (x, ' '*(max_ov_tag_length - len(tags[x]))), 'COMMENT:\\n') for x in overview
+                  ))
+              )
+        )

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bts-link/bts-link.git



More information about the bts-link-commits mailing list