added some function to bashrc. fixed issue 2.

This commit is contained in:
utahta
2010-11-20 07:38:22 +09:00
parent 0bc17f56db
commit 0605c27c57
12 changed files with 107 additions and 33 deletions
+11 -14
View File
@@ -1,6 +1,5 @@
import os
import sys
import re
from pythonbrew.basecommand import Command
from pythonbrew.define import PATH_PYTHONS, PATH_BIN
from pythonbrew.util import off, symlink, Package
@@ -13,13 +12,13 @@ class SwitchCommand(Command):
def run_command(self, options, args):
if not args:
logger.error("Unrecognized command line argument: argument not found.")
logger.info("Unrecognized command line argument: argument not found.")
sys.exit(1)
pkg = Package(args[0])
pkgname = pkg.name
pkgdir = "%s/%s" % (PATH_PYTHONS, pkgname)
pkgdir = os.path.join(PATH_PYTHONS, pkgname)
if not os.path.isdir(pkgdir):
logger.error("`%s` is not installed." % pkgname)
logger.info("`%s` is not installed." % pkgname)
sys.exit(1)
self._switch_dir(pkgdir)
logger.info("Switched to %s" % pkgname)
@@ -27,15 +26,13 @@ class SwitchCommand(Command):
def _switch_dir(self, pkgdir):
off()
symlink(pkgdir, "%s/current" % PATH_PYTHONS)
for root, dirs, files in os.walk("%s/current/bin/" % PATH_PYTHONS):
for f in files:
symlink("%s%s" % (root, f), "%s/%s" % (PATH_BIN, f))
break
# I want better code
if not os.path.isfile("%s/python" % PATH_BIN):
if os.path.isfile("%s/python3" % PATH_BIN):
symlink(os.path.realpath("%s/python3" % PATH_BIN), "%s/python" % PATH_BIN)
elif os.path.isfile("%s/python3.0" % PATH_BIN):
symlink(os.path.realpath("%s/python3.0" % PATH_BIN), "%s/python" % PATH_BIN)
# I want better code...
current_bin = os.path.join(PATH_PYTHONS,'current','bin')
if not os.path.isfile(os.path.join(current_bin,"python")):
if os.path.isfile(os.path.join(current_bin,"python3")):
symlink(os.path.realpath("%s/python3" % current_bin), os.path.join(PATH_BIN,"python"))
elif os.path.isfile(os.path.join(current_bin,"python3.0")):
symlink(os.path.realpath("%s/python3.0" % current_bin), os.path.join(PATH_BIN,"python"))
SwitchCommand()