mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-11-04 07:51:21 +00:00 
			
		
		
		
	target: Align Target.background() LC_ALL and PATH
Make Target.background() behave like Target.execute(): * Set LC_ALL if force_locale is provided (defaults to "C") * Add the target bin folder to PATH
This commit is contained in:
		
				
					committed by
					
						
						Marc Bonnici
					
				
			
			
				
	
			
			
			
						parent
						
							d2b80ccaf9
						
					
				
				
					commit
					3bc98f855b
				
			@@ -536,10 +536,7 @@ class Target(object):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # execution
 | 
					    # execution
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def execute(self, command, timeout=None, check_exit_code=True,
 | 
					    def _prepare_cmd(self, command, force_locale):
 | 
				
			||||||
                as_root=False, strip_colors=True, will_succeed=False,
 | 
					 | 
				
			||||||
                force_locale='C'):
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # Force the locale if necessary for more predictable output
 | 
					        # Force the locale if necessary for more predictable output
 | 
				
			||||||
        if force_locale:
 | 
					        if force_locale:
 | 
				
			||||||
            # Use an explicit export so that the command is allowed to be any
 | 
					            # Use an explicit export so that the command is allowed to be any
 | 
				
			||||||
@@ -550,11 +547,20 @@ class Target(object):
 | 
				
			|||||||
        if self.executables_directory:
 | 
					        if self.executables_directory:
 | 
				
			||||||
            command = "export PATH={}:$PATH && {}".format(quote(self.executables_directory), command)
 | 
					            command = "export PATH={}:$PATH && {}".format(quote(self.executables_directory), command)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return command
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def execute(self, command, timeout=None, check_exit_code=True,
 | 
				
			||||||
 | 
					                as_root=False, strip_colors=True, will_succeed=False,
 | 
				
			||||||
 | 
					                force_locale='C'):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        command = self._prepare_cmd(command, force_locale)
 | 
				
			||||||
        return self.conn.execute(command, timeout=timeout,
 | 
					        return self.conn.execute(command, timeout=timeout,
 | 
				
			||||||
                check_exit_code=check_exit_code, as_root=as_root,
 | 
					                check_exit_code=check_exit_code, as_root=as_root,
 | 
				
			||||||
                strip_colors=strip_colors, will_succeed=will_succeed)
 | 
					                strip_colors=strip_colors, will_succeed=will_succeed)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def background(self, command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, as_root=False):
 | 
					    def background(self, command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, as_root=False,
 | 
				
			||||||
 | 
					                   force_locale='C'):
 | 
				
			||||||
 | 
					        command = self._prepare_cmd(command, force_locale)
 | 
				
			||||||
        return self.conn.background(command, stdout, stderr, as_root)
 | 
					        return self.conn.background(command, stdout, stderr, as_root)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def invoke(self, binary, args=None, in_directory=None, on_cpus=None,
 | 
					    def invoke(self, binary, args=None, in_directory=None, on_cpus=None,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user