From 3bff8b0592313a2e165bb6735f9acf79ba6485bf Mon Sep 17 00:00:00 2001
From: Thomas Fetzer <thomas.fetzer@iws.uni-stuttgart.de>
Date: Tue, 28 Mar 2017 14:54:58 +0200
Subject: [PATCH] [postprocessing] Catch missing module, add colored help
 message indicating use of pvpython

---
 bin/postprocessing/extractlinedata.py          | 8 +++++---
 bin/postprocessing/extractpointdataovertime.py | 7 +++++--
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/bin/postprocessing/extractlinedata.py b/bin/postprocessing/extractlinedata.py
index 12861212f1..c0144c367c 100644
--- a/bin/postprocessing/extractlinedata.py
+++ b/bin/postprocessing/extractlinedata.py
@@ -5,10 +5,9 @@ import os
 
 # parse arguments
 parser = argparse.ArgumentParser(
-  prog='pvpython ' + sys.argv[0],
+  prog='\033[1m\033[94m' + 'pvpython' + '\033[0m' + ' ' + sys.argv[0],
   description='Extract data from the paraview plotOverLine filter.'
 )
-parser = argparse.ArgumentParser()
 parser.add_argument('-f', '--files', nargs='+', required=True, help="vtu files to be processed")
 parser.add_argument('-o', '--outputDirectory', default='', help="Directory to which the data files are written")
 parser.add_argument('-of', '--outFile', default='', help="Basename of the written csv file")
@@ -18,7 +17,10 @@ parser.add_argument('-r', '--resolution', type=int, default=1000, help='Resoluti
 parser.add_argument('-v', '--verbosity', type=int, default=2, help='Verbosity of the output. 1 = print progress. 2 = print data columns')
 args = vars(parser.parse_args())
 
-from paraview.simple import *
+try:
+    from paraview.simple import *
+except ImportError:
+    print("`paraview.simple` not found. Make sure using pvpython instead of python.")
 
 # import locations
 commonOutDirectory = False
diff --git a/bin/postprocessing/extractpointdataovertime.py b/bin/postprocessing/extractpointdataovertime.py
index d3c78c4da9..2fcf9394dd 100644
--- a/bin/postprocessing/extractpointdataovertime.py
+++ b/bin/postprocessing/extractpointdataovertime.py
@@ -6,7 +6,7 @@ import sys
 
 # parse arguments
 parser = argparse.ArgumentParser(
-  prog='pvpython ' + sys.argv[0],
+  prog='\033[1m\033[94m' + 'pvpython' + '\033[0m' + ' ' + sys.argv[0],
   description='Extract data from the paraview probeLocation and plotOverTime filters.'
 )
 parser.add_argument('-f', '--files', nargs='+', required=True, help="pvd files to be processed")
@@ -16,7 +16,10 @@ parser.add_argument('-p', '--point', type=float, nargs=3, required=True, help='C
 parser.add_argument('-v', '--verbosity', type=int, default=2, help='Verbosity of the output. 1 = print progress. 2 = print data columns')
 args = vars(parser.parse_args())
 
-from paraview.simple import *
+try:
+    from paraview.simple import *
+except ImportError:
+    print("`paraview.simple` not found. Make sure using pvpython instead of python.")
 
 # import locations
 commonOutDirectory = False
-- 
GitLab