From f3e0280716152c7c977202862504fb6c53b18b9e Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 8 Jan 2014 17:10:53 +0000 Subject: [PATCH] Improve error handling when calling ck2cti and ctml_writer Only look for modules in the new location (inside the cantera package), and print the path if they aren't found, to aid in debugging. --- src/base/ct2ctml.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/base/ct2ctml.cpp b/src/base/ct2ctml.cpp index f8c17b9db..a3519d250 100644 --- a/src/base/ct2ctml.cpp +++ b/src/base/ct2ctml.cpp @@ -78,9 +78,10 @@ void ct2ctml(const char* file, const int debug) " try:\n" << " from cantera import ctml_writer\n" << " except ImportError:\n" << - " import ctml_writer\n" << + " print('sys.path: ' + repr(sys.path) + '\\n')\n" << + " raise\n" << " ctml_writer.convert(r'" << file << "')\n" << - " sys.exit(0)\n\n" + " sys.exit(0)\n\n" << "sys.exit(7)\n"; python.close_in(); std::string line; @@ -154,9 +155,10 @@ void ck2cti(const std::string& in_file, const std::string& thermo_file, " import sys\n" << " sys.stderr = sys.stdout\n" << " try:\n" << - " from cantera import ck2cti\n" << // Cython module + " from cantera import ck2cti\n" << " except ImportError:\n" << - " import ck2cti\n" << // legacy Python module + " print('sys.path: ' + repr(sys.path))\n" << + " raise\n" " ck2cti.Parser().convertMech(r'" << in_file << "',"; if (thermo_file != "" && thermo_file != "-") { pyin << " thermoFile=r'" << thermo_file << "',"; @@ -165,7 +167,7 @@ void ck2cti(const std::string& in_file, const std::string& thermo_file, pyin << " transportFile=r'" << transport_file << "',"; } pyin << " phaseName='" << id_tag << "',"; - pyin << " permissive=True,"; + pyin << " permissive=True,"; pyin << " quiet=True)\n"; pyin << " sys.exit(0)\n\n"; pyin << "sys.exit(7)\n";