本文整理匯總了Python中distutils.debug.DEBUG屬性的典型用法代碼示例。如果您正苦於以下問題:Python debug.DEBUG屬性的具體用法?Python debug.DEBUG怎麽用?Python debug.DEBUG使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類distutils.debug
的用法示例。
在下文中一共展示了debug.DEBUG屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: debug_print
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def debug_print(self, msg):
"""Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
"""
from distutils.debug import DEBUG
if DEBUG:
print msg
sys.stdout.flush()
# -- Option validation methods -------------------------------------
# (these are very handy in writing the 'finalize_options()' method)
#
# NB. the general philosophy here is to ensure that a particular option
# value meets certain type and value constraints. If not, we try to
# force it into conformance (eg. if we expect a list but have a string,
# split the string on comma and/or whitespace). If we can't force the
# option into conformance, raise DistutilsOptionError. Thus, command
# classes need do nothing more than (eg.)
# self.ensure_string_list('foo')
# and they can be guaranteed that thereafter, self.foo will be
# a list of strings.
示例2: dump_dirs
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def dump_dirs (self, msg):
if DEBUG:
from distutils.fancy_getopt import longopt_xlate
print msg + ":"
for opt in self.user_options:
opt_name = opt[0]
if opt_name[-1] == "=":
opt_name = opt_name[0:-1]
if opt_name in self.negative_opt:
opt_name = string.translate(self.negative_opt[opt_name],
longopt_xlate)
val = not getattr(self, opt_name)
else:
opt_name = string.translate(opt_name, longopt_xlate)
val = getattr(self, opt_name)
print " %s: %s" % (opt_name, val)
示例3: test_debug_print
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def test_debug_print(self):
class MyCCompiler(CCompiler):
executables = {}
compiler = MyCCompiler()
with captured_stdout() as stdout:
compiler.debug_print('xxx')
stdout.seek(0)
self.assertEqual(stdout.read(), '')
debug.DEBUG = True
try:
with captured_stdout() as stdout:
compiler.debug_print('xxx')
stdout.seek(0)
self.assertEqual(stdout.read(), 'xxx\n')
finally:
debug.DEBUG = False
示例4: _spawn_os2
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def _spawn_os2(cmd, search_path=1, verbose=0, dry_run=0):
executable = cmd[0]
if search_path:
# either we find one or it stays the same
executable = find_executable(executable) or executable
log.info(' '.join([executable] + cmd[1:]))
if not dry_run:
# spawnv for OS/2 EMX requires a full path to the .exe
try:
rc = os.spawnv(os.P_WAIT, executable, cmd)
except OSError, exc:
# this seems to happen when the command isn't found
if not DEBUG:
cmd = executable
raise DistutilsExecError, \
"command %r failed: %s" % (cmd, exc[-1])
if rc != 0:
# and this reflects the command running but failing
if not DEBUG:
cmd = executable
log.debug("command %r failed with exit status %d" % (cmd, rc))
raise DistutilsExecError, \
"command %r failed with exit status %d" % (cmd, rc)
示例5: get_index_dist
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def get_index_dist(self):
if not self.download:
log.warn('Downloading {0!r} disabled.'.format(DIST_NAME))
return None
log.warn(
"Downloading {0!r}; run setup.py with the --offline option to "
"force offline installation.".format(DIST_NAME))
try:
dist = self._do_download()
except Exception as e:
if DEBUG:
raise
log.warn(
'Failed to download and/or install {0!r} from {1!r}:\n'
'{2}'.format(DIST_NAME, self.index_url, str(e)))
dist = None
# No need to run auto-upgrade here since we've already presumably
# gotten the most up-to-date version from the package index
return dist
示例6: debug_print
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def debug_print(self, msg):
"""Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
"""
from distutils.debug import DEBUG
if DEBUG:
print(msg)
sys.stdout.flush()
# -- Option validation methods -------------------------------------
# (these are very handy in writing the 'finalize_options()' method)
#
# NB. the general philosophy here is to ensure that a particular option
# value meets certain type and value constraints. If not, we try to
# force it into conformance (eg. if we expect a list but have a string,
# split the string on comma and/or whitespace). If we can't force the
# option into conformance, raise DistutilsOptionError. Thus, command
# classes need do nothing more than (eg.)
# self.ensure_string_list('foo')
# and they can be guaranteed that thereafter, self.foo will be
# a list of strings.
示例7: _spawn_nt
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def _spawn_nt(cmd, search_path=1, verbose=0, dry_run=0):
executable = cmd[0]
cmd = _nt_quote_args(cmd)
if search_path:
# either we find one or it stays the same
executable = find_executable(executable) or executable
log.info(' '.join([executable] + cmd[1:]))
if not dry_run:
# spawn for NT requires a full path to the .exe
try:
rc = os.spawnv(os.P_WAIT, executable, cmd)
except OSError as exc:
# this seems to happen when the command isn't found
if not DEBUG:
cmd = executable
raise DistutilsExecError(
"command %r failed: %s" % (cmd, exc.args[-1]))
if rc != 0:
# and this reflects the command running but failing
if not DEBUG:
cmd = executable
raise DistutilsExecError(
"command %r failed with exit status %d" % (cmd, rc))
示例8: dump_dirs
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def dump_dirs(self, msg):
"""Dumps the list of user options."""
if not DEBUG:
return
from distutils.fancy_getopt import longopt_xlate
log.debug(msg + ":")
for opt in self.user_options:
opt_name = opt[0]
if opt_name[-1] == "=":
opt_name = opt_name[0:-1]
if opt_name in self.negative_opt:
opt_name = self.negative_opt[opt_name]
opt_name = opt_name.translate(longopt_xlate)
val = not getattr(self, opt_name)
else:
opt_name = opt_name.translate(longopt_xlate)
val = getattr(self, opt_name)
log.debug(" %s: %s" % (opt_name, val))
示例9: debug_print
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def debug_print(self, msg):
from distutils.debug import DEBUG
if DEBUG:
print msg
示例10: debug_print
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def debug_print(self, msg):
"""Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
"""
from distutils.debug import DEBUG
if DEBUG:
print msg
# -- List-like methods ---------------------------------------------
示例11: test_debug_print
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def test_debug_print(self):
file_list = FileList()
with captured_stdout() as stdout:
file_list.debug_print('xxx')
self.assertEqual(stdout.getvalue(), '')
debug.DEBUG = True
try:
with captured_stdout() as stdout:
file_list.debug_print('xxx')
self.assertEqual(stdout.getvalue(), 'xxx\n')
finally:
debug.DEBUG = False
示例12: test_debug_print
# 需要導入模塊: from distutils import debug [as 別名]
# 或者: from distutils.debug import DEBUG [as 別名]
def test_debug_print(self):
cmd = self.cmd
with captured_stdout() as stdout:
cmd.debug_print('xxx')
stdout.seek(0)
self.assertEqual(stdout.read(), '')
debug.DEBUG = True
try:
with captured_stdout() as stdout:
cmd.debug_print('xxx')
stdout.seek(0)
self.assertEqual(stdout.read(), 'xxx\n')
finally:
debug.DEBUG = False