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

Manuel Traut manut at linutronix.de
Fri Oct 12 16:44:36 CEST 2018


On Wed, Sep 26, 2018 at 12:13:47PM +0200, Torben Hohn wrote:
> 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>

ignored, because posted seperately and already applied.

> ---
>  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
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel



More information about the elbe-devel mailing list