本文整理汇总了Python中pythonbrew.log.logger.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install_pythonbrew
def install_pythonbrew():
PythonbrewInstaller.install(INSTALLER_ROOT)
# for bash
shrc = yourshrc = "bashrc"
logger.log(
"""
Well-done! Congratulations!
The pythonbrew is installed as:
%(ROOT)s
Please add the following line to the end of your ~/.%(yourshrc)s
[[ -s "%(PATH_ETC)s/%(shrc)s" ]] && source "%(PATH_ETC)s/%(shrc)s"
After that, exit this shell, start a new one, and install some fresh
pythons:
pythonbrew install 2.7.2
pythonbrew install 3.2
For further instructions, run:
pythonbrew help
The default help messages will popup and tell you what to do!
Enjoy pythonbrew at %(ROOT)s!!
"""
% {"ROOT": ROOT, "yourshrc": yourshrc, "shrc": shrc, "PATH_ETC": PATH_ETC.replace(os.getenv("HOME"), "$HOME")}
)
示例2: install_setuptools
def install_setuptools(self):
options = self.options
pkgname = self.pkg.name
if options.no_setuptools:
logger.log("Skip installation of setuptools.")
return
download_url = DISTRIBUTE_SETUP_DLSITE
filename = Link(download_url).filename
download_file = os.path.join(PATH_DISTS, filename)
dl = Downloader()
dl.download(filename, download_url, download_file)
install_dir = os.path.join(PATH_PYTHONS, pkgname)
path_python = os.path.join(install_dir,"bin","python")
try:
s = Subprocess(log=self.logfile, cwd=PATH_DISTS, verbose=self.options.verbose)
logger.info("Installing distribute into %s" % install_dir)
s.check_call([path_python, filename])
# installing pip
easy_install = os.path.join(install_dir, 'bin', 'easy_install')
if os.path.isfile(easy_install):
logger.info("Installing pip into %s" % install_dir)
s.check_call([easy_install, 'pip'])
except:
logger.error("Failed to install setuptools. See %s/build.log to see why." % (ROOT))
logger.log("Skip installation of setuptools.")
示例3: install_pythonbrew
def install_pythonbrew():
PythonbrewInstaller.install(INSTALLER_ROOT)
# for bash
shrc = yourshrc = "bashrc"
logger.log("""
Well-done! Congratulations!
The pythonbrew is installed as:
%(ROOT)s
Please add the following line to the end of your ~/.%(yourshrc)s
source %(PATH_ETC)s/%(shrc)s
After that, exit this shell, start a new one, and install some fresh
pythons:
pythonbrew install 2.7.2
pythonbrew install 3.2
For further instructions, run:
pythonbrew help
The default help messages will popup and tell you what to do!
Enjoy pythonbrew at %(ROOT)s!!
""" % {'ROOT':ROOT, 'yourshrc':yourshrc, 'shrc':shrc, 'PATH_ETC':PATH_ETC})
示例4: systemwide_pythonbrew
def systemwide_pythonbrew():
PythonbrewInstaller.install(INSTALLER_ROOT)
PythonbrewInstaller.systemwide_install()
logger.log(
"""
Well-done! Congratulations!
The pythonbrew is installed as:
%(ROOT)s
After that, exit this shell, start a new one, and install some fresh
pythons:
pythonbrew install 2.7.2
pythonbrew install 3.2
For further instructions, run:
pythonbrew help
The default help messages will popup and tell you what to do!
Enjoy pythonbrew at %(ROOT)s!!
"""
% {"ROOT": ROOT}
)
示例5: configure
def configure(self):
s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
cmd = "./configure --prefix=%s %s %s" % (
self.install_dir,
self.options.configure,
" ".join(self.configure_options),
)
if self.options.verbose:
logger.log(cmd)
s.check_call(cmd)
示例6: run_command_print_activate
def run_command_print_activate(self, options, args):
if len(args) < 2:
logger.error("Unrecognized command line argument: ( 'pythonbrew venv print_activate <project>' )")
sys.exit(1)
activate = os.path.join(self._workon_home, args[1], 'bin', 'activate')
if not os.path.exists(activate):
logger.error('`%s` environment already does not exist. Try `pythonbrew venv create %s`.' % (args[1], args[1]))
sys.exit(1)
logger.log(activate)
示例7: shell
def shell(self, cmd):
if self._debug:
logger.log(cmd)
if is_sequence(cmd):
cmd = "".join(cmd)
if self._log:
if self._verbose:
cmd = "(%s) 2>&1 | tee '%s'" % (cmd, self._log)
else:
cmd = "(%s) >> '%s' 2>&1" % (cmd, self._log)
returncode = subprocess.call(cmd, shell=True, cwd=self._cwd)
if returncode:
raise ShellCommandException("%s: failed to `%s`" % (returncode, cmd))
示例8: _update_config
def _update_config(self, options, args):
# config.cfg update
# TODO: Automatically create for config.cfg
download_url = PYTHONBREW_UPDATE_URL_CONFIG
if not download_url:
logger.error("Invalid download url in config.cfg. `%s`" % download_url)
sys.exit(1)
distname = Link(PYTHONBREW_UPDATE_URL_CONFIG).filename
download_file = PATH_ETC_CONFIG
try:
d = Downloader()
d.download(distname, download_url, download_file)
except:
logger.error("Failed to download. `%s`" % download_url)
sys.exit(1)
logger.log("The config.cfg has been updated.")
示例9: install
def install(self):
# cleanup
if os.path.isdir(self.build_dir):
shutil.rmtree(self.build_dir)
# get content type.
if is_file(self.download_url):
path = fileurl_to_path(self.download_url)
self.content_type = mimetypes.guess_type(path)[0]
else:
headerinfo = get_headerinfo_from_url(self.download_url)
self.content_type = headerinfo["content-type"]
if is_html(self.content_type):
# note: maybe got 404 or 503 http status code.
logger.error("Invalid content-type: `%s`" % self.content_type)
return
if os.path.isdir(self.install_dir):
logger.info("You are already installed `%s`" % self.pkg.name)
return
self.download_and_extract()
logger.info(
"\nThis could take a while. You can run the following command on another shell to track the status:"
)
logger.info(" tail -f %s\n" % self.logfile)
self.patch()
logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir))
try:
self.configure()
self.make()
self.make_install()
except:
rm_r(self.install_dir)
logger.error("Failed to install %s. See %s to see why." % (self.pkg.name, self.logfile))
logger.log(" pythonbrew install --force %s" % self.pkg.version)
sys.exit(1)
self.symlink()
self.install_setuptools()
logger.info(
"\nInstalled %(pkgname)s successfully. Run the following command to switch to %(pkgname)s."
% {"pkgname": self.pkg.name}
)
logger.info(" pythonbrew switch %s" % self.pkg.alias)
示例10: call
def call(self, cmd):
if is_str(cmd):
cmd = shlex.split(cmd)
if self._debug:
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)
while p.returncode is None:
while bltin_any(select.select([p.stdout], [], [])):
line = to_str(p.stdout.readline())
if not line:
break
if self._verbose:
logger.log(line.strip())
if fp:
fp.write(line)
fp.flush()
p.poll()
if fp:
fp.close()
return p.returncode
示例11: installed
def installed(self, options, args):
logger.log("# pythonbrew pythons")
cur = get_using_python_pkgname()
for d in sorted(os.listdir(PATH_PYTHONS)):
if cur and cur == d:
logger.log(' %s (*)' % d)
else:
logger.log(' %s' % d)
示例12: run_command_list
def run_command_list(self, options, args):
if options.all:
for pkgname in get_installed_pythons_pkgname():
workon_home = os.path.join(PATH_VENVS, pkgname)
logger.log("# virtualenv for %(pkgname)s (found in %(workon_home)s)" % {'pkgname': pkgname, 'workon_home': workon_home})
if os.path.isdir(workon_home):
for d in sorted(os.listdir(workon_home)):
if os.path.isdir(os.path.join(workon_home, d)):
logger.log(d)
else:
logger.log("# virtualenv for %(pkgname)s (found in %(workon_home)s)" % {'pkgname': self._pkgname, 'workon_home': self._workon_home})
if os.path.isdir(self._workon_home):
for d in sorted(os.listdir(self._workon_home)):
if os.path.isdir(os.path.join(self._workon_home, d)):
logger.log(d)
示例13: run_command
def run_command(self, options, args):
if args:
command = args[0]
if command not in command_dict:
parser.error("Unknown command: `%s`" % command)
return
command = command_dict[command]
command.parser.print_help()
return
parser.print_help()
logger.log("\nCommands available:")
commands = [command_dict[key] for key in sorted(command_dict.keys())]
for command in commands:
logger.log(" %s: %s" % (command.name, command.summary))
logger.log("\nFurther Instructions:")
logger.log(" https://github.com/utahta/pythonbrew")
示例14: run_command
def run_command(self, options, args):
if args:
bin_ = args[0]
else:
bin_ = 'python'
# target python interpreter
if options.python:
pkgname = Package(options.python).name
if not is_installed(pkgname):
logger.error('%s is not installed.' % pkgname)
sys.exit(1)
else:
pkgname = get_using_python_pkgname()
if not pkgname:
logger.error("Unknown python version: ( 'pythonbrew locate -p VERSION' )")
sys.exit(1)
if options.venv:
venv_pkgdir = os.path.join(PATH_VENVS, pkgname)
venv_dir = os.path.join(venv_pkgdir, options.venv)
if not os.path.isdir(venv_dir):
logger.error("`%s` environment was not found in %s." % (options.venv, venv_pkgdir))
sys.exit(1)
bindir = os.path.join(venv_dir, 'bin')
else:
bindir = os.path.join(PATH_PYTHONS, pkgname, 'bin')
if not os.path.isdir(bindir):
logger.error("`%s` is not installed." % pkgname)
sys.exit(1)
path = os.path.join(bindir, bin_)
logger.log(path)
示例15: available_install
def available_install(self, options, args):
logger.log('# Pythons')
if args:
pkg = Package(args[0])
_re = re.compile(r"%s" % pkg.name)
pkgs = []
for pkgname in self._get_packages_name(options):
if _re.match(pkgname):
pkgs.append(pkgname)
if pkgs:
for pkgname in pkgs:
logger.log("%s" % pkgname)
else:
logger.error("`%s` was not found." % pkg.name)
else:
for pkgname in self._get_packages_name(options):
logger.log("%s" % pkgname)