本文整理汇总了Python中bundlewrap.utils.LOG.debug方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.debug方法的具体用法?Python LOG.debug怎么用?Python LOG.debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bundlewrap.utils.LOG
的用法示例。
在下文中一共展示了LOG.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: node_apply_end
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def node_apply_end(repo, node, duration=None, interactive=None, result=None, **kwargs):
if environ.get('TERM_PROGRAM', None) != "iTerm.app" or not interactive:
LOG.debug("skipping iTerm stats (wrong terminal)")
return
if not IMPORTS:
LOG.error("failed to import dependencies of itermstats plugin")
return
css_file = NamedTemporaryFile(delete=False)
css_file.write(".text-overlay { display: none; }")
css_file.close()
config = Config(
height=150,
style=STYLE,
width=350,
)
config.css.append(css_file.name)
chart = Pie(config)
chart.add('correct', result.correct)
chart.add('fixed', result.fixed)
chart.add('skipped', result.skipped)
chart.add('failed', result.failed)
png_data = cairosvg.svg2png(bytestring=chart.render())
png_data_b64 = b64encode(png_data)
remove(css_file.name)
print("\033]1337;File=inline=1:{}\007".format(png_data_b64))
示例2: _write_local_file
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def _write_local_file(self):
"""
Makes the file contents available at the returned temporary path
and performs local verification if necessary or requested.
The calling method is responsible for cleaning up the file at
the returned path (only if not a binary).
"""
if self.attributes['content_type'] == 'binary':
local_path = self.template
else:
handle, local_path = mkstemp()
with open(local_path, 'wb') as f:
f.write(self.content)
if self.attributes['verify_with']:
cmd = self.attributes['verify_with'].format(quote(local_path))
LOG.debug("calling local verify command for {i}: {c}".format(c=cmd, i=self.id))
if call(cmd, shell=True) == 0:
LOG.debug("{i} passed local validation".format(i=self.id))
else:
raise BundleError(_(
"{i} failed local validation using: {c}"
).format(c=cmd, i=self.id))
return local_path
示例3: diff
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def diff(content_old, content_new, filename, encoding_hint=None):
output = ""
LOG.debug("diffing {filename}: {len_before} B before, {len_after} B after".format(
filename=filename,
len_before=len(content_old),
len_after=len(content_new),
))
content_old = force_text(content_old)
content_new = force_text(content_new)
start = datetime.now()
for line in unified_diff(
content_old.splitlines(True),
content_new.splitlines(True),
fromfile=filename,
tofile=_("<bundlewrap content>"),
):
suffix = ""
line = force_text(line).rstrip("\n")
if len(line) > DIFF_MAX_LINE_LENGTH:
line = line[:DIFF_MAX_LINE_LENGTH]
suffix += _(" (line truncated after {} characters)").format(DIFF_MAX_LINE_LENGTH)
if line.startswith("+"):
line = green(line)
elif line.startswith("-"):
line = red(line)
output += line + suffix + "\n"
duration = datetime.now() - start
LOG.debug("diffing {file}: complete after {time}s".format(
file=filename,
time=duration.total_seconds(),
))
return output
示例4: apply
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def apply(self, interactive=False, interactive_default=True):
self.node.repo.hooks.item_apply_start(
self.node.repo,
self.node,
self,
)
status_code = None
status_before = None
status_after = None
start_time = datetime.now()
if self.triggered and not self.has_been_triggered:
LOG.debug(_("skipping {} because it wasn't triggered").format(self.id))
status_code = self.STATUS_SKIPPED
if status_code is None and self.cached_unless_result:
LOG.debug(_("'unless' for {} succeeded, not fixing").format(self.id))
status_code = self.STATUS_SKIPPED
if status_code is None:
status_before = self.cached_status
if status_before.correct:
status_code = self.STATUS_OK
if status_code is None:
if not interactive:
self.fix(status_before)
status_after = self.get_status()
else:
question = wrap_question(
self.id,
self.ask(status_before),
_("Fix {}?").format(bold(self.id)),
)
if ask_interactively(question,
interactive_default):
self.fix(status_before)
status_after = self.get_status()
else:
status_code = self.STATUS_SKIPPED
if status_code is None:
if status_after.correct:
status_code = self.STATUS_FIXED
else:
status_code = self.STATUS_FAILED
self.node.repo.hooks.item_apply_end(
self.node.repo,
self.node,
self,
duration=datetime.now() - start_time,
status_code=status_code,
status_before=status_before,
status_after=status_after,
)
return status_code
示例5: _create_config
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def _create_config(path):
LOG.debug("writing initial config for Slack notifications to .slack.cfg")
config = SafeConfigParser()
config.add_section("configuration")
config.set("configuration", "enabled", "unconfigured")
config.set("configuration", "username", "your-slack-username")
config.add_section("connection")
config.set("connection", "url",
"<insert URL from https://my.slack.com/services/new/incoming-webhook>")
config.add_section("apply_notifications")
config.set("apply_notifications", "enabled", "yes")
config.set("apply_notifications", "allow_groups", "all")
config.set("apply_notifications", "deny_groups", "local")
with open(path, 'wb') as f:
config.write(f)
示例6: _create_config
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def _create_config(path):
LOG.debug("writing initial config for HipChat notifications to .hipchat_secrets.cfg")
config = SafeConfigParser()
config.add_section("configuration")
config.set("configuration", "enabled", "unconfigured")
config.add_section("connection")
config.set("connection", "server", "api.hipchat.com")
config.set("connection", "token", "<insert token from https://www.hipchat.com/account/api>")
config.add_section("apply_notifications")
config.set("apply_notifications", "enabled", "yes")
config.set("apply_notifications", "rooms", "name_or_id_of_room1,name_or_id_of_room2")
config.add_section("item_notifications")
config.set("item_notifications", "enabled", "no")
config.set("item_notifications", "rooms", "name_or_id_of_room1,name_or_id_of_room2")
with open(path, 'wb') as f:
config.write(f)
示例7: apply_end
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def apply_end(repo, target, nodes, duration=None, **kwargs):
config = _get_config(repo.path)
if config is None or \
not config.has_section("apply_notifications") or \
not config.getboolean("apply_notifications", "enabled"):
return
for room in config.get("apply_notifications", "rooms").split(","):
LOG.debug("posting apply end notification to HipChat room {room}@{server}".format(
room=room,
server=config.get("connection", "server"),
))
_notify(
config.get("connection", "server"),
room.strip(),
config.get("connection", "token"),
"Finished bw apply on <b>{target}</b>.".format(target=target),
"html",
)
示例8: diff
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def diff(content_old, content_new, filename, encoding_hint=None):
output = ""
LOG.debug("diffing {filename}: {len_before} B before, {len_after} B after".format(
filename=filename,
len_before=len(content_old),
len_after=len(content_new),
))
start = datetime.now()
for line in unified_diff(
content_old.splitlines(True),
content_new.splitlines(True),
fromfile=filename,
tofile=_("<bundlewrap content>"),
):
suffix = ""
try:
line = line.decode('utf-8')
except UnicodeDecodeError:
if encoding_hint and encoding_hint.lower() != "utf-8":
try:
line = line.decode(encoding_hint)
suffix += _(" (line encoded in {})").format(encoding_hint)
except UnicodeDecodeError:
line = line[0]
suffix += _(" (line not encoded in UTF-8 or {})").format(encoding_hint)
else:
line = line[0]
suffix += _(" (line not encoded in UTF-8)")
line = line.rstrip("\n")
if len(line) > DIFF_MAX_LINE_LENGTH:
line = line[:DIFF_MAX_LINE_LENGTH]
suffix += _(" (line truncated after {} characters)").format(DIFF_MAX_LINE_LENGTH)
if line.startswith("+"):
line = green(line)
elif line.startswith("-"):
line = red(line)
output += line + suffix + "\n"
duration = datetime.now() - start
LOG.debug("diffing {file}: complete after {time}s".format(
file=filename,
time=duration.total_seconds(),
))
return output
示例9: _get_config
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def _get_config(repo_path):
config_path = join(repo_path, ".slack.cfg")
if not exists(config_path):
_create_config(config_path)
config = SafeConfigParser()
config.read(config_path)
if config.get("configuration", "enabled") == "unconfigured":
LOG.error("Slack notifications not configured. Please edit .slack.cfg "
"(it has already been created) and set enabled to 'yes' "
"(or 'no' to silence this message and disable Slack notifications).")
return None
elif config.get("configuration", "enabled").lower() not in ("yes", "true", "1"):
LOG.debug("Slack notifications not enabled in .slack.cfg, skipping...")
return None
elif not REQUESTS:
LOG.error("Slack notifications need the requests library. "
"You can usually install it with `pip install requests`.")
return None
return config
示例10: apply_end
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def apply_end(repo, target, nodes, duration=None, **kwargs):
config = _get_config(repo.path)
if config is None or \
not config.has_section("apply_notifications") or \
not config.getboolean("apply_notifications", "enabled") or \
not _check_allowed_groups(config, nodes):
return
LOG.debug("posting apply end notification to Slack")
_notify(
config.get("connection", "url"),
color="good",
fallback="Finished bw apply to {target} as {user} after {duration}s.".format(
duration=duration.total_seconds(),
target=target,
user=config.get("configuration", "username"),
),
target=target,
title="Finished bw apply after {}s.".format(duration.total_seconds()),
user=config.get("configuration", "username"),
)
示例11: apply_start
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def apply_start(repo, target, nodes, interactive=False, **kwargs):
config = _get_config(repo.path)
if config is None or \
not config.has_section("apply_notifications") or \
not config.getboolean("apply_notifications", "enabled") or \
not _check_allowed_groups(config, nodes):
return
LOG.debug("posting apply start notification to Slack")
_notify(
config.get("connection", "url"),
fallback="Starting bw apply to {target} as {user}".format(
target=target,
user=config.get("configuration", "username"),
),
target=target,
title=(
"Starting {interactive}interactive bw apply..."
).format(interactive="non-" if not interactive else ""),
user=config.get("configuration", "username"),
)
示例12: _get_result
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def _get_result(self, interactive=False, interactive_default=True):
if interactive is False and self.attributes['interactive'] is True:
return self.STATUS_SKIPPED
if self.triggered and not self.has_been_triggered:
LOG.debug(_("skipping {} because it wasn't triggered").format(self.id))
return self.STATUS_SKIPPED
if self.unless:
unless_result = self.bundle.node.run(
self.unless,
may_fail=True,
)
if unless_result.return_code == 0:
LOG.debug(_("{node}:{bundle}:action:{name}: failed 'unless', not running").format(
bundle=self.bundle.name,
name=self.name,
node=self.bundle.node.name,
))
return self.STATUS_SKIPPED
if (
interactive and
self.attributes['interactive'] is not False
and not ask_interactively(
wrap_question(
self.id,
self.attributes['command'],
_("Run action {}?").format(
bold(self.name),
),
),
interactive_default,
)
):
return self.STATUS_SKIPPED
try:
self.run(interactive=interactive)
return self.STATUS_ACTION_SUCCEEDED
except ActionFailure:
return self.STATUS_FAILED
示例13: item_apply_end
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def item_apply_end(
repo, node, item, duration=None, status_before=None, status_after=None, **kwargs
):
config = _get_config(repo.path)
if config is None or \
not config.has_section("item_notifications") or \
not config.getboolean("item_notifications", "enabled"):
return
color = "gray"
if status_before.correct:
return
elif status_after is None:
color = "purple"
status_string = "(unknown)"
elif status_after.correct:
color = "green"
status_string = "(successful)"
else:
color = "red"
status_string = "(failed)"
for room in config.get("item_notifications", "rooms").split(","):
LOG.debug("posting item apply end notification to HipChat room {room}@{server}".format(
room=room,
server=config.get("connection", "server"),
))
_notify(
config.get("connection", "server"),
room.strip(),
config.get("connection", "token"),
"{status_string} {node}:{bundle}:{item}".format(
bundle=item.bundle.name,
item=item,
node=node.name,
status_string=status_string,
),
"text",
color=color,
)
示例14: apply_start
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def apply_start(repo, target, nodes, interactive=False, **kwargs):
config = _get_config(repo.path)
if config is None or \
not config.has_section("apply_notifications") or \
not config.getboolean("apply_notifications", "enabled"):
return
for room in config.get("apply_notifications", "rooms").split(","):
LOG.debug("posting apply start notification to HipChat room {room}@{server}".format(
room=room,
server=config.get("connection", "server"),
))
_notify(
config.get("connection", "server"),
room.strip(),
config.get("connection", "token"),
(
"Starting {interactive}interactive "
"bw apply on <b>{target}</b>..."
).format(
interactive="non-" if not interactive else "",
target=target,
),
"html",
)
示例15: content_processor_mako
# 需要导入模块: from bundlewrap.utils import LOG [as 别名]
# 或者: from bundlewrap.utils.LOG import debug [as 别名]
def content_processor_mako(item):
from mako.lookup import TemplateLookup
from mako.template import Template
template = Template(
item._template_content.encode('utf-8'),
input_encoding='utf-8',
lookup=TemplateLookup(directories=[item.item_data_dir, item.item_dir]),
output_encoding=item.attributes['encoding'],
)
LOG.debug("{node}:{bundle}:{item}: rendering with Mako...".format(
bundle=item.bundle.name,
item=item.id,
node=item.node.name,
))
start = datetime.now()
try:
content = template.render(
item=item,
bundle=item.bundle,
node=item.node,
repo=item.node.repo,
**item.attributes['context']
)
except Exception as e:
LOG.debug("".join(format_exception(*exc_info())))
if isinstance(e, NameError) and e.message == "Undefined":
# Mako isn't very verbose here. Try to give a more useful
# error message - even though we can't pinpoint the excat
# location of the error. :/
e = _("Undefined variable (look for '${...}')")
raise TemplateError(_(
"Error while rendering template for {node}:{bundle}:{item}: {error}"
).format(
bundle=item.bundle.name,
error=e,
item=item.id,
node=item.node.name,
))
duration = datetime.now() - start
LOG.debug("{node}:{bundle}:{item}: rendered in {time}s".format(
bundle=item.bundle.name,
item=item.id,
node=item.node.name,
time=duration.total_seconds(),
))
return content