welcom ! Handel home

2016年5月10日 星期二

pip auto update the package tool Demo


PIP command example : 操作命令

  • pip list # 看目前系統有安裝哪些套件
  • pip search mysql # 搜尋相關套件
  • pip install package # 安裝套件
  • pip uninstall package # 移除套件
  • pip show --files package # 秀套件檔案列表
  • pip list --outdated # 列出過期套件
  • pip install --upgrade package # 升級

>> save next code to pipupv27.py
>> python2 pipupv27.py
then will auto scan the pip upgrade package list and  type y/a/n to select the function


#====================================================
import time
import sys
import os

os.system("pip2.7 list --outdated > chklist.txt")
f = open("chklist.txt",'r')
ss = f.read()
f.close()
kss = ss.split("\n")
#print ss

for i in kss:
    print (i)

kk='n'
kk2='n'
kk = raw_input("\nare you want to upgrate(y:1by1/a:all/n) : ")
if kk == 'n':
    print "\nby by ..."
    exit()

if kk == 'a':
        for i in kss:
                if i.split(" ")[0] != "numpy":
                    os.system("pip2.7 install --upgrade "+i.split(" ")[0])
else:
        for i in kss:
                ss2 = i.split(" ")[0]
                print (ss2)
                kk2 = raw_input("\n update it (y n):")
                if kk2 == 'y':
                    if i.split(" ")[0] != "numpy":
                        os.system("pip2.7 install --upgrade "+i.split(" ")[0])
                else:
                    print ("\npass to next")

#========================================================


沒有留言: