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))
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
def _notify(server, room, token, message, message_format, color="gray"): try: post( "https://{server}/v2/room/{room}/notification?auth_token={token}".format( token=token, room=room, server=server, ), headers={ 'content-type': 'application/json', }, data=dumps({ 'color': color, 'message': message, 'message_format': message_format, 'notify': True, }), ) except ConnectionError as e: LOG.error("Failed to submit HipChat notification: {}".format(e))
def _notify(server, room, token, message, message_format, color="gray"): try: post( "https://{server}/v2/room/{room}/notification?auth_token={token}". format( token=token, room=room, server=server, ), headers={ 'content-type': 'application/json', }, data=dumps({ 'color': color, 'message': message, 'message_format': message_format, 'notify': True, }), ) except ConnectionError as e: LOG.error("Failed to submit HipChat notification: {}".format(e))
def _notify(url, message=None, title=None, fallback=None, user=None, target=None, color="#000000"): payload = { "icon_url": "http://bundlewrap.org/img/icon.png", "username": "******", } if fallback: payload["attachments"] = [{ "color": color, "fallback": fallback, }] if message: payload["attachments"][0]["text"] = message if title: payload["attachments"][0]["title"] = title if target and user: payload["attachments"][0]["fields"] = [ { "short": True, "title": "User", "value": user, }, { "short": True, "title": "Target", "value": target, }, ] else: payload["text"] = message try: post( url, headers={ 'content-type': 'application/json', }, data=dumps(payload), ) except ConnectionError as e: LOG.error("Failed to submit Slack notification: {}".format(e))
def _get_config(repo_path): config_path = join(repo_path, ".hipchat_secrets.cfg") if not exists(config_path): _create_config(config_path) config = SafeConfigParser() config.read(config_path) if config.get("configuration", "enabled") == "unconfigured": LOG.error( "HipChat notifications not configured. Please edit .hipchat_secrets.cfg " "(it has already been created) and set enabled to 'yes' " "(or 'no' to silence this message and disable HipChat notifications)." ) return None elif config.get("configuration", "enabled").lower() not in ("yes", "true", "1"): LOG.debug( "HipChat notifications not enabled in .hipchat_secrets.cfg, skipping..." ) return None elif not REQUESTS: LOG.error("HipChat notifications need the requests library. " "You can usually install it with `pip install requests`.") return None return config