=== modified file 'lava_test/commands.py'
@@ -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'
@@ -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'
@@ -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'
@@ -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)