Merge lp:~le-chi-thu/lava-test/add-reset-command into lp:lava-test/0.0

Proposed by Le Chi Thu
Status: Merged
Merged at revision: 128
Proposed branch: lp:~le-chi-thu/lava-test/add-reset-command
Merge into: lp:lava-test/0.0
Diff against target: 69 lines (+23/-3)
2 files modified
lava_test/commands.py (+21/-2)
setup.py (+2/-1)
To merge this branch: bzr merge lp:~le-chi-thu/lava-test/add-reset-command
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Le Chi Thu (community) Needs Resubmitting
Review via email: mp+96013@code.launchpad.net

Description of the change

When new test job run with out deploying a new test image, there are old test result, installed tests and cached out-of-tree tests in the test image file system you want to removed. This command will be used to remove them.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

30 +
31 + def invoke(self):
32 + print "Delete " + self._config.configdir
33 + os.system("rm -rf " + self._config.configdir)
34 + print "Delete " + self._config.installdir
35 + os.system("rm -rf " + self._config.installdir)
36 + print "Delete " + self._config.resultsdir
37 + os.system("rm -rf " + self._config.resultsdir)
38 + cache = Cache.get_instance()
39 + print "Delete " + cache.cache_dir
40 + os.system("rm -rf " + cache.cache_dir)

Please use shutil.rmtree(), os.system() is wrong and error prone on many levels.
Otherwise this is okay

review: Needs Fixing
Revision history for this message
Le Chi Thu (le-chi-thu) wrote :

Fixed

review: Needs Resubmitting
123. By Le Chi Thu <email address hidden> <email address hidden>

Replaced os.system with shutil.rmtree

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_test/commands.py'
2--- lava_test/commands.py 2012-03-06 12:59:07 +0000
3+++ lava_test/commands.py 2012-03-06 14:05:20 +0000
4@@ -1,4 +1,4 @@
5-# Copyright (c) 2010, 2011 Linaro
6+# Copyright (c) 2010, 2011, 2012 Linaro
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10@@ -15,6 +15,7 @@
11 import logging
12
13 import os
14+import shutil
15 import subprocess
16
17 from lava_tool.interface import Command as LavaCommand
18@@ -27,7 +28,7 @@
19 from lava_test.core.artifacts import TestArtifacts
20 from lava_test.core.config import get_config
21 from lava_test.core.loader import TestLoader
22-
23+from lava_test.utils import Cache
24
25 class Command(LavaCommand, ITestInstallerObserver, ITestRunnerObserver):
26
27@@ -411,3 +412,21 @@
28 raise LavaCommandError("Unable to unregister test: %s" % exc)
29 except KeyError:
30 raise LavaCommandError("There is no test_url")
31+
32+
33+class reset(Command):
34+ """
35+ Reset the lava-test environment by removing
36+ cached items, all registerered simple declactive tests and configuration files
37+ """
38+
39+ def invoke(self):
40+ print "Delete " + self._config.configdir
41+ shutil.rmtree(self._config.configdir, ignore_errors=True)
42+ print "Delete " + self._config.installdir
43+ shutil.rmtree(self._config.installdir, ignore_errors=True)
44+ print "Delete " + self._config.resultsdir
45+ shutil.rmtree(self._config.resultsdir, ignore_errors=True)
46+ cache = Cache.get_instance()
47+ print "Delete " + cache.cache_dir
48+ shutil.rmtree(cache.cache_dir, ignore_errors=True)
49\ No newline at end of file
50
51=== modified file 'setup.py'
52--- setup.py 2012-02-06 15:48:33 +0000
53+++ setup.py 2012-03-06 14:05:20 +0000
54@@ -1,6 +1,6 @@
55 #!/usr/bin/env python
56
57-# Copyright (c) 2010, 2011 Linaro
58+# Copyright (c) 2010, 2011, 2012 Linaro
59 #
60 # This program is free software: you can redistribute it and/or modify
61 # it under the terms of the GNU General Public License as published by
62@@ -43,6 +43,7 @@
63 show=lava_test.commands:show
64 register_test=lava_test.commands:register_test
65 unregister_test=lava_test.commands:unregister_test
66+ reset=lava_test.commands:reset
67 """,
68 classifiers=[
69 "Development Status :: 3 - Alpha",

Subscribers

People subscribed via source and target branches