removed installed command. added some functions to bashrc.

This commit is contained in:
utahta
2010-11-25 23:14:19 +09:00
parent 5fadee8e92
commit 8e54618ff4
6 changed files with 35 additions and 48 deletions
-24
View File
@@ -1,24 +0,0 @@
import os
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"
usage = "%prog"
summary = "List the installed versions of python"
def run_command(self, options, args):
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(d)
if cur:
logger.info('%s (*)' % cur)
InstalledCommand()
+3 -1
View File
@@ -63,10 +63,12 @@ class PythonbrewInstaller(object):
makedirs(PATH_ETC)
makedirs(PATH_BIN)
makedirs(PATH_LOG)
rm_r(PATH_SCRIPTS)
makedirs(PATH_SCRIPTS)
makedirs(PATH_SCRIPTS_PYTHONBREW)
makedirs(PATH_SCRIPTS_PYTHONBREW_COMMANDS)
for path in glob.glob(os.path.join(installer_root,"*.py")):
shutil.copy(path, PATH_SCRIPTS_PYTHONBREW)
+31 -16
View File
@@ -1,21 +1,21 @@
PYTHONBREW_ROOT="@ROOT@"
PYTHONBREW_ETC="$PYTHONBREW_ROOT/etc"
PATH_ROOT="@ROOT@"
PATH_ETC="$PATH_ROOT/etc"
__pythonbrew_set_default()
{
PATH_PYTHONBREW="$PYTHONBREW_ROOT/bin"
PATH_PYTHONBREW="$PATH_ROOT/bin"
}
__pythonbrew_set_path()
{
PATH_WITHOUT_PYTHONBREW=$(printf $PATH | awk -v RS=: -v ORS=: "/${PYTHONBREW_ROOT//\//\/}/ {next} {print}" | sed -e 's#:$##')
PATH_WITHOUT_PYTHONBREW=$(printf $PATH | awk -v RS=: -v ORS=: "/${PATH_ROOT//\//\/}/ {next} {print}" | sed -e 's#:$##')
export PATH=$PATH_PYTHONBREW:$PATH_WITHOUT_PYTHONBREW
}
__pythonbrew_set_temp_path()
{
if [[ -s "$PYTHONBREW_ETC/temp" ]] ; then
source "$PYTHONBREW_ETC/temp"
if [[ -s "$PATH_ETC/temp" ]] ; then
source "$PATH_ETC/temp"
else
__pythonbrew_set_default
fi
@@ -24,8 +24,8 @@ __pythonbrew_set_temp_path()
__pythonbrew_set_current_path()
{
if [[ -s "$PYTHONBREW_ETC/current" ]] ; then
source "$PYTHONBREW_ETC/current"
if [[ -s "$PATH_ETC/current" ]] ; then
source "$PATH_ETC/current"
else
__pythonbrew_set_default
fi
@@ -34,38 +34,52 @@ __pythonbrew_set_current_path()
__pythonbrew_reload()
{
if [[ -s "$PYTHONBREW_ETC/bashrc" ]] ; then
source "$PYTHONBREW_ETC/bashrc"
fi
[[ -s "$PATH_ETC/bashrc" ]] && source "$PATH_ETC/bashrc"
}
__pythonbrew_use()
{
command pythonbrew "$@"
__pythonbrew_set_temp_path
[[ $? == 0 ]] && __pythonbrew_set_temp_path
}
__pythonbrew_switch()
{
command pythonbrew "$@"
__pythonbrew_set_current_path
[[ $? == 0 ]] && __pythonbrew_set_current_path
}
__pythonbrew_off()
{
command pythonbrew "$@"
__pythonbrew_set_current_path
[[ $? == 0 ]] && __pythonbrew_set_current_path
}
__pythonbrew_update()
{
command pythonbrew "$@"
__pythonbrew_reload
[[ $? == 0 ]] && __pythonbrew_reload
}
__pythonbrew_find_command()
{
command_name=""
for arg in "$@" ; do
case $arg in
--*) continue;;
-*) continue;;
*)
command_name=$arg
break
;;
esac
done
}
pythonbrew()
{
case $1 in
__pythonbrew_find_command "$@"
case $command_name in
use) __pythonbrew_use "$@";;
switch) __pythonbrew_switch "$@" ;;
off) __pythonbrew_off "$@" ;;
@@ -77,3 +91,4 @@ pythonbrew()
# main
__pythonbrew_set_current_path
+1 -1
View File
@@ -6,11 +6,11 @@ import re
import posixpath
import tarfile
import platform
from subprocess import PIPE, Popen
from pythonbrew.define import PATH_BIN, PATH_PYTHONS, PATH_ETC_CURRENT,\
PATH_ETC_TEMP
from pythonbrew.exceptions import ShellCommandException
from pythonbrew.log import logger
from subprocess import PIPE, Popen
def size_format(b):
kb = 1000