Skip to content

Commit

Permalink
A couple of things to ease migration to new API. Refs #4399
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Apr 17, 2012
1 parent 2ca9f47 commit d6e3866
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Code/Mantid/Framework/API/src/Algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,23 @@ namespace Mantid
g_log.setName(this->name());
try
{
// Invoke init() method of the derived class inside a try/catch clause
try
{
this->init();
}
catch(std::runtime_error& ex)
{
g_log.error()<<"Error initializing main algorithm"<<ex.what();
g_log.error() << "Error initializing " << this->name() << " algorithm. " << ex.what();
throw;
}

// Indicate that this Algorithm has been initialized to prevent duplicate attempts.
setInitialized();
}
catch(std::runtime_error& ex)
{
throw;
}
// Unpleasant catch-all! Along with this, Gaudi version catches GaudiException & std::exception
// but doesn't really do anything except (print fatal) messages.
catch (...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@ void export_leaf_classes()
(arg("name"), arg("defaultValue"), arg("direction")=Direction::Input),
"Declares a named property where the type is taken from the type "
"of the defaultValue and mapped to an appropriate C++ type")

.def("getLogger", &AlgorithmWrapper::getLogger, return_value_policy<reference_existing_object>(),
"Returns a reference to this algorithm's logger")
.def("log", &AlgorithmWrapper::getLogger, return_value_policy<reference_existing_object>(),
"Returns a reference to this algorithm's logger") // Traditional name
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ void export_V3D()
.def("X", &V3D::X, return_value_policy< copy_const_reference >(), "Returns the X coordinate")
.def("Y", &V3D::Y, return_value_policy< copy_const_reference >(), "Returns the Y coordinate")
.def("Z", &V3D::Z, return_value_policy< copy_const_reference >(), "Returns the Z coordinate")
.def("getX", &V3D::X, return_value_policy< copy_const_reference >(), "Returns the X coordinate") // Traditional name
.def("getY", &V3D::Y, return_value_policy< copy_const_reference >(), "Returns the Y coordinate") // Traditional name
.def("getZ", &V3D::Z, return_value_policy< copy_const_reference >(), "Returns the Z coordinate") // Traditional name
.def("distance", &V3D::distance, "Returns the distance between this vector and another")
.def("angle", &V3D::angle, "Returns the angle between this vector and another")
.def("zenith", &V3D::zenith, "Returns the zenith between this vector and another")
Expand Down
9 changes: 6 additions & 3 deletions Code/Mantid/Framework/PythonInterface/mantid/simpleapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,12 @@ def translate():
for name, versions in algs.iteritems():
if name == "Load":
continue
# Create the algorithm object
_algm_object = algorithm_mgr.createUnmanaged(name, max(versions))
_algm_object.initialize()
try:
# Create the algorithm object
_algm_object = algorithm_mgr.createUnmanaged(name, max(versions))
_algm_object.initialize()
except Exception:
continue
create_algorithm(name, max(versions), _algm_object)
create_algorithm_dialog(name, max(versions), _algm_object)

Expand Down

0 comments on commit d6e3866

Please sign in to comment.