added install/uninstall packages for python

This commit is contained in:
Ekaterina.Tuzova
2012-01-16 12:52:20 +04:00
parent 8c7e195a2e
commit 82a79a426d
3 changed files with 27 additions and 3 deletions

View File

@@ -29,6 +29,21 @@ def do_uninstall(pkg):
error("Python package management tool 'pip' not found. Please install 'pip'", ERROR_NO_PACKAGING_TOOLS)
return pip.main(['uninstall', '-y', pkg])
def do_install(pkg, options):
"""
simple realization for install packages
"""
#TODO: test install
try:
import pip
except ImportError:
error("Python package management tool 'pip' not found. Please install 'pip'", ERROR_NO_PACKAGING_TOOLS)
if options:
return pip.main(['install', pkg, options])
else:
return pip.main(['install', pkg])
def main():
retcode = 0
try:
@@ -41,10 +56,11 @@ def main():
usage()
do_list()
elif cmd == 'install':
if len(sys.argv) != 3:
if len(sys.argv) < 3:
usage()
pkg = sys.argv[2]
retcode = do_install(pkg)
options = sys.argv[3]
retcode = do_install(pkg, options)
elif cmd == 'uninstall':
if len(sys.argv) != 3:
usage()