mirror of
https://github.com/kennethreitz-archive/python-build.git
synced 2026-06-05 23:30:18 +00:00
modified install and uninstall command
This commit is contained in:
@@ -3,6 +3,8 @@ from pythonbrew.log import logger
|
||||
from pythonbrew.installer.pythoninstaller import PythonInstaller,\
|
||||
PythonInstallerMacOSX
|
||||
from pythonbrew.util import is_macosx_snowleopard
|
||||
from pythonbrew.exceptions import UnknownVersionException,\
|
||||
AlreadyInstalledException, NotSupportedVersionException
|
||||
|
||||
class InstallCommand(Command):
|
||||
name = "install"
|
||||
@@ -48,12 +50,20 @@ class InstallCommand(Command):
|
||||
|
||||
def run_command(self, options, args):
|
||||
if args:
|
||||
# Install Python
|
||||
if is_macosx_snowleopard():
|
||||
p = PythonInstallerMacOSX(args[0], options)
|
||||
else:
|
||||
p = PythonInstaller(args[0], options)
|
||||
p.install()
|
||||
# Install pythons
|
||||
for arg in args:
|
||||
try:
|
||||
if is_macosx_snowleopard():
|
||||
p = PythonInstallerMacOSX(arg, options)
|
||||
else:
|
||||
p = PythonInstaller(arg, options)
|
||||
p.install()
|
||||
except UnknownVersionException:
|
||||
continue
|
||||
except AlreadyInstalledException:
|
||||
continue
|
||||
except NotSupportedVersionException:
|
||||
continue
|
||||
else:
|
||||
logger.info("Unknown python version.")
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
import sys
|
||||
from pythonbrew.basecommand import Command
|
||||
from pythonbrew.define import PATH_PYTHONS
|
||||
from pythonbrew.util import off, rm_r, Package, get_current_python_path
|
||||
@@ -12,15 +11,17 @@ class UninstallCommand(Command):
|
||||
|
||||
def run_command(self, options, args):
|
||||
if args:
|
||||
pkg = Package(args[0])
|
||||
pkgname = pkg.name
|
||||
pkgpath = os.path.join(PATH_PYTHONS, pkgname)
|
||||
if not os.path.isdir(pkgpath):
|
||||
logger.info("`%s` is not installed." % pkgname)
|
||||
sys.exit(1)
|
||||
if get_current_python_path() == os.path.join(pkgpath,'bin','python'):
|
||||
off()
|
||||
rm_r(pkgpath)
|
||||
# Uninstall pythons
|
||||
for arg in args:
|
||||
pkg = Package(arg)
|
||||
pkgname = pkg.name
|
||||
pkgpath = os.path.join(PATH_PYTHONS, pkgname)
|
||||
if not os.path.isdir(pkgpath):
|
||||
logger.info("`%s` is not installed." % pkgname)
|
||||
continue
|
||||
if get_current_python_path() == os.path.join(pkgpath,'bin','python'):
|
||||
off()
|
||||
rm_r(pkgpath)
|
||||
else:
|
||||
self.parser.print_help()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user