本文整理汇总了Python中pythonz.log.logger.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read
def read(cls, url):
try:
r = urllib.urlopen(url)
except IOError:
logger.log(traceback.format_exc())
raise DownloadError('Failed to fetch.')
return r.read()
示例2: install_pythonz
def install_pythonz():
PythonzInstaller.install(INSTALLER_ROOT)
# for bash
shrc = yourshrc = "bashrc"
logger.log("""
Well-done! Congratulations!
The pythonz 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:
pythonz install 2.7.2
pythonz install 3.2
For further instructions, run:
pythonz help
The default help messages will popup and tell you what to do!
Enjoy pythonz at %(ROOT)s!!
""" % {'ROOT': ROOT, 'yourshrc': yourshrc, 'shrc': shrc, 'PATH_ETC': PATH_ETC.replace(os.getenv('HOME'), '$HOME')})
示例3: read
def read(self, url):
try:
r = urllib.urlopen(url)
except IOError:
logger.log(traceback.format_exc())
raise CurlFetchException('Failed to fetch.')
return r.read()
示例4: fetch
def fetch(cls, url, filename):
b = ProgressBar()
try:
urllib.urlretrieve(url, filename, b.reporthook)
sys.stdout.write('\n')
except IOError:
sys.stdout.write('\n')
logger.log(traceback.format_exc())
raise DownloadError('Failed to fetch.')
示例5: readheader
def readheader(self, url):
try:
req = HEADRequest(url)
res = urllib2.urlopen(req)
except IOError:
logger.log(traceback.format_exc())
raise CurlFetchException('Failed to fetch.')
if res.code != 200:
raise CurlFetchException('Failed to fetch.')
return res.info()
示例6: 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)
示例7: read_head_info
def read_head_info(cls, url):
try:
req = HEADRequest(url)
res = urllib2.urlopen(req)
except IOError:
logger.log(traceback.format_exc())
raise DownloadError('Failed to fetch.')
if res.code != 200:
raise DownloadError('Failed to fetch.')
return res.info()
示例8: run_command
def run_command(self, options, args):
if not args or len(args) > 1:
self.parser.print_help()
return
pkg = Package(args[0], options.type)
pkgname = pkg.name
if not is_installed(pkg):
logger.error("`%s` is not installed." % pkgname)
return
logger.log(os.path.join(PATH_PYTHONS, pkgname, 'bin', 'python'))
示例9: 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))
示例10: _update_config
def _update_config(self, options, args):
# config.cfg update
# TODO: Automatically create for config.cfg
download_url = PYTHONZ_UPDATE_URL_CONFIG
if not download_url:
logger.error("Invalid download url in config.cfg. `%s`" % download_url)
sys.exit(1)
distname = Link(PYTHONZ_UPDATE_URL_CONFIG).filename
download_file = PATH_ETC_CONFIG
logger.info("Downloading %s as %s" % (distname, download_file))
try:
Downloader.fetch(download_url, download_file)
except DownloadError:
logger.error("Failed to download. `%s`" % download_url)
sys.exit(1)
logger.log("The config.cfg has been updated.")
示例11: run_command
def run_command(self, options, args):
if not args or len(args) > 1:
self.parser.print_help()
sys.exit(1)
pkg = Package(args[0], options.type)
pkgname = pkg.name
if not is_installed(pkg):
logger.error("`%s` is not installed." % pkgname)
sys.exit(1)
for bin in ('python3', 'python', 'pypy3', 'pypy'):
path = os.path.join(PATH_PYTHONS, pkgname, 'bin', bin)
if os.path.exists(path):
break
else:
# fallback
path = os.path.join(PATH_PYTHONS, pkgname, 'bin', 'python')
logger.log(path)
示例12: installed
def installed(self, path):
logger.log("# Installed Python versions")
for d in sorted(os.listdir(PATH_PYTHONS)):
if path:
logger.log(' %-16s %s/%s' % (d, PATH_PYTHONS, d))
else:
logger.log(' %s' % d)
示例13: all
def all(self):
logger.log('# Available Python versions')
for type, versions in PYTHON_VERSIONS_URLS.iteritems():
if versions:
logger.log(' # %s:' % type)
for version in (version for version in sorted(versions.keys())):
logger.log(' %s' % version)
示例14: 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 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
示例15: installed
def installed(self):
logger.log("# Installed Python versions")
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)