Ubuntu Pastebin

Paste from daniel at Fri, 23 Jan 2015 10:13:17 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff --git a/runner b/runner
index 3582168..a02e9c9 100755
--- a/runner
+++ b/runner
@@ -7,6 +7,7 @@ from shutil                             import rmtree, copytree
 from logging                            import debug, error, basicConfig, DEBUG, WARNING
 from lib.argparse                       import ArgumentParser, RawDescriptionHelpFormatter
 import json
+import tempfile
 
 from lib.testsprops                     import TestProfiles, TestCollections
 from lib.test_attributes                import TestAttributes
@@ -214,10 +215,17 @@ class Runner():
     #
     def gather_test_results(self, test):
         user = getenv('USER')
-        result, output = sh('sudo chown -R %s.%s %s' % (user, user, self.autotest_results_root))
-        result, output = sh(r'sudo find %s -type d | xargs chmod +x' % (self.autotest_results_root))
+        tmpdir = tempfile.mkdtemp()
+        try:
+            sh('sudo cp -r {} {}'.format(self.autotest_results_root, tmpdir))
+            tmp_results_dir = path.join(
+                tmpdir, path.basename(self.autotest_results_root))
+            sh('sudo chown -R {}.{} {}'.format(user, user, tmp_results_dir))
+            sh('sudo find {} -type d | xargs chmod +x'.format(tmp_results_dir))
+            copytree(tmp_results_dir, self.per_test_results_root)
+        finally:
+            rmtree(tmpdir, ignore_errors=True)
 
-        copytree(self.autotest_results_root, self.per_test_results_root)
 
     # install_required_packages
     #
Download as text