21 lines
764 B
Python
21 lines
764 B
Python
import subprocess
|
|
import sys
|
|
import json
|
|
|
|
# run this with sudo because sometimes packages require sudo to update/install
|
|
|
|
print('checking for updates...')
|
|
pipOut = subprocess.run('python3.7 -m pip list --outdated --format json', capture_output=True, encoding="utf-8", shell=True)
|
|
pipJson = json.loads(pipOut.stdout)
|
|
updatable = []
|
|
for x in pipJson:
|
|
i = 1
|
|
updatable.append(x['name'])
|
|
for x in updatable:
|
|
sys.stdout.write('\x1b[2K') # erase last line
|
|
sys.stdout.write('\rupdating {} {}/{}'.format(x, i, str(len(updatable))))
|
|
sys.stdout.flush()
|
|
process = subprocess.Popen('python3.7 -m pip install --upgrade ' + x, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
process.wait()
|
|
i = i + 1
|
|
print() |