diff mbox

[Branch,~linaro-validation/lava-test/trunk] Rev 108: Fix bug 898092 - More detail error messages when parsing the out of tree json file

Message ID 20120118211613.3161.95517.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Paul Larson Jan. 18, 2012, 9:16 p.m. UTC
Merge authors:
  Le Chi Thu le.chi.thu@linaro.org <le.chi.thu@linaro.org>
Related merge proposals:
  https://code.launchpad.net/~le-chi-thu/lava-test/fix-898092/+merge/88548
  proposed by: Le Chi Thu (le-chi-thu)
  review: Resubmit - Le Chi Thu (le-chi-thu)
------------------------------------------------------------
revno: 108 [merge]
committer: Paul Larson <paul.larson@linaro.org>
branch nick: lava-test
timestamp: Wed 2012-01-18 15:11:25 -0600
message:
  Fix bug 898092 - More detail error messages when parsing the out of tree json file
modified:
  lava_test/commands.py
  lava_test/core/loader.py
  lava_test/core/providers.py
  lava_test/main.py


--
lp:lava-test
https://code.launchpad.net/~linaro-validation/lava-test/trunk

You are subscribed to branch lp:lava-test.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-test/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_test/commands.py'
--- lava_test/commands.py	2011-10-19 09:27:29 +0000
+++ lava_test/commands.py	2012-01-17 12:42:46 +0000
@@ -12,7 +12,7 @@ 
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
+import logging
 
 import os
 import subprocess
@@ -297,7 +297,7 @@ 
         artifacts.incorporate_parse_results(parse_results)
         self.say("Parsed {0} test results",
                  len(artifacts.bundle["test_runs"][0]["test_results"]))
-        print artifacts.dumps_bundle()
+        logging.debug(artifacts.dumps_bundle())
         if self.args.output:
             if not self.args.skip_attachments:
                 artifacts.attach_standard_files_to_bundle()

=== modified file 'lava_test/core/loader.py'
--- lava_test/core/loader.py	2011-09-12 09:19:10 +0000
+++ lava_test/core/loader.py	2012-01-17 12:42:46 +0000
@@ -16,6 +16,8 @@ 
 from __future__ import absolute_import
 from lava_test.core.config import get_config
 
+import logging
+
 class TestLoader(object):
     """
     Test loader.
@@ -52,8 +54,8 @@ 
                     "lava-test is not properly set up."
                     " Please read the README file")
             except ImportError, err:
-                print "Couldn't load module : %s . Maybe configuration needs to be updated" % module_name
-                print "The configuration is stored at %s" %(get_config().configdir)
+                logging.warning("Couldn't load module : %s . Maybe configuration needs to be updated" % module_name)
+                logging.warning("The configuration is stored at %s" %(get_config().configdir))
 
 
 

=== modified file 'lava_test/core/providers.py'
--- lava_test/core/providers.py	2011-10-13 10:20:52 +0000
+++ lava_test/core/providers.py	2012-01-17 12:42:46 +0000
@@ -12,12 +12,16 @@ 
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+import sys
+from urllib2 import URLError
 
 from lava_test.api.core import ITestProvider
 from lava_test.core.config import get_config
 from lava_test.core.tests import DeclarativeTest
 from lava_test.utils import Cache
 
+import logging
+
 
 class BuiltInProvider(ITestProvider):
     """
@@ -129,17 +133,22 @@ 
 
     @classmethod
     def unregister_remote_test(self, test_url):
-      config = get_config()  # This is a different config object from
+        config = get_config()  # This is a different config object from
                              # self._config
-      provider_config = config.get_provider_config(
-          "lava_test.core.providers:RegistryProvider")
-      if "entries" not in provider_config:
-          provider_config["entries"] = []
-      if test_url in provider_config["entries"]:
-          provider_config["entries"].remove(test_url)
-          config._save_registry()
-      else:
-          raise ValueError("This test is not registered")
+        provider_config = config.get_provider_config("lava_test.core.providers:RegistryProvider")
+
+        if "entries" not in provider_config:
+            provider_config["entries"] = []
+
+        logging.info("removing remote test : " + test_url)
+        for entry in provider_config["entries"]:
+          logging.debug("found entry = " + str(entry))
+
+        if test_url in provider_config["entries"]:
+            provider_config["found remote test : "].remove(test_url)
+            config._save_registry()
+        else:
+            raise ValueError("This test is not registered")
 
     def _load_remote_test(self, test_url):
         """
@@ -162,8 +171,19 @@ 
                 if test.test_id in self._cache:
                     raise ValueError("Duplicate test %s declared" % test.test_id)
                 self._cache[test.test_id] = test
-            except:
-                print("Warning: Failed to load test from '%s'" % test_url)
+            except IOError, err:
+                logging.warning("Failed to load the " + test_url)
+                if hasattr(e, 'reason'):
+                    logging.warning("WARNING: URL Reason: "+ e.reason)
+                elif hasattr(e, 'code'):
+                    logging.warning('WARNING: URL Error code: ' + e.code)
+                else:
+                    logging.exception("WARNING: Unknown IO error", str(err))
+            except ValueError, err:
+                logging.warning('Error found when parsing the' + test_url)
+            except Exception, err:
+                logging.warning('Failed to load the' + test_url)
+                logging.warning("Unknown exception : " + str(err))
 
     def __iter__(self):
         self._fill_cache()

=== modified file 'lava_test/main.py'
--- lava_test/main.py	2011-09-27 20:07:52 +0000
+++ lava_test/main.py	2012-01-17 12:42:46 +0000
@@ -39,6 +39,12 @@ 
 
     if logging_config_file != None:
         logging.config.fileConfig(logging_config_file)
+    else:
+        # config the python logging
+       FORMAT = '<LAVA_TEST>%(asctime)s %(levelname)s: %(message)s'
+       DATEFMT= '%Y-%m-%d %I:%M:%S %p'
+       logging.basicConfig(format=FORMAT,datefmt=DATEFMT)
+       logging.root.setLevel(logging.DEBUG)
 
     run_with_dispatcher_class(LAVATestDispatcher)