Update All Easy_Install Python Eggs


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/usr/bin/env python
  2. from setuptools.command.easy_install import main as install
  3. from pkg_resources import Environment, working_set
  4. import sys
  5.  
  6. #Packages managed by setuptools
  7. plist = [dist.key for dist in working_set]
  8.  
  9. def autoUp():
  10. for p in Environment():
  11. try:
  12. install(['-U', '-v']+[p])
  13. except:
  14. print "Update of %s failed!"%p
  15. print "Done!"
  16.  
  17. def stepUp():
  18. for p in Environment():
  19. a = raw_input("updating %s, confirm? (y/n)"%p)
  20. if a =='y':
  21. try:
  22. install(['-U']+[p])
  23. except:
  24. print "Update of %s failed!"%p
  25. else:
  26. print "Skipping %s"%p
  27. print "Done!"
  28.  
  29. print "You have %s packages currently managed through Easy_install"%len(plist)
  30. print plist
  31. ans = raw_input('Do you want to update them... (N)ot at all, (O)ne-by-one, (A)utomatically (without prompting)')
  32. if ans == 'N':
  33. sys.exit()
  34. elif ans == 'O':
  35. stepUp()
  36. elif ans == 'A':
  37. autoUp()
  38. else:
  39. pass

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.