Add 'pip-update.py'

This commit is contained in:
Cyberes 2019-12-16 23:22:31 -07:00
parent 191d9f52b0
commit b6035e6048
1 changed files with 18 additions and 0 deletions

18
pip-update.py Normal file
View File

@ -0,0 +1,18 @@
import subprocess
import sys
import json
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