Ejemplo n.º 1
0
 def emit_update(self):
     rdb.publish(
         'actions',
         json.dumps({
             'type': 'GUILD_UPDATE',
             'id': self.guild_id,
         }))
Ejemplo n.º 2
0
    def dispatch(cls, typ, **kwargs):
        obj = cls.create(
            type_=typ,
            metadata=kwargs
        )

        rdb.publish('notifications', json.dumps(obj.to_user()))
        return obj
Ejemplo n.º 3
0
def deploy():
    if not g.user.admin:
        return '', 401

    subprocess.Popen(['git', 'pull', 'origin', 'master']).wait()
    rdb.publish('actions', json.dumps({
        'type': 'RESTART',
    }))
    return '', 200
Ejemplo n.º 4
0
def webhook_circle_ci():
    data = request.json['payload']

    embed = MessageEmbed()

    if data['outcome'] == 'success':
        embed.color = 0x42c88a
    else:
        embed.color = 0xed5c5c

    embed.title = 'Build #{} - {} ({})'.format(
        data['build_num'],
        data['subject'],
        data['author_name'],
    )

    embed.url = data['build_url']

    steps = []
    for step in data['steps']:
        emoji = ':x:' if any(
            True for act in step['actions']
            if act.get('failed', False)) else ':white_check_mark:'
        steps.append('{} - {}'.format(emoji, step['name']))

    embed.description = '\n'.join(steps)
    embed.description += '\n [View Diff]({})'.format(data['compare'])

    Webhook.execute_url(current_app.config.get('WEBHOOK_URL'), embeds=[embed])

    if data['outcome'] != 'success':
        return

    subprocess.Popen(['git', 'pull', 'origin', 'master']).wait()
    rdb.publish('actions', json.dumps({
        'type': 'RESTART',
    }))
    return '', 200