mirror of
https://github.com/kennethreitz-archive/python-build.git
synced 2026-06-05 23:30:18 +00:00
Improve venv command, log and bashrc
This commit is contained in:
+11
-8
@@ -10,7 +10,7 @@ import urllib
|
||||
import subprocess
|
||||
import shlex
|
||||
import select
|
||||
from pythonbrew.define import PATH_BIN, PATH_ETC_CURRENT, PATH_PYTHONS
|
||||
from pythonbrew.define import PATH_BIN, PATH_HOME_ETC_CURRENT, PATH_PYTHONS
|
||||
from pythonbrew.exceptions import ShellCommandException
|
||||
from pythonbrew.log import logger
|
||||
|
||||
@@ -209,10 +209,13 @@ def extract_downloadfile(content_type, download_file, target_dir):
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_using_python_path():
|
||||
p = subprocess.Popen('command -v python', stdout=subprocess.PIPE, shell=True)
|
||||
def get_command_path(command):
|
||||
p = subprocess.Popen('command -v %s' % command, stdout=subprocess.PIPE, shell=True)
|
||||
return to_str(p.communicate()[0].strip())
|
||||
|
||||
def get_using_python_path():
|
||||
return get_command_path('python')
|
||||
|
||||
def get_using_python_pkgname():
|
||||
"""return: Python-<VERSION> or None"""
|
||||
path = get_using_python_path()
|
||||
@@ -233,8 +236,8 @@ def is_installed(name):
|
||||
return True
|
||||
|
||||
def set_current_path(path):
|
||||
fp = open(PATH_ETC_CURRENT, 'w')
|
||||
fp.write('PATH_PYTHONBREW="%s"\n' % (path))
|
||||
fp = open(PATH_HOME_ETC_CURRENT, 'w')
|
||||
fp.write('PATH_PYTHONBREW_CURRENT="%s"\n' % (path))
|
||||
fp.close()
|
||||
|
||||
def path_to_fileurl(path):
|
||||
@@ -290,7 +293,7 @@ class Subprocess(object):
|
||||
|
||||
def shell(self, cmd):
|
||||
if self._debug:
|
||||
logger.info(cmd)
|
||||
logger.log(cmd)
|
||||
if self._log:
|
||||
if self._verbose:
|
||||
cmd = "(%s) 2>&1 | tee '%s'" % (cmd, self._log)
|
||||
@@ -304,7 +307,7 @@ class Subprocess(object):
|
||||
if is_str(cmd):
|
||||
cmd = shlex.split(cmd)
|
||||
if self._debug:
|
||||
logger.info(cmd)
|
||||
logger.log(cmd)
|
||||
|
||||
fp = ((self._log and open(self._log, 'a')) or None)
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self._cwd)
|
||||
@@ -314,7 +317,7 @@ class Subprocess(object):
|
||||
if not line:
|
||||
break
|
||||
if self._verbose:
|
||||
logger.info(line.strip())
|
||||
logger.log(line.strip())
|
||||
if fp:
|
||||
fp.write(line)
|
||||
fp.flush()
|
||||
|
||||
Reference in New Issue
Block a user