From patchwork Wed Jan 18 21:16:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Larson X-Patchwork-Id: 6283 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 826EC23E0E for ; Wed, 18 Jan 2012 21:16:16 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 57219A18125 for ; Wed, 18 Jan 2012 21:16:16 +0000 (UTC) Received: by bkbzt4 with SMTP id zt4so3567404bkb.11 for ; Wed, 18 Jan 2012 13:16:16 -0800 (PST) Received: by 10.204.41.143 with SMTP id o15mr9217480bke.63.1326921375788; Wed, 18 Jan 2012 13:16:15 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs160356bkc; Wed, 18 Jan 2012 13:16:15 -0800 (PST) Received: by 10.180.91.42 with SMTP id cb10mr34205433wib.15.1326921373928; Wed, 18 Jan 2012 13:16:13 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id j19si20435149wiv.43.2012.01.18.13.16.13 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Jan 2012 13:16:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Rncrd-0001R9-La for ; Wed, 18 Jan 2012 21:16:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 97F35E017D for ; Wed, 18 Jan 2012 21:16:13 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-test X-Launchpad-Branch: ~linaro-validation/lava-test/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 108 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [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> Date: Wed, 18 Jan 2012 21:16:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14681"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 6920517680874f8f33087a1d13e8e546b4d0b8e7 Merge authors: Le Chi Thu 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 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 === 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 . - +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 . +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 = '%(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)