rmtree only if it is temp dir. If user specifies out_path then do not rmtree it.
This commit is contained in:
		
					parent
					
						
							
								f6a5f56098
							
						
					
				
			
			
				commit
				
					
						0e2e90322b
					
				
			
		
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -138,13 +138,19 @@ def commandline():
 | 
				
			||||||
        # created in it.
 | 
					        # created in it.
 | 
				
			||||||
        if args_dict['out_path'] is None:
 | 
					        if args_dict['out_path'] is None:
 | 
				
			||||||
            args.out_path = tempfile.mkdtemp()
 | 
					            args.out_path = tempfile.mkdtemp()
 | 
				
			||||||
 | 
					            is_temp_dir = True
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            is_temp_dir = False
 | 
				
			||||||
        # if remote-exec and/or remote-copy args are None then user
 | 
					        # if remote-exec and/or remote-copy args are None then user
 | 
				
			||||||
        # didn't specify command line options nor env vars:
 | 
					        # didn't specify command line options nor env vars:
 | 
				
			||||||
        # inspect multiplexing options for default cdist.REMOTE_COPY/EXEC
 | 
					        # inspect multiplexing options for default cdist.REMOTE_COPY/EXEC
 | 
				
			||||||
        if args_dict['remote_copy'] is None or args_dict['remote_exec'] is None:
 | 
					        if args_dict['remote_copy'] is None or args_dict['remote_exec'] is None:
 | 
				
			||||||
            control_path_dir = args.out_path
 | 
					            control_path_dir = args.out_path
 | 
				
			||||||
            import atexit
 | 
					            # only rmtree if it is temp directory;
 | 
				
			||||||
            atexit.register(lambda: shutil.rmtree(control_path_dir))
 | 
					            # if user specifies out_path do not remove it
 | 
				
			||||||
 | 
					            if is_temp_dir:
 | 
				
			||||||
 | 
					                import atexit
 | 
				
			||||||
 | 
					                atexit.register(lambda: shutil.rmtree(control_path_dir))
 | 
				
			||||||
            mux_opts = inspect_ssh_mux_opts(control_path_dir)
 | 
					            mux_opts = inspect_ssh_mux_opts(control_path_dir)
 | 
				
			||||||
            if args_dict['remote_exec'] is None:
 | 
					            if args_dict['remote_exec'] is None:
 | 
				
			||||||
                args.remote_exec = cdist.REMOTE_EXEC + mux_opts
 | 
					                args.remote_exec = cdist.REMOTE_EXEC + mux_opts
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue