From aad0e9be44e612fa1399d38e1971f8aef2996560 Mon Sep 17 00:00:00 2001 From: skyanth Date: Tue, 29 Nov 2016 16:58:20 +0100 Subject: [PATCH] execsummary=true now also still builds report instead of just summary --- chatops/bash/handler_build | 1 + chatops/python/docbuilder.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/chatops/bash/handler_build b/chatops/bash/handler_build index 01cce2a..49452ec 100644 --- a/chatops/bash/handler_build +++ b/chatops/bash/handler_build @@ -113,6 +113,7 @@ build() { add_to_repo() { git add target/$TARGET-latest.pdf git add target/waiver_?*.pdf &>/dev/null + git add target/execsummary.pdf &>/dev/null git commit -q -m "$targetpdf proudly manufactured using ChatOps" &>/dev/null git push -q >/dev/null } diff --git a/chatops/python/docbuilder.py b/chatops/python/docbuilder.py index af4530a..a1c85d6 100644 --- a/chatops/python/docbuilder.py +++ b/chatops/python/docbuilder.py @@ -32,6 +32,7 @@ import textwrap GITREV = 'GITREV' # Magic tag which gets replaced by the git short commit hash OFFERTE = 'generate_offerte.xsl' # XSL for generating waivers WAIVER = 'waiver_' # prefix for waivers +EXECSUMMARY = 'execsummary' # generating an executive summary instead of a report def parse_arguments(): @@ -227,6 +228,23 @@ def main(): except OSError as exception: print_exit('[-] ERR: {0}'.format(exception.strerror), exception.errno) + if options['execsummary'] == 'true': # we're generating a summary as well as a report + report_output = options['output'] + verboseprint('generating additional executive summary') + output_dir = os.path.dirname(options['output']) + fop_dir = os.path.dirname(options['fop']) + try: + for fop in [os.path.splitext(x)[0] for x in + os.listdir(fop_dir) if x.endswith('fo')]: + if EXECSUMMARY in fop: + options['output'] = output_dir + os.sep + fop + '.pdf' + else: + options['output'] = report_output + options['fop'] = fop_dir + os.sep + fop + '.fo' + result = to_pdf(options) and result + except OSError as exception: + print_exit('[-] ERR: {0}'.format(exception.strerror), + exception.errno) else: result = to_pdf(options)