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

Torben Hohn torben.hohn at linutronix.de
Wed Sep 26 12:13:47 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 c0089173..300124a3 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -239,12 +239,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