Closed as not planned
Description
Bug report
I am using subprocess
library to run command. I want to export xml file by using below functions. But the subprocess fails sometimes to export data. It was exporting previous command data from mobile screen. For the first run of grab_xml
it does not export data of current screen, its grabbing data of previous situation.
My function to run a command:
def run_cmd(cmd):
""" Runs scripts
Argumentss:
cmd -> string command for script
"""
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
out = str(proc.stdout.read())
return out
My function to export data:
def grab_xml():
run_cmd('adb -s device_id shell uiautomator dump && adb -s device_id pull /sdcard/window_dump.xml')
with open("window_dump.xml", encoding='utf8') as infile:
return str(infile.read())
Note: device_id means the id of device which is found by running adb devices
command in command prompt
Your environment
- CPython versions tested on: 3.10
- Operating system and architecture: Windows 10 and x64 PC.