Search code examples
pythonsubprocesspipepopen

How to "apt full-upgrade" using a python script


I want to be able to 1) upgrade my RPi via python and 2) catch the results (as String) to see how things went. How can I do it passing also automatically any relevant -Y responses.


Solution

  • I eventually ended up using:

    command = ['apt', 'full-upgrade', '-y']
    result = str(subprocess.run(command, capture_output=True).stdout, 'ascii')