diff --git a/server.py b/server.py index b87a520..144943a 100644 --- a/server.py +++ b/server.py @@ -2,6 +2,7 @@ import hmac import hashlib import asyncio + # import subprocess from sanic import Sanic @@ -51,7 +52,9 @@ async def notify(message, repository="dev"): if type(e).__name__ == "CancelledError": pass else: - raise Exception(f" {type(e).__name__} while trying to notify about commit '{commit_message}' on {repository}/{branch}: {e}") + raise Exception( + f" {type(e).__name__} while trying to notify about commit '{commit_message}' on {repository}/{branch}: {e}" + ) @app.route("/github", methods=["GET"]) @@ -479,7 +482,9 @@ async def github(request): repository = request.json["repository"]["name"] user = request.json["sender"]["login"] url = request.json["commit"]["html_url"] - commit_message = request.json["commit"]["commit"]["message"].replace("\n", " ") + commit_message = request.json["commit"]["commit"]["message"].replace( + "\n", " " + ) if request.json["commit"]["commit"]["committer"]: commit_author = request.json["commit"]["commit"]["committer"]["name"] else: @@ -490,12 +495,12 @@ async def github(request): if description == "Pipeline failed on GitLab": pipeline_id = target_url.split("/")[-1] await notify( - f'[{repository}] 🔴 Pipeline [#{pipeline_id}]({target_url}) failed on branch {branches}' + f"[{repository}] 🔴 Pipeline [#{pipeline_id}]({target_url}) failed on branch {branches}" ) elif description == "Pipeline canceled on GitLab": pipeline_id = target_url.split("/")[-1] await notify( - f'[{repository}] ✖️ Pipeline [#{pipeline_id}]({target_url}) canceled on branch {branches}' + f"[{repository}] ✖️ Pipeline [#{pipeline_id}]({target_url}) canceled on branch {branches}" ) else: await notify( @@ -530,4 +535,4 @@ async def index(request): if __name__ == "__main__": - app.run('127.0.0.1', port="4567") + app.run("127.0.0.1", port="4567") diff --git a/to_room.py b/to_room.py index 45108b2..2386011 100644 --- a/to_room.py +++ b/to_room.py @@ -27,19 +27,33 @@ def XMPPBot(password, room="dev"): client.sendInitPresence(requestRoster=0) - presence = xmpp.Presence(attrs={'id': uuid.uuid4()}, to="%s@conference.yunohost.org" % room) - presence.setTag('x', namespace='http://jabber.org/protocol/muc') + presence = xmpp.Presence( + attrs={"id": uuid.uuid4()}, to="%s@conference.yunohost.org" % room + ) + presence.setTag("x", namespace="http://jabber.org/protocol/muc") client.send(presence) - client.send(xmpp.Presence(attrs={'id': uuid.uuid4()}, to='%s@conference.yunohost.org/GitBot' % room)) + client.send( + xmpp.Presence( + attrs={"id": uuid.uuid4()}, + to="%s@conference.yunohost.org/GitBot" % room, + ) + ) def sendToChatRoom(message): if not client.connected: connect() client.connected = True - client.send(xmpp.protocol.Message("%s@conference.yunohost.org" % room, message, typ="groupchat", attrs={'id': uuid.uuid4()})) + client.send( + xmpp.protocol.Message( + "%s@conference.yunohost.org" % room, + message, + typ="groupchat", + attrs={"id": uuid.uuid4()}, + ) + ) client.sendToChatRoom = sendToChatRoom @@ -49,7 +63,7 @@ def XMPPBot(password, room="dev"): client.disconnect() -if __name__ == '__main__': +if __name__ == "__main__": if len(sys.argv[1:]) < 2: print("Usage : python to_room.py []") sys.exit(1)