From 3a9268086b3effb30bc5370159c2ff2b3c023757 Mon Sep 17 00:00:00 2001 From: Jonathan Golder Date: Wed, 17 Oct 2018 14:28:52 +0200 Subject: [PATCH] Check returncode of gnuplot to detect errors Do not try to upload image, if gnuplot run fails Issue #2 (https://git.golderweb.de/wiki/jogobot-euroexchange/issues/2) --- euroexchange/euroexchange.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/euroexchange/euroexchange.py b/euroexchange/euroexchange.py index 9e4286d..f55ced0 100644 --- a/euroexchange/euroexchange.py +++ b/euroexchange/euroexchange.py @@ -247,13 +247,18 @@ class EuroExchangeBot( pywikibot.bot.BaseBot ): # Check if update is necessary if self.image_update_needed(): - self.call_gnuplot( job ) + try: + self.call_gnuplot( job ) - if self.file_changed(): - self.upload_file( job ) - else: - jogobot.output( "No upload needed for Job {}.".format( - self.current_job.image) ) + if self.file_changed(): + self.upload_file( job ) + else: + jogobot.output( "No upload needed for Job {}.".format( + self.current_job.image) ) + + except subprocess.CalledProcessError as e: + jogobot.output( "Subprocess terminated with exit code {}!". + format( e.returncode), "ERROR" ) # Nothing to do else: @@ -299,7 +304,7 @@ class EuroExchangeBot( pywikibot.bot.BaseBot ): plt_env["INFILE"] = type(self).csv_file plt_env["OUTFILE"] = job.image - subprocess.call( cmd, cwd=self.wdir, env=plt_env ) + subprocess.check_call( cmd, cwd=self.wdir, env=plt_env ) def file_changed( self ): """