[elbe-devel] [PATCH 1/6] filesystem: add debug mode Parameter to TmpdirFilesystem

Torben Hohn torben.hohn at linutronix.de
Tue Aug 28 18:41:25 CEST 2018


debugging things, that happen in TmpdirFilesystem, is not really
possible.

Add a debug parameter to TmpdirFilesystem.__init__() that makes
it leave the directory undeleted, and also makes it print out
the path to the directory.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/filesystem.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index 5fd97c60..c8c67d87 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -230,12 +230,18 @@ class Filesystem(object):
 
 
 class TmpdirFilesystem (Filesystem):
-    def __init__(self):
+    def __init__(self, debug=False):
         tmpdir = mkdtemp()
         Filesystem.__init__(self, tmpdir)
+        self.debug = debug
 
     def __del__(self):
-        shutil.rmtree(self.path, True)
+        if not self.debug:
+            # cleanup
+            shutil.rmtree(self.path, True)
+        else:
+            # debug mode, leave it there
+            print('leaving TmpdirFilesystem in "%s"' % self.path)
 
 
 hostfs = Filesystem('/')
-- 
2.11.0




More information about the elbe-devel mailing list