Add 'pip-update.py'
This commit is contained in:
parent
191d9f52b0
commit
b6035e6048
|
@ -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
|
Reference in New Issue