added use command. added some functions to bashrc.

This commit is contained in:
utahta
2010-11-25 01:12:24 +09:00
parent 159d839803
commit 611b71d635
14 changed files with 258 additions and 93 deletions
+10 -16
View File
@@ -1,9 +1,9 @@
import os
import sys
from subprocess import Popen, PIPE
from pythonbrew.basecommand import Command
from pythonbrew.define import PATH_PYTHONS
from pythonbrew.log import logger
from pythonbrew.util import get_current_python_path
class InstalledCommand(Command):
name = "installed"
@@ -11,20 +11,14 @@ class InstalledCommand(Command):
summary = "List the installed versions of python"
def run_command(self, options, args):
cur = None
if not os.path.islink("%s/current" % PATH_PYTHONS):
p = Popen('command -v python', stdout=PIPE, shell=True)
p.wait()
if p.returncode == 0:
logger.info("%s (*)" % p.stdout.read().strip())
elif os.path.islink("%s/current" % PATH_PYTHONS):
cur = os.path.basename(os.path.realpath("%s/current" % PATH_PYTHONS))
for d in sorted(os.listdir("%s/" % PATH_PYTHONS)):
if d == "current":
continue
if cur == d:
logger.info("%s (*)" % cur)
cur = get_current_python_path()
for d in sorted(os.listdir('%s/' % PATH_PYTHONS)):
if cur == os.path.join(PATH_PYTHONS, d, 'bin','python'):
logger.info('%s (*)' % d)
cur = None
else:
logger.info("%s" % (d))
logger.info(d)
if cur:
logger.info('%s (*)' % cur)
InstalledCommand()