Skip to content

Commit 1702406

Browse files
committed
🎨 Format Python code with Black
1 parent 27376f5 commit 1702406

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

server.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import hmac
33
import hashlib
44
import asyncio
5+
56
# import subprocess
67

78
from sanic import Sanic
@@ -51,7 +52,9 @@ async def notify(message, repository="dev"):
5152
if type(e).__name__ == "CancelledError":
5253
pass
5354
else:
54-
raise Exception(f" {type(e).__name__} while trying to notify about commit '{commit_message}' on {repository}/{branch}: {e}")
55+
raise Exception(
56+
f" {type(e).__name__} while trying to notify about commit '{commit_message}' on {repository}/{branch}: {e}"
57+
)
5558

5659

5760
@app.route("/github", methods=["GET"])
@@ -479,7 +482,9 @@ async def github(request):
479482
repository = request.json["repository"]["name"]
480483
user = request.json["sender"]["login"]
481484
url = request.json["commit"]["html_url"]
482-
commit_message = request.json["commit"]["commit"]["message"].replace("\n", " ")
485+
commit_message = request.json["commit"]["commit"]["message"].replace(
486+
"\n", " "
487+
)
483488
if request.json["commit"]["commit"]["committer"]:
484489
commit_author = request.json["commit"]["commit"]["committer"]["name"]
485490
else:
@@ -490,12 +495,12 @@ async def github(request):
490495
if description == "Pipeline failed on GitLab":
491496
pipeline_id = target_url.split("/")[-1]
492497
await notify(
493-
f'[{repository}] 🔴 Pipeline [#{pipeline_id}]({target_url}) failed on branch {branches}'
498+
f"[{repository}] 🔴 Pipeline [#{pipeline_id}]({target_url}) failed on branch {branches}"
494499
)
495500
elif description == "Pipeline canceled on GitLab":
496501
pipeline_id = target_url.split("/")[-1]
497502
await notify(
498-
f'[{repository}] ✖️ Pipeline [#{pipeline_id}]({target_url}) canceled on branch {branches}'
503+
f"[{repository}] ✖️ Pipeline [#{pipeline_id}]({target_url}) canceled on branch {branches}"
499504
)
500505
else:
501506
await notify(
@@ -530,4 +535,4 @@ async def index(request):
530535

531536

532537
if __name__ == "__main__":
533-
app.run('127.0.0.1', port="4567")
538+
app.run("127.0.0.1", port="4567")

to_room.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,33 @@ def connect():
2727

2828
client.sendInitPresence(requestRoster=0)
2929

30-
presence = xmpp.Presence(attrs={'id': uuid.uuid4()}, to="%[email protected]" % room)
31-
presence.setTag('x', namespace='http://jabber.org/protocol/muc')
30+
presence = xmpp.Presence(
31+
attrs={"id": uuid.uuid4()}, to="%[email protected]" % room
32+
)
33+
presence.setTag("x", namespace="http://jabber.org/protocol/muc")
3234

3335
client.send(presence)
3436

35-
client.send(xmpp.Presence(attrs={'id': uuid.uuid4()}, to='%[email protected]/GitBot' % room))
37+
client.send(
38+
xmpp.Presence(
39+
attrs={"id": uuid.uuid4()},
40+
to="%[email protected]/GitBot" % room,
41+
)
42+
)
3643

3744
def sendToChatRoom(message):
3845
if not client.connected:
3946
connect()
4047
client.connected = True
4148

42-
client.send(xmpp.protocol.Message("%[email protected]" % room, message, typ="groupchat", attrs={'id': uuid.uuid4()}))
49+
client.send(
50+
xmpp.protocol.Message(
51+
"%[email protected]" % room,
52+
message,
53+
typ="groupchat",
54+
attrs={"id": uuid.uuid4()},
55+
)
56+
)
4357

4458
client.sendToChatRoom = sendToChatRoom
4559

@@ -49,7 +63,7 @@ def sendToChatRoom(message):
4963
client.disconnect()
5064

5165

52-
if __name__ == '__main__':
66+
if __name__ == "__main__":
5367
if len(sys.argv[1:]) < 2:
5468
print("Usage : python to_room.py <password> <message> [<room name>]")
5569
sys.exit(1)

0 commit comments

Comments
 (0)