update symlink,uninstall command

This commit is contained in:
utahta
2011-05-25 13:30:46 +09:00
parent c92148805d
commit aa0bc97bc8
4 changed files with 15 additions and 5 deletions
+10 -2
View File
@@ -1,7 +1,7 @@
import os
from pythonbrew.basecommand import Command
from pythonbrew.define import PATH_PYTHONS
from pythonbrew.util import off, rm_r, Package, get_current_python_path
from pythonbrew.define import PATH_PYTHONS, PATH_BIN
from pythonbrew.util import off, rm_r, Package, get_current_python_path, unlink
from pythonbrew.log import logger
class UninstallCommand(Command):
@@ -21,6 +21,14 @@ class UninstallCommand(Command):
continue
if get_current_python_path() == os.path.join(pkgpath,'bin','python'):
off()
for d in os.listdir(PATH_BIN):
# remove symlink
path = os.path.join(PATH_BIN, d)
if os.path.islink(path):
basename = os.path.basename(os.path.realpath(path))
tgtpath = os.path.join(pkgpath, 'bin', basename)
if os.path.isfile(tgtpath) and os.path.samefile(path, tgtpath):
unlink(path)
rm_r(pkgpath)
else:
self.parser.print_help()