Skip to content

Commit

Permalink
Per #1753, there are 3 calls to the user's python version throughout …
Browse files Browse the repository at this point in the history
…MET. Update all 3 to print consistent log message when writing/reading the temp file. In particular, print the system command that is being executed at Debug(4) to make it easier to replicate python embedding problems that may arise.
  • Loading branch information
John Halley Gotway committed Apr 16, 2021
1 parent ad553d7 commit e4134ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
21 changes: 13 additions & 8 deletions met/src/basic/vx_util/python_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ sublist = PyList_GetItem(main_list, index);

if ( ! sublist ) {

mlog << Error
<< "\n\n PyLineDataFile::make_data_line() -> nul sublist pointer!\n\n";
mlog << Error << "\nPyLineDataFile::make_data_line() ->"
<< "nul sublist pointer!\n\n";

exit ( 1 );

Expand All @@ -255,8 +255,8 @@ if ( ! sublist ) {

if ( ! PyList_Check(sublist) ) {

mlog << Error
<< "\n\n PyLineDataFile::make_data_line() -> python object is not a list!\n\n";
mlog << Error << "\nPyLineDataFile::make_data_line() ->"
<< "python object is not a list!\n\n";

exit ( 1 );

Expand Down Expand Up @@ -336,8 +336,7 @@ if ( PyErr_Occurred() ) {

PyErr_Print();

mlog << Error
<< "\nPyLineDataFile::do_straight() -> "
mlog << Error << "\nPyLineDataFile::do_straight() -> "
<< "an error occurred importing module "
<< '\"' << user_base.text() << "\"\n\n";

Expand Down Expand Up @@ -411,6 +410,9 @@ for (j=0; j<N; ++j) {

};

mlog << Debug(4) << "Writing temporary Python line data file:\n\t"
<< command << "\n";

status = system(command.text());

if ( status ) {
Expand All @@ -429,14 +431,17 @@ wrapper = generic_pickle_wrapper;

script = new Python3_Script (wrapper.text());

mlog << Debug(4) << "Reading temporary Python line data file: "
<< pickle_path << "\n";

script->read_pickle(list_name, pickle_path.text());

main_list = script->lookup(list_name);

if ( ! main_list ) {

mlog << Error
<< "\n\n PyLineDataFile::do_pickle() -> nul main list pointer!\n\n";
mlog << Error << "\nPyLineDataFile::do_pickle() ->"
<< "nul main list pointer!\n\n";

exit ( 1 );

Expand Down
9 changes: 6 additions & 3 deletions met/src/libcode/vx_data2d_python/python_dataplane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ for (j=1; j<user_script_argc; ++j) { // j starts at one, here

}

mlog << Debug(4) << "Writing temporary Python dataplane file:\n\t"
<< command << "\n";

status = system(command.text());

if ( status ) {
Expand Down Expand Up @@ -353,9 +356,6 @@ if ( PyErr_Occurred() ) {

}

mlog << Debug(3) << "Reading temporary tmp_nc file: "
<< tmp_nc_path << "\n";

//
// set the arguments
//
Expand All @@ -370,6 +370,9 @@ wa.set(a);

PySys_SetArgv (wa.wargc(), wa.wargv());

mlog << Debug(4) << "Reading temporary Python dataplane file: "
<< tmp_nc_path << "\n";

//
// import the python wrapper script as a module
//
Expand Down
6 changes: 6 additions & 0 deletions met/src/tools/other/ascii2nc/python_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ for (j=0; j<N; ++j) {

};

mlog << Debug(4) << "Writing temporary Python ascii observation file:\n\t"
<< command << "\n";

status = system(command.text());

if ( status ) {
Expand All @@ -379,6 +382,9 @@ wrapper = generic_python_wrapper;

Python3_Script script(wrapper.text());

mlog << Debug(4) << "Reading temporary Python ascii observation file: "
<< tmp_ascii_path << "\n";

script.import_read_tmp_ascii_py();

PyObject * dobj = script.read_tmp_ascii(tmp_ascii_path.text());
Expand Down

0 comments on commit e4134ab

Please sign in to comment.