[Branch,~linaro-validation/lava-test/trunk] Rev 128: Added reset command

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

Commit Message

Le Chi Thu March 10, 2012, 1:23 p.m.
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/add-reset-command/+merge/96013
  proposed by: Le Chi Thu (le-chi-thu)
  review: Approve - Zygmunt Krynicki (zkrynicki)
  review: Resubmit - Le Chi Thu (le-chi-thu)
------------------------------------------------------------
revno: 128 [merge]
committer: Le Chi Thu le.chi.thu@linaro.org <le.chi.thu@linaro.org>
branch nick: trunk
timestamp: Sat 2012-03-10 14:21:53 +0100
message:
  Added reset command
modified:
  doc/changes.rst
  lava_test/commands.py
  setup.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

Patch

=== modified file 'doc/changes.rst'
--- doc/changes.rst	2012-03-08 16:59:15 +0000
+++ doc/changes.rst	2012-03-10 13:21:53 +0000
@@ -1,6 +1,8 @@ 
 Version History
 ***************
 
+ * Add reset command
+
 .. _version_0_5:
 
 Version 0.5

=== modified file 'lava_test/commands.py'
--- lava_test/commands.py	2012-03-05 21:43:48 +0000
+++ lava_test/commands.py	2012-03-10 13:21:53 +0000
@@ -1,4 +1,4 @@ 
-# Copyright (c) 2010, 2011 Linaro
+# Copyright (c) 2010, 2011, 2012 Linaro
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -15,6 +15,7 @@ 
 import logging
 
 import os
+import shutil
 import subprocess
 
 from lava_tool.interface import Command as LavaCommand
@@ -27,7 +28,7 @@ 
 from lava_test.core.artifacts import TestArtifacts
 from lava_test.core.config import get_config
 from lava_test.core.loader import TestLoader
-
+from lava_test.utils import Cache
 
 class Command(LavaCommand, ITestInstallerObserver, ITestRunnerObserver):
 
@@ -431,3 +432,21 @@ 
             raise LavaCommandError("Unable to unregister test: %s" % exc)
         except KeyError:
             raise LavaCommandError("There is no test_url")
+
+
+class reset(Command):
+    """
+    Reset the lava-test environment by removing
+    cached items, all registerered simple declactive tests and configuration files
+    """
+
+    def invoke(self):
+        print "Delete " + self._config.configdir
+        shutil.rmtree(self._config.configdir, ignore_errors=True)
+        print "Delete " + self._config.installdir
+        shutil.rmtree(self._config.installdir, ignore_errors=True)
+        print "Delete " + self._config.resultsdir
+        shutil.rmtree(self._config.resultsdir, ignore_errors=True)
+        cache = Cache.get_instance()
+        print "Delete " + cache.cache_dir
+        shutil.rmtree(cache.cache_dir, ignore_errors=True)
\ No newline at end of file

=== modified file 'setup.py'
--- setup.py	2012-02-06 15:48:33 +0000
+++ setup.py	2012-03-02 14:21:13 +0000
@@ -1,6 +1,6 @@ 
 #!/usr/bin/env python
 
-# Copyright (c) 2010, 2011 Linaro
+# Copyright (c) 2010, 2011, 2012 Linaro
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -43,6 +43,7 @@ 
     show=lava_test.commands:show
     register_test=lava_test.commands:register_test
     unregister_test=lava_test.commands:unregister_test
+    reset=lava_test.commands:reset
     """,
     classifiers=[
         "Development Status :: 3 - Alpha",