mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-10-22 10:33:19 +01:00 
			
		
		
		
	adb_shell: fixing handling of line breaks at the end of the output
- adb protcol uses "\r\n" for line breaks. This is not handled by Python's line break translation, as not a file. So spliting on '\n' when extracting the exit code resulted in stray '\r' in the output. - adb_shell expects exit code to be echoed on the same line. This may not have been the case if latest output from executed command was not a complete line. An extra echo will now ensure that the exit code will be on its own line even in that case.
This commit is contained in:
		| @@ -293,14 +293,14 @@ def adb_shell(device, command, timeout=None, check_exit_code=False, as_root=Fals | ||||
|                                              escape_double_quotes(command)) | ||||
|     logger.debug(full_command) | ||||
|     if check_exit_code: | ||||
|         actual_command = "adb{} shell '({}); echo $?'".format(device_string, | ||||
|                                                               escape_single_quotes(command)) | ||||
|         actual_command = "adb{} shell '({}); echo; echo $?'".format(device_string, | ||||
|                                                                     escape_single_quotes(command)) | ||||
|         raw_output, error = check_output(actual_command, timeout, shell=True) | ||||
|         if raw_output: | ||||
|             try: | ||||
|                 output, exit_code, _ = raw_output.rsplit('\n', 2) | ||||
|                 output, exit_code, _ = raw_output.rsplit('\r\n', 2) | ||||
|             except ValueError: | ||||
|                 exit_code, _ = raw_output.rsplit('\n', 1) | ||||
|                 exit_code, _ = raw_output.rsplit('\r\n', 1) | ||||
|                 output = '' | ||||
|         else:  # raw_output is empty | ||||
|             exit_code = '969696'  # just because | ||||
|   | ||||
		Reference in New Issue
	
	Block a user