From a550198851238fd0f7acba2c355f142f61ec4371 Mon Sep 17 00:00:00 2001
From: Stefano Borini <sborini@enthought.com>
Date: Mon, 21 May 2018 17:15:21 +0100
Subject: [PATCH] More robust initialization and fixed test failure

---
 force_bdss/core_mco_driver.py            | 11 +++++++++--
 force_bdss/tests/test_core_mco_driver.py |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/force_bdss/core_mco_driver.py b/force_bdss/core_mco_driver.py
index a75f1aa..fb940f7 100644
--- a/force_bdss/core_mco_driver.py
+++ b/force_bdss/core_mco_driver.py
@@ -25,7 +25,14 @@ class CoreMCODriver(BaseCoreDriver):
 
     @on_trait_change("application:started")
     def application_started(self):
-        mco = self.workflow.mco
+        try:
+            mco = self.mco
+        except Exception:
+            log.exception(
+                "Unable to obtain MCO with id '{}' from plugin '{}'."
+            )
+            sys.exit(1)
+
         try:
             mco.run(self.workflow.mco)
         except Exception:
@@ -35,7 +42,7 @@ class CoreMCODriver(BaseCoreDriver):
                 "programming error in the plugin.".format(
                     mco.factory.id,
                     mco.factory.plugin.id))
-            raise
+            sys.exit(1)
 
     @on_trait_change("application:stopping")
     def application_stopping(self):
diff --git a/force_bdss/tests/test_core_mco_driver.py b/force_bdss/tests/test_core_mco_driver.py
index 407244e..0c8fcbf 100644
--- a/force_bdss/tests/test_core_mco_driver.py
+++ b/force_bdss/tests/test_core_mco_driver.py
@@ -116,7 +116,7 @@ class TestCoreMCODriver(unittest.TestCase):
                  "'force.bdss.enthought.plugin.test.v0"
                  ".factory.probe_notification_listener' in plugin "
                  "'force.bdss.enthought.plugin.test.v0'. The listener will "
-                 "be dropped and computation will continue." ))
+                 "be dropped and computation will continue."))
 
     def test_finalize_error(self):
         driver = CoreMCODriver(
-- 
GitLab